Skip to content

Commit b62ea41

Browse files
committed
fix: Use scope instead of configureScope
1 parent 73c8cfe commit b62ea41

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/integrations/src/transactionactivity.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class TransactionActivity implements Integration {
9696
return TransactionActivity._enabled;
9797
}
9898
// This happens only in test cases where the integration isn't initalized properly
99-
if (!TransactionActivity.options || isNaN(TransactionActivity.options.tracesSampleRate)) {
99+
// tslint:disable-next-line: strict-type-predicates
100+
if (!TransactionActivity.options || typeof TransactionActivity.options.tracesSampleRate !== 'number') {
100101
return false;
101102
}
102103
TransactionActivity._enabled = Math.random() > TransactionActivity.options.tracesSampleRate ? false : true;
@@ -111,6 +112,7 @@ export class TransactionActivity implements Integration {
111112
// Tracing is not enabled
112113
return undefined;
113114
}
115+
114116
const activeTransaction = TransactionActivity._activeTransaction;
115117

116118
if (activeTransaction) {
@@ -140,9 +142,11 @@ export class TransactionActivity implements Integration {
140142

141143
TransactionActivity._activeTransaction = span;
142144

143-
hub.configureScope((scope: Scope) => {
144-
scope.setSpan(span);
145-
});
145+
// We need to do this workaround here and not use configureScope
146+
// Reason being at the time we start the inital transaction we do not have a client bound on the hub yet
147+
// therefore configureScope wouldn't be executed and we would miss setting the transaction
148+
// tslint:disable-next-line: no-unsafe-any
149+
(hub as any).getScope().setSpan(span);
146150

147151
// The reason we do this here is because of cached responses
148152
// If we start and transaction without an activity it would never finish since there is no activity
@@ -185,6 +189,10 @@ export class TransactionActivity implements Integration {
185189
// Tracing is not enabled
186190
return 0;
187191
}
192+
193+
// We want to clear the timeout also here since we push a new activity
194+
clearTimeout(TransactionActivity._debounce);
195+
188196
const _getCurrentHub = TransactionActivity._getCurrentHub;
189197
if (spanContext && _getCurrentHub) {
190198
const hub = _getCurrentHub();
@@ -211,6 +219,7 @@ export class TransactionActivity implements Integration {
211219
// Tracing is not enabled
212220
return;
213221
}
222+
214223
const activity = TransactionActivity._activities[id];
215224
if (activity) {
216225
if (activity.span) {

0 commit comments

Comments
 (0)