1
1
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
2
- import { Event , EventProcessor , Hub , Integration , Primitive , Severity , EventHint } from '@sentry/types' ;
2
+ import { Event , EventHint , EventProcessor , Hub , Integration , Primitive , Severity } from '@sentry/types' ;
3
3
import {
4
4
addExceptionMechanism ,
5
5
addInstrumentationHandler ,
@@ -13,11 +13,11 @@ import {
13
13
import { eventFromUnknownInput } from '../eventbuilder' ;
14
14
import { shouldIgnoreOnError } from '../helpers' ;
15
15
16
+ const ONUNHANDLEDREJECTION = 'onunhandledrejection' ;
17
+ const ONERROR = 'onerror' ;
18
+
16
19
/** JSDoc */
17
- interface GlobalHandlersIntegrations {
18
- onerror : boolean ;
19
- onunhandledrejection : boolean ;
20
- }
20
+ type GlobalHandlersIntegrations = Record < typeof ONUNHANDLEDREJECTION | typeof ONERROR , boolean > ;
21
21
22
22
/** Global handlers */
23
23
export class GlobalHandlers implements Integration {
@@ -62,15 +62,15 @@ export class GlobalHandlers implements Integration {
62
62
const attachStacktrace = client && client . getOptions ( ) . attachStacktrace ;
63
63
64
64
if ( this . _options . onerror && ! this . _onErrorHandlerInstalled ) {
65
- globalHandlerLog ( 'onerror' ) ;
66
65
_installGlobalOnErrorHandler ( hub , attachStacktrace ) ;
67
66
this . _onErrorHandlerInstalled = true ;
67
+ globalHandlerLog ( ONERROR ) ;
68
68
}
69
69
70
70
if ( this . _options . onunhandledrejection && ! this . _onUnhandledRejectionHandlerInstalled ) {
71
- globalHandlerLog ( 'onunhandledrejection' ) ;
72
71
_installGlobalOnUnhandledRejectionHandler ( hub , attachStacktrace ) ;
73
72
this . _onUnhandledRejectionHandlerInstalled = true ;
73
+ globalHandlerLog ( ONUNHANDLEDREJECTION ) ;
74
74
}
75
75
}
76
76
}
@@ -100,7 +100,7 @@ function _installGlobalOnErrorHandler(hub: Hub, attachStacktrace: boolean | unde
100
100
data . column ,
101
101
) ;
102
102
103
- addMechanismAndCapture ( hub , error , event , 'onerror' ) ;
103
+ addMechanismAndCapture ( hub , error , event , ONERROR ) ;
104
104
} ,
105
105
type : 'error' ,
106
106
} ) ;
@@ -146,7 +146,7 @@ function _installGlobalOnUnhandledRejectionHandler(hub: Hub, attachStacktrace: b
146
146
147
147
event . level = Severity . Error ;
148
148
149
- addMechanismAndCapture ( hub , error , event , 'onunhandledrejection' ) ;
149
+ addMechanismAndCapture ( hub , error , event , ONUNHANDLEDREJECTION ) ;
150
150
return ;
151
151
} ,
152
152
type : 'unhandledrejection' ,
0 commit comments