Skip to content

Commit 5e0d890

Browse files
authored
Sentry: Replace @sentry/browser with @sentry/ember (#8778)
`@sentry/ember` seems mature enough to use these days and will make the transition to the v8 Sentry SDK easier.
1 parent e9ece4c commit 5e0d890

File tree

5 files changed

+29
-65
lines changed

5 files changed

+29
-65
lines changed

app/sentry.js

+1-57
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
import { runInDebug } from '@ember/debug';
2-
3-
import * as Sentry from '@sentry/browser';
4-
import { getGlobalObject, isInstanceOf, logger } from '@sentry/utils';
1+
import * as Sentry from '@sentry/ember';
52

63
import config from './config/environment';
74

85
export function init() {
9-
let integrations = [];
10-
if (config.environment === 'production') {
11-
integrations.push(new Ember());
12-
}
13-
146
let isProd = location.hostname === 'crates.io';
157
let isStaging = location.hostname === 'staging.crates.io';
168
let environment = isProd ? 'production' : isStaging ? 'staging' : 'unknown';
179

1810
Sentry.init({
1911
environment,
2012
...config.sentry,
21-
integrations,
2213

2314
allowUrls: ['crates.io', 'crates-io.herokuapp.com', 'staging.crates.io', 'staging-crates-io.herokuapp.com'],
2415

@@ -35,50 +26,3 @@ export function init() {
3526
},
3627
});
3728
}
38-
39-
export class Ember {
40-
static id = 'Ember';
41-
42-
name = Ember.id;
43-
_Ember;
44-
45-
constructor(options = {}) {
46-
this._Ember = options.Ember || getGlobalObject().Ember;
47-
}
48-
49-
setupOnce(_, getCurrentHub) {
50-
if (!this._Ember) {
51-
runInDebug(() => logger.error('EmberIntegration is missing an Ember instance'));
52-
return;
53-
}
54-
55-
const oldOnError = this._Ember.onerror;
56-
57-
// eslint-disable-next-line unicorn/prefer-add-event-listener
58-
this._Ember.onerror = error => {
59-
if (getCurrentHub().getIntegration(Ember)) {
60-
getCurrentHub().captureException(error, { originalException: error });
61-
}
62-
63-
if (typeof oldOnError === 'function') {
64-
oldOnError.call(this._Ember, error);
65-
} else if (this._Ember.testing) {
66-
throw error;
67-
}
68-
};
69-
70-
this._Ember.RSVP.on('error', reason => {
71-
if (getCurrentHub().getIntegration(Ember)) {
72-
getCurrentHub().withScope(scope => {
73-
if (isInstanceOf(reason, Error)) {
74-
scope.setExtra('context', 'Unhandled Promise error detected');
75-
getCurrentHub().captureException(reason, { originalException: reason });
76-
} else {
77-
scope.setExtra('reason', reason);
78-
getCurrentHub().captureMessage('Unhandled Promise error detected');
79-
}
80-
});
81-
}
82-
});
83-
}
84-
}

app/services/sentry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Service from '@ember/service';
22

3-
import * as Sentry from '@sentry/browser';
3+
import * as Sentry from '@sentry/ember';
44

55
export default class SentryService extends Service {
66
captureException(error, captureContext) {

config/environment.js

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ module.exports = function (environment) {
3434
// We don't want to use Mirage if a proxy backend has been provided.
3535
enabled: !process.env.PROXY_BACKEND,
3636
},
37+
38+
'@sentry/ember': {
39+
disablePerformance: true,
40+
},
3741
};
3842

3943
if (environment === 'development') {

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
},
4242
"dependencies": {
4343
"@juggle/resize-observer": "3.4.0",
44-
"@sentry/browser": "7.116.0",
45-
"@sentry/utils": "7.116.0",
44+
"@sentry/ember": "7.116.0",
4645
"chart.js": "4.4.3",
4746
"date-fns": "3.6.0",
4847
"highlight.js": "11.9.0",

pnpm-lock.yaml

+22-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)