2019-03-26 16:02:08 +01:00
|
|
|
import * as Sentry from '@sentry/browser';
|
|
|
|
|
2019-04-04 14:21:18 +02:00
|
|
|
const { key, enabled, user, environment, browser } = gon.sentry || {};
|
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) {
|
2019-04-03 12:13:34 +02:00
|
|
|
Sentry.init({ dsn: key, environment });
|
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) => {
|
2019-10-24 15:54:08 +02:00
|
|
|
const error = event.detail;
|
|
|
|
Sentry.captureException(error);
|
|
|
|
});
|
2019-03-26 16:02:08 +01:00
|
|
|
}
|