2022-11-15 12:48:54 -08:00
|
|
|
import * as BuildConfig from 'soapbox/build-config';
|
2021-09-08 13:45:44 -07:00
|
|
|
|
2022-08-25 11:49:08 -07:00
|
|
|
import type { CaptureContext } from '@sentry/types';
|
|
|
|
|
2022-04-15 17:54:40 -07:00
|
|
|
export const start = (): void => {
|
2021-09-12 10:33:39 -07:00
|
|
|
Promise.all([
|
|
|
|
import(/* webpackChunkName: "error" */'@sentry/react'),
|
|
|
|
import(/* webpackChunkName: "error" */'@sentry/tracing'),
|
|
|
|
]).then(([Sentry, { Integrations: Integrations }]) => {
|
|
|
|
Sentry.init({
|
2022-04-15 17:54:40 -07:00
|
|
|
dsn: BuildConfig.SENTRY_DSN,
|
|
|
|
environment: BuildConfig.NODE_ENV,
|
2021-09-12 10:33:39 -07:00
|
|
|
debug: false,
|
|
|
|
integrations: [new Integrations.BrowserTracing()],
|
2021-09-08 13:45:44 -07:00
|
|
|
|
2022-08-25 11:49:08 -07:00
|
|
|
// 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',
|
2022-08-25 12:17:23 -07:00
|
|
|
// Useful for try/catch, useless as a Sentry error.
|
|
|
|
'AbortError',
|
2022-08-25 11:49:08 -07:00
|
|
|
],
|
|
|
|
denyUrls: [
|
|
|
|
// Browser extensions.
|
|
|
|
/extensions\//i,
|
|
|
|
/^chrome:\/\//i,
|
|
|
|
/^moz-extension:\/\//i,
|
|
|
|
],
|
|
|
|
|
2021-09-12 10:33:39 -07:00
|
|
|
// We recommend adjusting this value in production, or using tracesSampler
|
|
|
|
// for finer control
|
|
|
|
tracesSampleRate: 1.0,
|
|
|
|
});
|
|
|
|
}).catch(console.error);
|
|
|
|
};
|
|
|
|
|
2022-08-25 11:49:08 -07:00
|
|
|
export const captureException = (exception: any, captureContext?: CaptureContext | undefined): void => {
|
2021-09-12 10:33:39 -07:00
|
|
|
import(/* webpackChunkName: "error" */'@sentry/react')
|
|
|
|
.then(Sentry => {
|
2022-08-25 11:49:08 -07:00
|
|
|
Sentry.captureException(exception, captureContext);
|
2021-09-12 10:33:39 -07:00
|
|
|
})
|
|
|
|
.catch(console.error);
|
|
|
|
};
|