@@ -432,7 +432,8 @@ function xhrCallback(handlerData: { [key: string]: any }): void {
432
432
433
433
handlerData . xhr . __sentry_xhr_activity_id__ = Tracing . pushActivity ( 'xhr' , {
434
434
data : {
435
- request_data : xhr . data ,
435
+ ...xhr . data ,
436
+ type : 'xhr' ,
436
437
} ,
437
438
description : `${ xhr . method } ${ xhr . url } ` ,
438
439
op : 'http' ,
@@ -443,58 +444,30 @@ function xhrCallback(handlerData: { [key: string]: any }): void {
443
444
/**
444
445
* Creates breadcrumbs from fetch API calls
445
446
*/
446
- // function fetchHandler(handlerData: { [key: string]: any }): void {
447
- // // We only capture complete fetch requests
448
- // if (!handlerData.requestComplete) {
449
- // return;
450
- // }
451
-
452
- // const client = getCurrentHub().getClient<BrowserClient>();
453
- // const dsn = client && client.getDsn();
454
-
455
- // if (dsn) {
456
- // const filterUrl = new API(dsn).getStoreEndpoint();
457
- // // if Sentry key appears in URL, don't capture it as a request
458
- // // but rather as our own 'sentry' type breadcrumb
459
- // if (
460
- // filterUrl &&
461
- // handlerData.fetchData.url.indexOf(filterUrl) !== -1 &&
462
- // handlerData.fetchData.method === 'POST' &&
463
- // handlerData.args[1] &&
464
- // handlerData.args[1].body
465
- // ) {
466
- // addSentryBreadcrumb(handlerData.args[1].body);
467
- // return;
468
- // }
469
- // }
470
-
471
- // if (handlerData.error) {
472
- // getCurrentHub().addBreadcrumb(
473
- // {
474
- // category: 'fetch',
475
- // data: handlerData.fetchData,
476
- // level: Severity.Error,
477
- // type: 'http',
478
- // },
479
- // {
480
- // data: handlerData.error,
481
- // input: handlerData.args,
482
- // },
483
- // );
484
- // } else {
485
- // getCurrentHub().addBreadcrumb(
486
- // {
487
- // category: 'fetch',
488
- // data: handlerData.fetchData,
489
- // type: 'http',
490
- // },
491
- // {
492
- // input: handlerData.args,
493
- // response: handlerData.response,
494
- // },
495
- // );
496
- // }
497
- // }
447
+ function fetchCallback ( handlerData : { [ key : string ] : any } ) : void {
448
+ // tslint:disable: no-unsafe-any
449
+ if ( ! Tracing . options . traceFetch ) {
450
+ return ;
451
+ }
452
+
453
+ if ( handlerData . requestComplete && handlerData . __activity ) {
454
+ Tracing . popActivity ( handlerData . __activity , handlerData . fetchData ) ;
455
+ } else {
456
+ handlerData . __activity = Tracing . pushActivity ( 'fetch' , {
457
+ data : {
458
+ ...handlerData . fetchData ,
459
+ type : 'fetch' ,
460
+ } ,
461
+ description : `${ handlerData . fetchData . method } ${ handlerData . fetchData . url } ` ,
462
+ op : 'http' ,
463
+ } ) ;
464
+ }
465
+
466
+ // if (handlerData.error) {
467
+ // } else {
468
+ // }
469
+ // tslint:enable: no-unsafe-any
470
+ }
498
471
499
472
/**
500
473
* Creates transaction from navigation changes
@@ -518,5 +491,10 @@ const xhrHandler = {
518
491
type : 'xhr' ,
519
492
} ;
520
493
494
+ const fetchHandler = {
495
+ callback : fetchCallback ,
496
+ type : 'fetch' ,
497
+ } ;
498
+
521
499
// tslint:disable-next-line: variable-name
522
- export const TracingHandlers = [ historyHandler , xhrHandler ] ;
500
+ export const TracingHandlers = [ historyHandler , xhrHandler , fetchHandler ] ;
0 commit comments