2019-03-26 16:02:08 +01:00
|
|
|
import * as Sentry from '@sentry/browser';
|
2022-07-07 11:39:03 +02:00
|
|
|
import { getConfig } from '@utils';
|
2019-03-26 16:02:08 +01:00
|
|
|
|
2022-07-07 11:39:03 +02:00
|
|
|
const {
|
|
|
|
sentry: { key, enabled, user, environment, browser }
|
|
|
|
} = getConfig();
|
2019-03-26 16:02:08 +01:00
|
|
|
|
|
|
|
// We need to check for key presence here as we do not have a dsn for browser yet
|
|
|
|
if (enabled && key) {
|
2021-07-13 14:57:42 +02:00
|
|
|
Sentry.init({
|
|
|
|
dsn: key,
|
|
|
|
environment,
|
2023-02-06 11:14:38 +01:00
|
|
|
tracesSampleRate: 0.1,
|
2021-07-13 14:57:42 +02:00
|
|
|
ignoreErrors: [
|
|
|
|
// Ignore errors generated by a Microsoft crawler.
|
|
|
|
// See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062
|
2021-09-07 15:54:10 +02:00
|
|
|
'Non-error promise rejection captured with keys',
|
2023-01-10 16:04:43 +01:00
|
|
|
'Non-Error promise rejection captured with value',
|
|
|
|
|
|
|
|
// Error with password input with a password manager, pending a DSFR fix
|
|
|
|
'e.getModifierState is not a function'
|
2021-07-13 14:57:42 +02:00
|
|
|
]
|
|
|
|
});
|
2019-03-26 16:02:08 +01:00
|
|
|
|
2020-04-30 15:42:29 +02:00
|
|
|
Sentry.configureScope((scope) => {
|
2019-04-04 11:47:55 +02:00
|
|
|
scope.setUser(user);
|
2019-04-04 14:21:18 +02:00
|
|
|
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');
|
2019-04-04 11:47:55 +02:00
|
|
|
});
|
2019-10-24 15:54:08 +02:00
|
|
|
|
|
|
|
// Register a way to explicitely capture messages from a different bundle.
|
2020-04-30 15:42:29 +02:00
|
|
|
addEventListener('sentry:capture-exception', (event) => {
|
2022-07-07 11:39:03 +02:00
|
|
|
const error = (event as CustomEvent).detail;
|
2019-10-24 15:54:08 +02:00
|
|
|
Sentry.captureException(error);
|
|
|
|
});
|
2019-03-26 16:02:08 +01:00
|
|
|
}
|