Skip to content

feat(browser): Report web vitals for bfcache restores - #23750

Open
logaretm wants to merge 1 commit into
awad/bfcache-navigation-spanfrom
awad/bfcache-web-vitals
Open

feat(browser): Report web vitals for bfcache restores#23750
logaretm wants to merge 1 commit into
awad/bfcache-navigation-spanfrom
awad/bfcache-web-vitals

Conversation

@logaretm

@logaretm logaretm commented Aug 28, 2026

Copy link
Copy Markdown
Member

Reports web vitals for back/forward cache restores, which we dropped outright before.

Now that a restore gets its own navigation span in #23748, the vitals have a correct parent, so the hardcoded withoutBfcache drop becomes webVitals: { bfcache: true }. Off by default, since a restore is a different population from a page load.

Stacked on #23748.

@logaretm logaretm changed the title awad/bfcache web vitals feat(browser): Report web vitals for bfcache restores Aug 28, 2026
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from c306449 to b172bce Compare August 31, 2026 16:03
@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.81 kB - -
@sentry/browser - with treeshaking flags 27.12 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.01 kB - -
@sentry/browser (incl. Tracing) 50.31 kB +2.11% +1.03 kB 🔺
@sentry/browser (incl. Tracing + Span Streaming) 50.32 kB +2.13% +1.05 kB 🔺
@sentry/browser (incl. Tracing, Profiling) 53.31 kB +2.12% +1.1 kB 🔺
@sentry/browser (incl. Tracing, Replay) 89.84 kB +1.16% +1.03 kB 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 78.94 kB +1.22% +949 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 94.53 kB +1.11% +1.03 kB 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 107.51 kB +1.01% +1.07 kB 🔺
@sentry/browser (incl. Feedback) 46.3 kB - -
@sentry/browser (incl. sendFeedback) 33.87 kB - -
@sentry/browser (incl. FeedbackAsync) 38.99 kB - -
@sentry/browser (incl. Metrics) 29.84 kB - -
@sentry/browser (incl. Logs) 30.1 kB - -
@sentry/browser (incl. Metrics & Logs) 30.78 kB - -
@sentry/react 30.57 kB - -
@sentry/react (incl. Tracing) 52.61 kB +1.9% +977 B 🔺
@sentry/vue 36.07 kB - -
@sentry/vue (incl. Tracing) 52.54 kB +1.92% +987 B 🔺
@sentry/svelte 28.85 kB - -
CDN Bundle 30.56 kB - -
CDN Bundle (incl. Tracing) 50.79 kB +1.97% +979 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.83 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 52.76 kB +1.91% +988 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73.51 kB +0.06% +38 B 🔺
CDN Bundle (incl. Tracing, Replay) 88.32 kB +1.12% +972 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 90.29 kB +1.15% +1.02 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 94.36 kB +1.17% +1.09 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 96.39 kB +1.18% +1.12 kB 🔺
CDN Bundle - uncompressed 90.47 kB - -
CDN Bundle (incl. Tracing) - uncompressed 151.72 kB +2.27% +3.35 kB 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.04 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 157.68 kB +2.18% +3.35 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.4 kB +0.05% +107 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 271.29 kB +1.25% +3.34 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 277.24 kB +1.22% +3.34 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 284.99 kB +1.19% +3.34 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 290.93 kB +1.17% +3.34 kB 🔺
@sentry/nextjs (client) 54.96 kB +1.62% +875 B 🔺
@sentry/sveltekit (client) 50.73 kB +2.03% +1.01 kB 🔺
@sentry/core/server 36.99 kB - -
@sentry/core/browser 13.55 kB - -
@sentry/node 127.95 kB +0.02% +24 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.61 kB - -
@sentry/node - without tracing 88.73 kB +0.03% +21 B 🔺
@sentry/node - without channel injection 107.17 kB +0.02% +20 B 🔺
@sentry/aws-serverless 97.12 kB +0.03% +27 B 🔺
@sentry/cloudflare (withSentry) - minified 202.05 kB - -
@sentry/cloudflare (withSentry) 502.91 kB - -

View base workflow run

@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from b172bce to 89498ab Compare September 8, 2026 14:56
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from 89498ab to 00a507c Compare September 8, 2026 14:57
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from 00a507c to 9e62164 Compare September 9, 2026 13:56
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from 9e62164 to 2bfb452 Compare September 9, 2026 16:06
@logaretm
logaretm marked this pull request as ready for review September 9, 2026 16:08
@logaretm
logaretm requested a review from a team as a code owner September 9, 2026 16:08
@logaretm
logaretm requested review from Lms24 and msonnb and removed request for a team September 9, 2026 16:08

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread packages/browser-utils/src/web-vitals/spans.ts
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from 2bfb452 to aabc750 Compare September 9, 2026 16:25
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from aabc750 to 1689dad Compare September 9, 2026 16:28

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread packages/browser-utils/src/web-vitals/spans.ts
Comment thread packages/browser-utils/src/web-vitals/spans.ts
Comment thread packages/browser/src/integrations/webVitals.ts
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from 1689dad to 7e70c6c Compare September 9, 2026 16:40
Comment thread packages/browser-utils/src/web-vitals/spans.ts Outdated
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from 7e70c6c to af8c52d Compare September 9, 2026 17:09
Comment thread packages/browser-utils/src/web-vitals/spans.ts Outdated
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from af8c52d to 9cff25a Compare September 9, 2026 17:32
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from 9cff25a to 35ba3f5 Compare September 9, 2026 17:37

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread packages/browser-utils/src/web-vitals/spans.ts
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from 35ba3f5 to b201558 Compare September 9, 2026 17:52
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from b201558 to dffc394 Compare September 9, 2026 19:22
… dropped

`withoutBfcache` dropped every metric web-vitals reported after a
back/forward-cache restore. That was the right call while there was
nothing to attach them to: a restore reuses the frozen document, so the
values would have landed on the span the page had before it was frozen.

Now that a restore gets its own navigation span, they have a correct
parent, so the drop becomes an option rather than a hard rule:

    webVitals: { bfcache: true }

Off by default. A restore is near-instant, so its vitals are a different
population from page load vitals, and the earlier concern about skewing
aggregates still applies to anyone who has not decided how to treat them.
`browser.navigation.type: bfcache` makes them separable once enabled.

Reporting per navigation rather than per page load is now what the
tracker flag means, since bfcache restores need it for the same reason
soft navigations do. `reportAllChanges` is switched off for either, since
the per-navigation path relies on each reported value already being final
for its navigation.

Verified end to end in Chrome 152: a restore emits LCP and CLS parented
to the bfcache navigation span on the restore's own trace, and a
bfcache-ineligible back navigation still falls back to a page load.
Comment thread packages/browser/src/integrations/webVitals.ts
@logaretm
logaretm force-pushed the awad/bfcache-web-vitals branch from dffc394 to bd52ab7 Compare September 9, 2026 19:26

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit dffc394. Configure here.


if (reportBfcache) {
enableBfcacheReporting();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bfcache opt-in runs too late

Medium Severity

enableBfcacheReporting is only called from webVitalsIntegration setup, but that integration is auto-registered in browserTracingIntegration afterAllSetup. Replay can instrument observers first and pin reportAllChanges on, so incremental LCP and CLS updates each emit a span on the per-navigation path.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit dffc394. Configure here.

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.

1 participant