@@ -84,7 +84,8 @@ export class GlobalHandlers implements Integration {
84
84
this . _oldOnErrorHandler = this . _global . onerror ;
85
85
86
86
this . _global . onerror = function ( msg : any , url : any , line : any , column : any , error : any ) : boolean {
87
- const hasIntegration = getCurrentHub ( ) . getIntegration ( GlobalHandlers ) ;
87
+ const currentHub = getCurrentHub ( ) ;
88
+ const hasIntegration = currentHub . getIntegration ( GlobalHandlers ) ;
88
89
const isFailedOwnDelivery = error && error . __sentry_own_request__ === true ;
89
90
90
91
if ( ! hasIntegration || shouldIgnoreOnError ( ) || isFailedOwnDelivery ) {
@@ -94,16 +95,25 @@ export class GlobalHandlers implements Integration {
94
95
return false ;
95
96
}
96
97
98
+ const client = currentHub . getClient ( ) ;
97
99
const event = isPrimitive ( error )
98
100
? self . _eventFromIncompleteOnError ( msg , url , line , column )
99
- : self . _enhanceEventWithInitialFrame ( eventFromUnknownInput ( error , undefined ) , url , line , column ) ;
101
+ : self . _enhanceEventWithInitialFrame (
102
+ eventFromUnknownInput ( error , undefined , {
103
+ attachStacktrace : client && client . getOptions ( ) . attachStacktrace ,
104
+ rejection : false ,
105
+ } ) ,
106
+ url ,
107
+ line ,
108
+ column ,
109
+ ) ;
100
110
101
111
addExceptionMechanism ( event , {
102
112
handled : false ,
103
113
type : 'onerror' ,
104
114
} ) ;
105
115
106
- getCurrentHub ( ) . captureEvent ( event , {
116
+ currentHub . captureEvent ( event , {
107
117
originalException : error ,
108
118
} ) ;
109
119
@@ -134,7 +144,8 @@ export class GlobalHandlers implements Integration {
134
144
// no-empty
135
145
}
136
146
137
- const hasIntegration = getCurrentHub ( ) . getIntegration ( GlobalHandlers ) ;
147
+ const currentHub = getCurrentHub ( ) ;
148
+ const hasIntegration = currentHub . getIntegration ( GlobalHandlers ) ;
138
149
const isFailedOwnDelivery = error && error . __sentry_own_request__ === true ;
139
150
140
151
if ( ! hasIntegration || shouldIgnoreOnError ( ) || isFailedOwnDelivery ) {
@@ -144,9 +155,13 @@ export class GlobalHandlers implements Integration {
144
155
return false ;
145
156
}
146
157
158
+ const client = currentHub . getClient ( ) ;
147
159
const event = isPrimitive ( error )
148
160
? self . _eventFromIncompleteRejection ( error )
149
- : eventFromUnknownInput ( error , undefined , true ) ;
161
+ : eventFromUnknownInput ( error , undefined , {
162
+ attachStacktrace : client && client . getOptions ( ) . attachStacktrace ,
163
+ rejection : true ,
164
+ } ) ;
150
165
151
166
event . level = Severity . Error ;
152
167
@@ -155,7 +170,7 @@ export class GlobalHandlers implements Integration {
155
170
type : 'onunhandledrejection' ,
156
171
} ) ;
157
172
158
- getCurrentHub ( ) . captureEvent ( event , {
173
+ currentHub . captureEvent ( event , {
159
174
originalException : error ,
160
175
} ) ;
161
176
0 commit comments