From 1b36c79d3ea2b0efbc09af636a8909f627dee276 Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Mon, 25 Oct 2021 00:59:30 +0000 Subject: [PATCH] fix(vue): Move `ROOT_SPAN_TIMER` into Vue context. --- packages/vue/src/tracing.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vue/src/tracing.ts b/packages/vue/src/tracing.ts index 1363bc9398f9..87511ebac7bb 100644 --- a/packages/vue/src/tracing.ts +++ b/packages/vue/src/tracing.ts @@ -13,6 +13,7 @@ interface VueSentry extends ViewModel { [key: string]: Span; }; $_sentryRootSpan?: Span; + $_sentryRootSpanTimer?: ReturnType; } // Mappings from operation to corresponding lifecycle hook. @@ -23,7 +24,6 @@ const HOOKS: { [key in Operation]: Hook[] } = { mount: ['beforeMount', 'mounted'], update: ['beforeUpdate', 'updated'], }; -let ROOT_SPAN_TIMER: ReturnType; /** Grabs active transaction off scope, if any */ function getActiveTransaction(): Transaction | undefined { @@ -34,11 +34,11 @@ function getActiveTransaction(): Transaction | undefined { /** Finish top-level span and activity with a debounce configured using `timeout` option */ function finishRootSpan(vm: VueSentry, timestamp: number, timeout: number): void { - if (ROOT_SPAN_TIMER) { - clearTimeout(ROOT_SPAN_TIMER); + if (vm.$_sentryRootSpanTimer) { + clearTimeout(vm.$_sentryRootSpanTimer); } - ROOT_SPAN_TIMER = setTimeout(() => { + vm.$_sentryRootSpanTimer = setTimeout(() => { if (vm.$root?.$_sentryRootSpan) { vm.$root.$_sentryRootSpan.finish(timestamp); vm.$root.$_sentryRootSpan = undefined;