Skip to content

Commit 46e1842

Browse files
chore: Only enable sentry for non dummy DSN (#4393)
1 parent 6d1e4ee commit 46e1842

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

app/sentry.ts

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,58 @@ import * as Sentry from '@sentry/browser';
22
import { CaptureConsole, Dedupe, Ember } from '@sentry/integrations';
33
import config from 'open-event-frontend/config/environment';
44

5-
Sentry.init({
6-
integrations: [
7-
new Ember(),
8-
new Dedupe(),
9-
new CaptureConsole({
10-
levels: ['error']
11-
})
12-
],
13-
beforeSend(event: Sentry.Event) {
14-
const exception = event.exception?.values?.[0];
15-
const errorValue = exception?.value;
16-
if (errorValue?.includes("Ember Data Request")) {
17-
if (errorValue?.includes("404")) {
18-
// Ignore 404 errors from Ember Data because
19-
// I don't know how to turn them off
5+
if (!config.sentry.dsn.includes('dummy')) {
6+
7+
Sentry.init({
8+
integrations: [
9+
new Ember(),
10+
new Dedupe(),
11+
new CaptureConsole({
12+
levels: ['error']
13+
})
14+
],
15+
beforeSend(event: Sentry.Event) {
16+
const exception = event.exception?.values?.[0];
17+
const errorValue = exception?.value;
18+
if (errorValue?.includes("Ember Data Request")) {
19+
if (errorValue?.includes("404")) {
20+
// Ignore 404 errors from Ember Data because
21+
// I don't know how to turn them off
22+
return null;
23+
}
24+
}
25+
26+
if (errorValue?.includes("TransitionAborted") &&
27+
exception?.mechanism?.handled) {
28+
// Every page load has a handled TransitionAborted for some reason
2029
return null;
2130
}
22-
}
2331

24-
if (errorValue?.includes("TransitionAborted") &&
25-
exception?.mechanism?.handled) {
26-
// Every page load has a handled TransitionAborted for some reason
27-
return null;
28-
}
32+
return event;
33+
},
34+
...config.sentry
35+
});
2936

30-
return event;
31-
},
32-
...config.sentry
33-
});
34-
35-
Sentry.configureScope(function(scope) {
36-
function addAdapterError(error: any, event: Sentry.Event) {
37-
if (error.isAdapterError) {
38-
event.extra = {
39-
...event.extra,
40-
adapter_errors: error.errors,
41-
adapter_errors_json: JSON.stringify(error.errors)
37+
Sentry.configureScope(function(scope) {
38+
function addAdapterError(error: any, event: Sentry.Event) {
39+
if (error.isAdapterError) {
40+
event.extra = {
41+
...event.extra,
42+
adapter_errors: error.errors,
43+
adapter_errors_json: JSON.stringify(error.errors)
44+
}
4245
}
4346
}
44-
}
4547

46-
scope.addEventProcessor(function(event: Sentry.Event, hints: Sentry.EventHint) {
47-
addAdapterError(hints.originalException, event);
48+
scope.addEventProcessor(function(event: Sentry.Event, hints: Sentry.EventHint) {
49+
addAdapterError(hints.originalException, event);
4850

49-
const args: any[] = event.extra?.arguments || [];
50-
for (const arg of args) {
51-
addAdapterError(arg, event);
52-
}
53-
return event;
51+
const args: any[] = event.extra?.arguments || [];
52+
for (const arg of args) {
53+
addAdapterError(arg, event);
54+
}
55+
return event;
56+
});
5457
});
55-
});
58+
59+
}

0 commit comments

Comments
 (0)