demarches-normaliennes/app/javascript/shared/track/sentry.js
Pierre de La Morinerie 63cde95fc9 js: ignore errors generated by a Microsoft crawler
Sentry has a lot of Javacript errors stating:

> UnhandledRejection: Non-Error promise rejection captured with value: Object Not Found Matching Id:2 

This is apparently caused by a Microsoft crawler (maybe for scanning
targets of email links), and can be safely ignored.

See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062/12
2021-07-20 09:21:59 +02:00

27 lines
875 B
JavaScript

import * as Sentry from '@sentry/browser';
const { key, enabled, user, environment, browser } = gon.sentry || {};
// We need to check for key presence here as we do not have a dsn for browser yet
if (enabled && key) {
Sentry.init({
dsn: key,
environment,
ignoreErrors: [
// Ignore errors generated by a Microsoft crawler.
// See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062
'Non-error promise rejection captured with keys'
]
});
Sentry.configureScope((scope) => {
scope.setUser(user);
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');
});
// Register a way to explicitely capture messages from a different bundle.
addEventListener('sentry:capture-exception', (event) => {
const error = event.detail;
Sentry.captureException(error);
});
}