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
63import config from './config/environment' ;
74
85export 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- }
0 commit comments