Skip to content

Commit 73c8cfe

Browse files
committed
fix: Not initalized integration
1 parent 9118d31 commit 73c8cfe

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/integrations/src/transactionactivity.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ export class TransactionActivity implements Integration {
7979
if (!TransactionActivity._isEnabled()) {
8080
return;
8181
}
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+
}
8789
}
8890

8991
/**
@@ -93,6 +95,10 @@ export class TransactionActivity implements Integration {
9395
if (TransactionActivity._enabled !== undefined) {
9496
return TransactionActivity._enabled;
9597
}
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+
}
96102
TransactionActivity._enabled = Math.random() > TransactionActivity.options.tracesSampleRate ? false : true;
97103
return TransactionActivity._enabled;
98104
}

0 commit comments

Comments
 (0)