@@ -84,7 +84,8 @@ export class GlobalHandlers implements Integration {
8484 this . _oldOnErrorHandler = this . _global . onerror ;
8585
8686 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 ) ;
8889 const isFailedOwnDelivery = error && error . __sentry_own_request__ === true ;
8990
9091 if ( ! hasIntegration || shouldIgnoreOnError ( ) || isFailedOwnDelivery ) {
@@ -94,16 +95,25 @@ export class GlobalHandlers implements Integration {
9495 return false ;
9596 }
9697
98+ const client = currentHub . getClient ( ) ;
9799 const event = isPrimitive ( error )
98100 ? 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+ ) ;
100110
101111 addExceptionMechanism ( event , {
102112 handled : false ,
103113 type : 'onerror' ,
104114 } ) ;
105115
106- getCurrentHub ( ) . captureEvent ( event , {
116+ currentHub . captureEvent ( event , {
107117 originalException : error ,
108118 } ) ;
109119
@@ -134,7 +144,8 @@ export class GlobalHandlers implements Integration {
134144 // no-empty
135145 }
136146
137- const hasIntegration = getCurrentHub ( ) . getIntegration ( GlobalHandlers ) ;
147+ const currentHub = getCurrentHub ( ) ;
148+ const hasIntegration = currentHub . getIntegration ( GlobalHandlers ) ;
138149 const isFailedOwnDelivery = error && error . __sentry_own_request__ === true ;
139150
140151 if ( ! hasIntegration || shouldIgnoreOnError ( ) || isFailedOwnDelivery ) {
@@ -144,9 +155,13 @@ export class GlobalHandlers implements Integration {
144155 return false ;
145156 }
146157
158+ const client = currentHub . getClient ( ) ;
147159 const event = isPrimitive ( error )
148160 ? self . _eventFromIncompleteRejection ( error )
149- : eventFromUnknownInput ( error , undefined , true ) ;
161+ : eventFromUnknownInput ( error , undefined , {
162+ attachStacktrace : client && client . getOptions ( ) . attachStacktrace ,
163+ rejection : true ,
164+ } ) ;
150165
151166 event . level = Severity . Error ;
152167
@@ -155,7 +170,7 @@ export class GlobalHandlers implements Integration {
155170 type : 'onunhandledrejection' ,
156171 } ) ;
157172
158- getCurrentHub ( ) . captureEvent ( event , {
173+ currentHub . captureEvent ( event , {
159174 originalException : error ,
160175 } ) ;
161176
0 commit comments