Skip to content

fix: Do not trigger session on meaningless navigation #3608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2021
Merged

Conversation

kamilogorek
Copy link
Contributor

@kamilogorek kamilogorek commented May 27, 2021

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would double check with Daniel to confirm, but this LGTM

@github-actions
Copy link
Contributor

github-actions bot commented May 27, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 20.77 KB (+0.08% 🔺)
@sentry/browser - Webpack 22 KB (+0.08% 🔺)
@sentry/react - Webpack 22.03 KB (+0.09% 🔺)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.17 KB (+0.05% 🔺)

Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
@HazAT HazAT enabled auto-merge (squash) May 27, 2021 16:59
Comment on lines 69 to 73
// Otherwise:
// hub.startSession();
// hub.captureSession();
// can produce either 0 or 1, depending on the mood
this.duration = Math.floor(this.timestamp - this.started);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://develop.sentry.dev/sdk/sessions/#session-update-payload documents duration to be a float

What exactly was the problem here? If float is not being ingested correctly then we might need changes elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‘Date.now() - Date.now()’ which is what we have here will always produce int.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both are ints, what's the deal with rounding? This doesn't make sense.

If we want to always report zero then Math.floor is not part of the solution.

Copy link
Contributor Author

@kamilogorek kamilogorek May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New session is initially at 0, but captureSession is passing its own Date.now() as endTimestamp. Its possible that 2 calls followed after each other (as in code comment) will have 2 differents Date.now (by 1ms), which will produce a duration of 1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Team talked about this on a call, decided that we:

  1. Do not send duration for JS Browser sessions.
  2. Fix duration calculation to report seconds instead of milliseconds and to use the same clock as we use for errors and transactions. See timestampInSeconds.
  3. For this PR, revert the above changes to packages/hub/src/session.ts and merge the changes to packages/browser/src/sdk.ts.

We'll fix the reporting of session durations separately later.
@rhcarvalho rhcarvalho changed the title fix: Normalize session duration rounding; Dont trigger session on initial navigation fix: Do not trigger session on initial navigation May 28, 2021
@rhcarvalho rhcarvalho disabled auto-merge May 28, 2021 14:29
@rhcarvalho rhcarvalho changed the title fix: Do not trigger session on initial navigation fix: Do not trigger session on meaningless navigation May 28, 2021
@rhcarvalho rhcarvalho enabled auto-merge (squash) May 28, 2021 14:46
@rhcarvalho rhcarvalho merged commit 60f2ce9 into master May 28, 2021
@rhcarvalho rhcarvalho deleted the session-fixes branch May 28, 2021 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants