@@ -24,33 +24,30 @@ export function instrumentRoutingWithDefaults<T extends Transaction>(
24
24
}
25
25
26
26
if ( startTransactionOnLocationChange ) {
27
- addInstrumentationHandler ( {
28
- callback : ( { to, from } : { to : string ; from ?: string } ) => {
29
- /**
30
- * This early return is there to account for some cases where a navigation transaction starts right after
31
- * long-running pageload. We make sure that if `from` is undefined and a valid `startingURL` exists, we don't
32
- * create an uneccessary navigation transaction.
33
- *
34
- * This was hard to duplicate, but this behavior stopped as soon as this fix was applied. This issue might also
35
- * only be caused in certain development environments where the usage of a hot module reloader is causing
36
- * errors.
37
- */
38
- if ( from === undefined && startingUrl && startingUrl . indexOf ( to ) !== - 1 ) {
39
- startingUrl = undefined ;
40
- return ;
41
- }
27
+ addInstrumentationHandler ( 'history' , ( { to, from } : { to : string ; from ?: string } ) => {
28
+ /**
29
+ * This early return is there to account for some cases where a navigation transaction starts right after
30
+ * long-running pageload. We make sure that if `from` is undefined and a valid `startingURL` exists, we don't
31
+ * create an uneccessary navigation transaction.
32
+ *
33
+ * This was hard to duplicate, but this behavior stopped as soon as this fix was applied. This issue might also
34
+ * only be caused in certain development environments where the usage of a hot module reloader is causing
35
+ * errors.
36
+ */
37
+ if ( from === undefined && startingUrl && startingUrl . indexOf ( to ) !== - 1 ) {
38
+ startingUrl = undefined ;
39
+ return ;
40
+ }
42
41
43
- if ( from !== to ) {
44
- startingUrl = undefined ;
45
- if ( activeTransaction ) {
46
- logger . log ( `[Tracing] Finishing current transaction with op: ${ activeTransaction . op } ` ) ;
47
- // If there's an open transaction on the scope, we need to finish it before creating an new one.
48
- activeTransaction . finish ( ) ;
49
- }
50
- activeTransaction = customStartTransaction ( { name : global . location . pathname , op : 'navigation' } ) ;
42
+ if ( from !== to ) {
43
+ startingUrl = undefined ;
44
+ if ( activeTransaction ) {
45
+ logger . log ( `[Tracing] Finishing current transaction with op: ${ activeTransaction . op } ` ) ;
46
+ // If there's an open transaction on the scope, we need to finish it before creating an new one.
47
+ activeTransaction . finish ( ) ;
51
48
}
52
- } ,
53
- type : 'history' ,
49
+ activeTransaction = customStartTransaction ( { name : global . location . pathname , op : 'navigation' } ) ;
50
+ }
54
51
} ) ;
55
52
}
56
53
}
0 commit comments