From 60f2ce9940f91ebdc2124d7b94148be1d7526b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Fri, 28 May 2021 16:54:57 +0200 Subject: [PATCH] fix: Do not trigger session on meaningless navigation (#3608) Avoid double-reporting on initial navigation, and omit sessions for navigation API events that do not change the URL. --- packages/browser/src/sdk.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts index 82bcdc161d66..444e06ecbe90 100644 --- a/packages/browser/src/sdk.ts +++ b/packages/browser/src/sdk.ts @@ -204,7 +204,11 @@ function startSessionTracking(): void { // We want to create a session for every navigation as well addInstrumentationHandler({ - callback: () => { + callback: ({ from, to }) => { + // Don't create an additional session for the initial route or if the location did not change + if (from === undefined || from === to) { + return; + } hub.startSession(); hub.captureSession(); },