Skip to content

Commit

Permalink
fix: Do not trigger session on meaningless navigation (#3608)
Browse files Browse the repository at this point in the history
Avoid double-reporting on initial navigation, and omit sessions for navigation API events that do not change the URL.
  • Loading branch information
kamilogorek authored May 28, 2021
1 parent 82a868f commit 60f2ce9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/browser/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down

0 comments on commit 60f2ce9

Please sign in to comment.