feat(browser): Experimental soft navigation web vitals support - #22880
Closed
logaretm wants to merge 8 commits into
Closed
feat(browser): Experimental soft navigation web vitals support#22880logaretm wants to merge 8 commits into
logaretm wants to merge 8 commits into
Conversation
Contributor
size-limit report 📦
|
logaretm
force-pushed
the
awad/js-1019-webvitals-softnavs
branch
from
August 4, 2026 20:17
3a26d29 to
42b6fa6
Compare
Re-port of Chrome Soft Navigation web-vitals support onto current develop. Adds an opt-in _experiments.enableSoftNavWebVitals flag on browserTracingIntegration that threads reportSoftNavs through webVitalsIntegration into the vendored web-vitals library and the tracking functions. Soft nav vitals are emitted as v2 spans grouped with the navigation span by trace ID; pageload vitals are unchanged. The vendored library carries the soft-nav port of GoogleChrome/web-vitals#308. Upstream shipped it in v6.0.0 entangled with BFCache handling this fork intentionally removed, so it was adapted onto our BFCache-free v5.1.0 base.
Best-effort correlation between Chrome Soft Navigation navigationIds and the Sentry navigation span they belong to. Navigation spans are registered as they start; when the async soft-navigation performance entry lands it is matched back to the span by start time (drift measured at ~1-2ms) and the navigationId is stamped onto the span. Soft nav web vital spans then look up their navigation span by navigationId and link via sentry.navigation.span_id. Soft nav web vital spans are tagged with a dedicated origin (auto.http.browser.soft_navigation) and a sentry.web_vital.navigation_type attribute so consumers can identify them. Correlation is inherently partial (programmatic/non-painting navs produce no entry); the vital span is always emitted, with the navigation link added only when correlation succeeds.
Three fixes for soft navigation web vitals, found by comparing against upstream web-vitals@6 running in parallel as a reference oracle: - INP: thread navigationId into the emitted span so soft-nav INP is tagged with the soft_navigation origin + sentry.web_vital.navigation_type and correlated to its navigation span, instead of emitting as an untagged ui.interaction.click. - LCP/CLS: a soft-nav value of 0 is a valid data point (the contentful paint often lands at navigation start; a nav with no layout shift has CLS 0). Previously these were dropped by the pageload-path validity/entry guards, so no LCP/CLS spans were emitted for soft navs at all. Emit them for soft navs. - getLCP: guard against undefined entries in the handler loop, which crashed with 'Cannot read properties of undefined (reading startTime)' and aborted LCP reporting (upstream web-vitals#725).
The vendored web-vitals INP collector can report the same finalized value more than once around a soft-navigation boundary (once on the interaction, then again when the next soft nav re-initializes the metric). Track the last emitted value per navigation and skip duplicate reports so a single INP span is emitted per soft navigation.
This reverts commit d80ee6c89b3e936d048654e5a9c9d2f6b69219be.
Match a soft-navigation entry to the navigation span it belongs to by the interactionId of the interaction that triggered it, rather than by start-time proximity. The triggering interaction's PerformanceEventTiming entry and the resulting soft-navigation entry share the same interactionId, so the join is deterministic instead of a timing-window heuristic.
logaretm
force-pushed
the
awad/js-1019-webvitals-softnavs
branch
from
August 4, 2026 20:58
42b6fa6 to
64eba92
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements soft navigation support which is pulled from GoogleChrome/web-vitals#308 which entered recently origin trials.
Still need to check how this affects product and how to incorporate the way it works currently with our UI and if that's needed at all.
Links:
How it works
Two ways to turn it on.
Via the tracing integration (forwards the flag when it auto-registers
webVitalsIntegration):Or directly on the web vitals integration:
Once enabled,
reportSoftNavsflows into the vendored web-vitals lib, which re-initializes each metric on a newnavigationIdso LCP/CLS/INP/TTFB/FCP are also captured for soft navigations. Those soft-nav vitals are emitted as v2 spans that group with the navigation span by trace id.closes #17857