How to use the @sentry/browser.withScope function in @sentry/browser

To help you get started, we’ve selected a few @sentry/browser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nusmodifications / nusmods / www / src / js / utils / error.ts View on Github external
export function captureException(error: any, extra: any = {}) {
  Sentry.withScope((scope) => {
    each(extra, (data, key) => {
      scope.setExtra(key, extra[key]);
    });

    Sentry.captureException(error);

    console.error(error); // eslint-disable-line no-console
    if (size(extra) > 0) console.error(extra); // eslint-disable-line no-console
  });
}
github Thorium-Sim / thorium / client / src / helpers / errorBoundary.js View on Github external
componentDidCatch(error, errorInfo) {
    // Catch errors in any components below and re-render with error message
    this.setState({
      error: error,
      errorInfo: errorInfo
    });
    // You can also log error messages to an error reporting service here
    Sentry.withScope(scope => {
      Object.keys(errorInfo).forEach(key => {
        scope.setExtra(key, errorInfo[key]);
      });
      Sentry.captureException(error);
    });
  }
  refresh() {
github nusmodifications / nusmods / www / src / js / views / errors / ModuleNotFoundPage.tsx View on Github external
componentDidMount() {
    Sentry.withScope(() => {
      Sentry.captureMessage('404 - Module Not Found');
    });

    // If we think this is a module, try checking for archived modules
    if (this.props.moduleCode.match(MODULE_CODE_REGEX)) {
      this.props.fetchModuleArchive(this.props.moduleCode);
    }
  }
github EnixCoda / Gitako / src / analytics.ts View on Github external
function reportError(
  error: Error,
  extra?: {
    [key: string]: any
  },
) {
  if (!IN_PRODUCTION_MODE) {
    console.error(error)
    console.error('Extra:\n', extra)
    return
  }

  Sentry.withScope(scope => {
    if (extra) {
      Object.keys(extra).forEach(key => {
        scope.setExtra(key, extra[key])
      })
    }
    Sentry.captureException(error)
  })
}
github keyteki / keyteki / client / Components / Site / ErrorBoundary.jsx View on Github external
componentDidCatch(error, errorInfo) {
        this.setState({ error });

        Sentry.withScope(scope => {
            scope.setExtras(errorInfo);
            const eventId = Sentry.captureException(error);
            this.setState({ eventId });
        });
    }
github OperationCode / front-end / pages / _app.js View on Github external
componentDidCatch(error, errorInfo) {
    Sentry.withScope(scope => {
      Object.keys(errorInfo).forEach(key => {
        scope.setExtra(key, errorInfo[key]);
      });

      Sentry.captureException(error);
    });

    super.componentDidCatch(error, errorInfo);
  }
github appbaseio / dashboard / src / pages / ErrorPage / ErrorPage.js View on Github external
componentDidCatch(error, errorInfo) {
		this.setState({
			error: true,
		});
		Sentry.withScope(scope => {
			Object.keys(errorInfo).forEach(key => {
				scope.setExtra(key, errorInfo[key]);
			});
			Sentry.captureException(error);
		});
	}
github sourcegraph / sourcegraph / web / src / components / ErrorBoundary.tsx View on Github external
public componentDidCatch(error: any, errorInfo: React.ErrorInfo): void {
        sentry.withScope(scope => {
            for (const [key, value] of Object.entries(errorInfo)) {
                scope.setExtra(key, value)
            }
            sentry.captureException(error)
        })
    }