Sentry: filter out useless events, tag ErrorBoundary page crashes

environments/review-sentry-san-rhroiu/deployments/838
Alex Gleason 2022-08-25 13:49:08 -05:00
rodzic 5ad4303c3e
commit f8f8b4f2b9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 28 dodań i 3 usunięć

Wyświetl plik

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

Wyświetl plik

@ -1,5 +1,7 @@
import * as BuildConfig from 'soapbox/build_config';
import type { CaptureContext } from '@sentry/types';
export const start = (): void => {
Promise.all([
import(/* webpackChunkName: "error" */'@sentry/react'),
@ -11,6 +13,24 @@ export const start = (): void => {
debug: false,
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',
// The user decided not to share (eg `navigator.share()`).
// This exception is useful for a try/catch flow, but not for error monitoring.
'AbortError: Share canceled',
],
denyUrls: [
// Browser extensions.
/extensions\//i,
/^chrome:\/\//i,
/^moz-extension:\/\//i,
],
// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
@ -18,10 +38,10 @@ export const start = (): void => {
}).catch(console.error);
};
export const captureException = (error: Error): void => {
export const captureException = (exception: any, captureContext?: CaptureContext | undefined): void => {
import(/* webpackChunkName: "error" */'@sentry/react')
.then(Sentry => {
Sentry.captureException(error);
Sentry.captureException(exception, captureContext);
})
.catch(console.error);
};