Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
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);
});
}
}
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'
})
})
}
}
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);
}
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);
});
}
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);
});
}
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;
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})
}
export function setUserInfoForErrorReporting(email: string, howUsing: string) {
Sentry.configureScope(scope => {
scope.setUser({ email });
scope.setExtra("how_using", howUsing);
});
}
export function sentryBreadCrumb(msg: string) {
updateSettings( settings ) {
Sentry.configureScope( scope => {
scope.setExtra( 'settings', settings )
} )
}
}