File tree 1 file changed +11
-5
lines changed
packages/integrations/src
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -79,11 +79,13 @@ export class TransactionActivity implements Integration {
79
79
if ( ! TransactionActivity . _isEnabled ( ) ) {
80
80
return ;
81
81
}
82
- // `${window.location.href}` will be used a temp transaction name
83
- TransactionActivity . startIdleTransaction ( `${ window . location . href } ` , {
84
- op : 'pageload' ,
85
- sampled : true ,
86
- } ) ;
82
+ if ( global . location && global . location . href ) {
83
+ // `${global.location.href}` will be used a temp transaction name
84
+ TransactionActivity . startIdleTransaction ( global . location . href , {
85
+ op : 'pageload' ,
86
+ sampled : true ,
87
+ } ) ;
88
+ }
87
89
}
88
90
89
91
/**
@@ -93,6 +95,10 @@ export class TransactionActivity implements Integration {
93
95
if ( TransactionActivity . _enabled !== undefined ) {
94
96
return TransactionActivity . _enabled ;
95
97
}
98
+ // This happens only in test cases where the integration isn't initalized properly
99
+ if ( ! TransactionActivity . options || isNaN ( TransactionActivity . options . tracesSampleRate ) ) {
100
+ return false ;
101
+ }
96
102
TransactionActivity . _enabled = Math . random ( ) > TransactionActivity . options . tracesSampleRate ? false : true ;
97
103
return TransactionActivity . _enabled ;
98
104
}
You can’t perform that action at this time.
0 commit comments