-
Notifications
You must be signed in to change notification settings - Fork 125
/
sentry.js
41 lines (35 loc) · 1.2 KB
/
sentry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Initializes error reporting to Sentry when running at a higher enviroment than localhost
*/
import * as Sentry from '@sentry/browser';
import environment from '../utilities/environment';
// url check is necessary for e2e tests and local environments
const trackErrors = environment.BASE_URL.indexOf('localhost') < 0;
if (trackErrors) {
const url = `${environment.BASE_URL}/js-report/0`.replace('//', '//faker@');
Sentry.init({
dsn: url,
ignoreErrors: [
// Error generated by a bug in auto-fill library from safari
// https://github.com/getsentry/sentry/issues/5267
/Blocked a frame with origin/,
],
});
Sentry.setTag('source', 'unknown');
Sentry.configureScope(scope => {
scope.setLevel('error');
});
// this is for errors that happen in promises
// it does not work locally with the webpack devtool setting we
// use but does with the one we use in prod/staging
window.addEventListener('unhandledrejection', evt => {
Sentry.withScope(scope => {
scope.setExtra('evt', evt);
if (evt && evt.reason) {
Sentry.captureException(evt.reason);
} else {
Sentry.captureMessage('Unhandled promise rejection');
}
});
});
}