Skip to content
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

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

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

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 more 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.

@AbhiPrasad AbhiPrasad added Feature: Spans Package: browser Issues related to the Sentry Browser SDK labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Spans Package: browser Issues related to the Sentry Browser SDK
Projects
None yet
Development

No branches or pull requests

3 participants