How to use the @sentry/browser.configureScope 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 brianlovin / brian-lovin-next / src / components / Providers / Sentry.tsx View on Github external
componentDidCatch(error: any, errorInfo: any) {
    console.error({ errorInfo })
    Sentry.configureScope(scope => {
      Object.keys(errorInfo).forEach(key => {
        scope.setExtra(key, errorInfo[key]);
      });
    });
    Sentry.captureException(error);

    // This is needed to render errors correctly in development / production
    super.componentDidCatch(error, errorInfo);
  }
github magcius / noclip.website / src / main.ts View on Github external
if (!IS_DEVELOPMENT) {
            Sentry.init({
                dsn: 'https://a3b5f6c50bc04555835f9a83d6e76b23@sentry.io/1448331',
                beforeSend: (event) => {
                    // Filter out aborted XHRs.
                    if (event.exception!.values!.length) {
                        const exc = event.exception!.values![0];
                        if (exc.type === 'AbortedError')
                            return null;
                    }

                    return event;
                },
            });

            Sentry.configureScope((scope) => {
                scope.setExtra('git-revision', GIT_REVISION);
            });
        }
    }
github prescottprue / fireadmin / src / utils / errorHandler.js View on Github external
export function setErrorUser(auth) {
  if (auth && auth.uid && environment !== 'dev') {
    // Set user within Stackdriver
    if (errorHandler && errorHandler.setUser) {
      errorHandler.setUser(auth.uid)
    }
    // Set user within Sentry
    Sentry.configureScope(scope => {
      scope.setUser({
        id: auth.uid,
        email: auth.email || 'none'
      })
    })
  }
}
github patcito / nextjob / pages / _app.js View on Github external
componentDidCatch(error, errorInfo) {
    Sentry.configureScope(scope => {
      Object.keys(errorInfo).forEach(key => {
        scope.setExtra(key, errorInfo[key]);
      });
    });
    Sentry.captureException(error);

    // This is needed to render errors correctly in development / production
    super.componentDidCatch(error, errorInfo);
  }
github airbnb / lunar / packages / metrics / src / index.ts View on Github external
const { host, protocol } = global.location;

    if (!this.isSentryEnabled()) {
      return;
    }

    Sentry.init({
      dsn: `${protocol}//${sentryKey}@${host}/${sentryProject}`,
      enabled: true,
      environment: process.env.NODE_ENV,
      ignoreErrors,
      release: process.env.SENTRY_RELEASE,
      ...sentry,
    });

    Sentry.configureScope(scope => {
      scope.setUser({ id: userID ? String(userID) : 'N/A' });
      scope.setTag('browser.locale', global.navigator.language);
      scope.setExtras(context);
    });
  }
github magcius / noclip.website / src / main.ts View on Github external
const sceneDescId = this._getCurrentSceneDescId()!;

        if (typeof gtag !== 'undefined') {
            gtag("event", "loadScene", {
                'event_category': "Scenes",
                'event_label': sceneDescId,
            });
        }

        Sentry.addBreadcrumb({
            category: 'loadScene',
            message: sceneDescId,
        });

        Sentry.configureScope((scope) => {
            scope.setExtra('sceneDescId', sceneDescId);
        });
    }
github theRoughCode / WatsMyMajor / react-ui / src / reducers.js View on Github external
function user(state = defaultUser, action) {
  switch (action.type) {
  case SET_USER:
    action.user.username = action.username;
    return action.user || defaultUser;
  case LOGIN_USER:
    Sentry.configureScope((scope) => {
      if (action.payload != null) {
        scope.setUser({ userId: action.payload.username });
      }
    });
    return action.payload || defaultUser;
  case LOGOUT_USER:
  case DELETE_ACCOUNT_SUCCESS:
    return defaultUser;
  case DELETE_ACCOUNT_FAILURE:
    toast.error('Failed to delete account. Please contact an administrator.')
    return state;
  case EDIT_SETTINGS:
    return Object.assign({}, state, action.meta.user);
  case EDIT_SETTINGS_FAILURE: {
    const ERROR_WRONG_PASSWORD = 105;
    const { code } = action.payload.response;
github samuelcolvin / nosht / js / src / App.js View on Github external
setError (error) {
    if (error.status === 401) {
      this.setMessage({icon: 'sign-in-alt', message: error.msg || 'Login Required'})
      this.props.history.push(`/login/?next=${encodeURIComponent(this.props.location.pathname)}`)
      return
    } else if (error.status !== 404) {
      Sentry.configureScope(scope => scope.setExtra('extra', error))
      Sentry.captureMessage(`caught error: ${error.msg || error.toString()}`, 'warning')
    }
    this.setState({error})
  }
github SayMoreX / saymore-x / app / errorHandling.ts View on Github external
export function setUserInfoForErrorReporting(email: string, howUsing: string) {
  Sentry.configureScope(scope => {
    scope.setUser({ email });
    scope.setExtra("how_using", howUsing);
  });
}
export function sentryBreadCrumb(msg: string) {
github ShabadOS / desktop / app / frontend / src / lib / analytics.js View on Github external
updateSettings( settings ) {
    Sentry.configureScope( scope => {
      scope.setExtra( 'settings', settings )
    } )
  }
}