Distinguish redirects from user-initiated nagivations #15286
Labels
Feature: Tracing
Feature: web-vitals
Improvement
Package: browser
Issues related to the Sentry Browser SDK
Problem Statement
Our Browser SDKs by default create
op: pageload
andop: navigation
idle spans to record spans and browser metrics during (hard) page loads and (soft) navigations (most commonly via client-side SPA routers). In most of ourbrowserTracingIntegration
s, including the default one, we cancel (i.e. end) an ongoing idle span if there is still an active span. While this makes sense if you assume the new navigation is intentionally triggered (e.g. by a user clicking a link/button), it falls apart for automatic redirections. Such redirects are fairly common shortly after the pageload. A popular example is users opening a page on/
which causes the router to checks if they're authenticated. If yes, they're redirected to a/dashboard
page and otherwise t oa/login
page.For redirects (or more generally for "non-user-triggered navigations"), this cancellation behavior has a variety of problems:
Goal
We want to find a way to distinguish such automatic redirects from user-triggered navigations.
Options Considered
1. Distinguishing based on Heuristics
"User-triggered" navigation implies a click. We can listen globally to a click event and treat every navigation before the first click as a redirect/application-triggered navigation.
Pros:
Cons:
startBrowserTracingNavigationSpan
(?)1.1 Reset heuristic on every user-initiated navigation
Same as above but reset the click listener and upper bound after each user-initiated navigation
Additional Pros:
2. Leverage the framework/router
Some routers provide our instrumentation with enough information to distinguish between application- vs. user-initiated navigations (e.g. Ember, Angular, more?)
Pros:
Cons:
3. Provide users a manual pageload end reporting API.
Proposed in #14810.
Pro:
Cons:
4. Do nothing / null option
Pros:
Cons:
The text was updated successfully, but these errors were encountered: