10000 Programatic way to indicate that a pageload / navigation transaction has completed · Issue #14810 · getsentry/sentry-javascript · GitHub
[go: up one dir, main page]

Skip to content

Programatic way to indicate that a pageload / navigation transaction has completed #14810

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

Open
bcoe opened this issue Dec 19, 2024 · 4 comments
Labels
Feature Package: browser Issues related to the Sentry Browser SDK Spans

Comments

@bcoe
Copy link
Member
bcoe commented Dec 19, 2024

Problem Statement

When setting duration on pageload / navigation transactions today, we use a heuristic approach to determine the timing

From internal conversation:

IIRC they end via a combination of idleTimeout, finalTimeout, and heartbeatInterval (docs), or a new transaction starting.

Being a heuristic, there are many opinions about what constitutes the completion of a pageload or navigation event. Rather than addressing all these alternate opinions, it would be interesting to give developers a programatic way to indicate that the pageload, or navigation, is complete.

Solution Brainstorm

I could imagine something like this:

Sentry.reportPageLoaded()

Similar to Time to Full Display is handled.

@Lms24
Copy link
Member
Lms24 commented Dec 20, 2024

I think it's worth exploring this direction. Essentially, such a function would be syntactic sugar around this code:

const rootSpan = getRootSpan(getActiveSpan())
if (rootSpan && spanToJSON(rootSpan).op === "pageload") {
  rootSpan.end();
}

which is not a lot but of course less unintuitive than calling reportPageLoaded(). However, it would also result in a bundle size increase for CDN bundle (or loader) users if we decided to add it to our CDN bundles in addition to NPM packages.

Importantly though: If we added this API, we'd also need to ensure that the pageload span is active until this function is called. Or IOW, we should deactivate all idle span heuristics to end the span. Which is another bundle size increase and makes this a bit more complex.

Update: Users can also today set the parameters for our idle spans in a way that they're factually disabled by making sure, that our idle parameters would end the span definitely after their manual call to end the span:

Sentry.init({
  integrations: [
    Sentry.browserTracingIntegration({
      idleTimeout: 60_000,
      finalTimeout: 60_000,
      childSpanTimeout: 60_000,
    })
  ]
})

(feel free to adjust as necessary)

@cobyeastwood183
Copy link

@yashverma2110
Copy link

Any updates on this?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 15, 2025
Copy link
Member
mydea commented May 16, 2025

We are scheduling this work in a bit more concretely now, hopefully we have updates to share in the near-ish future. We still need to figure the exact semantics of this out, though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Package: browser Issues related to the Sentry Browser SDK Spans
Projects
Status: No status
Development

No branches or pull requests

7 participants
0