Skip to content

Commit bcf30ca

Browse files
authored
fix(vue): Move ROOT_SPAN_TIMER into Vue context. (#4081)
1 parent 83b5cc6 commit bcf30ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/vue/src/tracing.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface VueSentry extends ViewModel {
1313
[key: string]: Span;
1414
};
1515
$_sentryRootSpan?: Span;
16+
$_sentryRootSpanTimer?: ReturnType<typeof setTimeout>;
1617
}
1718

1819
// Mappings from operation to corresponding lifecycle hook.
@@ -23,7 +24,6 @@ const HOOKS: { [key in Operation]: Hook[] } = {
2324
mount: ['beforeMount', 'mounted'],
2425
update: ['beforeUpdate', 'updated'],
2526
};
26-
let ROOT_SPAN_TIMER: ReturnType<typeof setTimeout>;
2727

2828
/** Grabs active transaction off scope, if any */
2929
function getActiveTransaction(): Transaction | undefined {
@@ -34,11 +34,11 @@ function getActiveTransaction(): Transaction | undefined {
3434

3535
/** Finish top-level span and activity with a debounce configured using `timeout` option */
3636
function finishRootSpan(vm: VueSentry, timestamp: number, timeout: number): void {
37-
if (ROOT_SPAN_TIMER) {
38-
clearTimeout(ROOT_SPAN_TIMER);
37+
if (vm.$_sentryRootSpanTimer) {
38+
clearTimeout(vm.$_sentryRootSpanTimer);
3939
}
4040

41-
ROOT_SPAN_TIMER = setTimeout(() => {
41+
vm.$_sentryRootSpanTimer = setTimeout(() => {
4242
if (vm.$root?.$_sentryRootSpan) {
4343
vm.$root.$_sentryRootSpan.finish(timestamp);
4444
vm.$root.$_sentryRootSpan = undefined;

0 commit comments

Comments
 (0)