@@ -7,13 +7,6 @@ import { eventFromUnknownInput } from '../eventbuilder';
7
7
export type HttpStatusCodeRange = [ number , number ] | number ;
8
8
export type HttpRequestTarget = string | RegExp ;
9
9
interface HttpClientOptions {
10
- /**
11
- * Controls whether failed requests should be captured.
12
- *
13
- * Default: false
14
- */
15
- captureFailedRequests ?: boolean ;
16
-
17
10
/**
18
11
* HTTP status codes that should be considered failed.
19
12
* This array can contain tuples of `[begin, end]` (both inclusive),
@@ -55,7 +48,6 @@ export class HttpClient implements Integration {
55
48
*/
56
49
public constructor ( options ?: Partial < HttpClientOptions > ) {
57
50
this . _options = {
58
- captureFailedRequests : false ,
59
51
failedRequestStatusCodes : [ [ 500 , 599 ] ] ,
60
52
failedRequestTargets : [ / .* / ] ,
61
53
...options ,
@@ -68,10 +60,6 @@ export class HttpClient implements Integration {
68
60
* @param options
69
61
*/
70
62
public setupOnce ( ) : void {
71
- if ( ! this . _options . captureFailedRequests ) {
72
- return ;
73
- }
74
-
75
63
this . _wrapFetch ( ) ;
76
64
this . _wrapXHR ( ) ;
77
65
}
@@ -170,7 +158,6 @@ export class HttpClient implements Integration {
170
158
responseCookies,
171
159
} ) ;
172
160
173
- // Note: Not adding request / response objects as hints for XHR
174
161
captureEvent ( event ) ;
175
162
}
176
163
}
@@ -284,7 +271,7 @@ export class HttpClient implements Integration {
284
271
}
285
272
286
273
/**
287
- *
274
+ * Wraps `fetch` function to capture request and response data
288
275
*/
289
276
private _wrapFetch ( ) : void {
290
277
if ( ! supportsNativeFetch ( ) ) {
@@ -314,7 +301,7 @@ export class HttpClient implements Integration {
314
301
}
315
302
316
303
/**
317
- * Wraps XMLHttpRequest to capture request and response data
304
+ * Wraps XMLHttpRequest to capture request and response data
318
305
*/
319
306
private _wrapXHR ( ) : void {
320
307
if ( ! ( 'XMLHttpRequest' in GLOBAL_OBJ ) ) {
@@ -358,7 +345,9 @@ export class HttpClient implements Integration {
358
345
__DEBUG_BUILD__ && logger . warn ( 'Error while extracting response event form XHR response' , e ) ;
359
346
}
360
347
361
- return original ?. apply ( xhr , onloadendArgs ) ;
348
+ if ( original ) {
349
+ return original . apply ( xhr , onloadendArgs ) ;
350
+ }
362
351
} ;
363
352
} ) ;
364
353
@@ -373,7 +362,13 @@ export class HttpClient implements Integration {
373
362
* @param url url to verify
374
363
*/
375
364
private _isSentryRequest ( url : string ) : boolean {
376
- const dsn = getCurrentHub ( ) . getClient ( ) ?. getDsn ( ) ;
365
+ const client = getCurrentHub ( ) . getClient ( ) ;
366
+
367
+ if ( ! client ) {
368
+ return false ;
369
+ }
370
+
371
+ const dsn = client . getDsn ( ) ;
377
372
return dsn ? url . includes ( dsn . host ) : false ;
378
373
}
379
374
0 commit comments