Skip to content

Commit 2b38c8e

Browse files
committed
fix(v8): Fixes latest route name and source not updating correctly #10702
Forward port of #10702
1 parent 5a60afd commit 2b38c8e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

packages/browser-utils/src/browser/browserTracingIntegration.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
169169
startTrackingInteractions();
170170
}
171171

172-
let latestRouteName: string | undefined;
173-
let latestRouteSource: TransactionSource | undefined;
172+
const latestRoute: { name: string | undefined; source: TransactionSource | undefined } = {
173+
name: undefined,
174+
source: undefined,
175+
};
174176

175177
/** Create routing idle transaction. */
176178
function _createRouteSpan(client: Client, startSpanOptions: StartSpanOptions): Span {
@@ -190,8 +192,8 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
190192
finalStartSpanOptions.attributes = attributes;
191193
}
192194

193-
latestRouteName = finalStartSpanOptions.name;
194-
latestRouteSource = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
195+
latestRoute.name = finalStartSpanOptions.name;
196+
latestRoute.source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
195197

196198
const idleSpan = startIdleSpan(finalStartSpanOptions, {
197199
idleTimeout,
@@ -333,7 +335,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
333335
}
334336

335337
if (_experiments.enableInteractions) {
336-
registerInteractionListener(options, latestRouteName, latestRouteSource);
338+
registerInteractionListener(options, latestRoute);
337339
}
338340

339341
instrumentOutgoingRequests({
@@ -404,8 +406,7 @@ export function getMetaContent(metaName: string): string | undefined {
404406
/** Start listener for interaction transactions */
405407
function registerInteractionListener(
406408
options: BrowserTracingOptions,
407-
latestRouteName: string | undefined,
408-
latestRouteSource: TransactionSource | undefined,
409+
latestRoute: { name: string | undefined; source: TransactionSource | undefined },
409410
): void {
410411
let inflightInteractionSpan: Span | undefined;
411412
const registerInteractionTransaction = (): void => {
@@ -429,17 +430,17 @@ function registerInteractionListener(
429430
inflightInteractionSpan = undefined;
430431
}
431432

432-
if (!latestRouteName) {
433+
if (!latestRoute.name) {
433434
DEBUG_BUILD && logger.warn(`[Tracing] Did not create ${op} transaction because _latestRouteName is missing.`);
434435
return undefined;
435436
}
436437

437438
inflightInteractionSpan = startIdleSpan(
438439
{
439-
name: latestRouteName,
440+
name: latestRoute.name,
440441
op,
441442
attributes: {
442-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRouteSource || 'url',
443+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.source || 'url',
443444
},
444445
},
445446
{

0 commit comments

Comments
 (0)