Merge branch 'sentry-sanity' into 'develop'

Sentry: filter out useless events, tag ErrorBoundary page crashes

See merge request soapbox-pub/soapbox-fe!1751
environments/review-develop-3zknud/deployments/847
Alex Gleason 2 years ago
commit c29bf4040a

@ -56,7 +56,12 @@ class ErrorBoundary extends React.PureComponent<Props, State> {
textarea: HTMLTextAreaElement | null = null; textarea: HTMLTextAreaElement | null = null;
componentDidCatch(error: any, info: any): void { componentDidCatch(error: any, info: any): void {
captureException(error); captureException(error, {
tags: {
// Allow page crashes to be easily searched in Sentry.
ErrorBoundary: 'yes',
},
});
this.setState({ this.setState({
hasError: true, hasError: true,

@ -1,5 +1,7 @@
import * as BuildConfig from 'soapbox/build_config'; import * as BuildConfig from 'soapbox/build_config';
import type { CaptureContext } from '@sentry/types';
export const start = (): void => { export const start = (): void => {
Promise.all([ Promise.all([
import(/* webpackChunkName: "error" */'@sentry/react'), import(/* webpackChunkName: "error" */'@sentry/react'),
@ -11,6 +13,23 @@ export const start = (): void => {
debug: false, debug: false,
integrations: [new Integrations.BrowserTracing()], integrations: [new Integrations.BrowserTracing()],
// Filter events.
// https://docs.sentry.io/platforms/javascript/configuration/filtering/
ignoreErrors: [
// Network errors.
'AxiosError',
// sw.js couldn't be downloaded.
'Failed to update a ServiceWorker for scope',
// Useful for try/catch, useless as a Sentry error.
'AbortError',
],
denyUrls: [
// Browser extensions.
/extensions\//i,
/^chrome:\/\//i,
/^moz-extension:\/\//i,
],
// We recommend adjusting this value in production, or using tracesSampler // We recommend adjusting this value in production, or using tracesSampler
// for finer control // for finer control
tracesSampleRate: 1.0, tracesSampleRate: 1.0,
@ -18,10 +37,10 @@ export const start = (): void => {
}).catch(console.error); }).catch(console.error);
}; };
export const captureException = (error: Error): void => { export const captureException = (exception: any, captureContext?: CaptureContext | undefined): void => {
import(/* webpackChunkName: "error" */'@sentry/react') import(/* webpackChunkName: "error" */'@sentry/react')
.then(Sentry => { .then(Sentry => {
Sentry.captureException(error); Sentry.captureException(exception, captureContext);
}) })
.catch(console.error); .catch(console.error);
}; };

Loading…
Cancel
Save