@@ -226,15 +226,15 @@ function instrumentXHR(): void {
226226 // eslint-disable-next-line @typescript-eslint/no-this-alias
227227 const xhr = this ;
228228 const url = args [ 1 ] ;
229- xhr . __sentry_xhr__ = {
229+ const xhrInfo : SentryWrappedXMLHttpRequest [ '__sentry_xhr__' ] = ( xhr . __sentry_xhr__ = {
230230 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
231231 method : isString ( args [ 0 ] ) ? args [ 0 ] . toUpperCase ( ) : args [ 0 ] ,
232232 url : args [ 1 ] ,
233- } ;
233+ } ) ;
234234
235235 // if Sentry key appears in URL, don't capture it as a request
236236 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
237- if ( isString ( url ) && xhr . __sentry_xhr__ . method === 'POST' && url . match ( / s e n t r y _ k e y / ) ) {
237+ if ( isString ( url ) && xhrInfo . method === 'POST' && url . match ( / s e n t r y _ k e y / ) ) {
238238 xhr . __sentry_own_request__ = true ;
239239 }
240240
@@ -243,9 +243,7 @@ function instrumentXHR(): void {
243243 try {
244244 // touching statusCode in some platforms throws
245245 // an exception
246- if ( xhr . __sentry_xhr__ ) {
247- xhr . __sentry_xhr__ . status_code = xhr . status ;
248- }
246+ xhrInfo . status_code = xhr . status ;
249247 } catch ( e ) {
250248 /* do nothing */
251249 }
@@ -256,8 +254,8 @@ function instrumentXHR(): void {
256254 // Make sure to pop both key and value to keep it in sync.
257255 requestKeys . splice ( requestPos ) ;
258256 const args = requestValues . splice ( requestPos ) [ 0 ] ;
259- if ( xhr . __sentry_xhr__ && args [ 0 ] !== undefined ) {
260- xhr . __sentry_xhr__ . body = args [ 0 ] as XHRSendInput ;
257+ if ( args [ 0 ] !== undefined ) {
258+ xhrInfo . body = args [ 0 ] as XHRSendInput ;
261259 }
262260 }
263261 } catch ( e ) {
0 commit comments