Skip to content

ref(browser): Replace vendored web-vitals with web-vitals@6 dependency - #23070

Open
logaretm wants to merge 3 commits into
developfrom
awad/webvitals-dep-only
Open

ref(browser): Replace vendored web-vitals with web-vitals@6 dependency#23070
logaretm wants to merge 3 commits into
developfrom
awad/webvitals-dep-only

Conversation

@logaretm

@logaretm logaretm commented Aug 5, 2026

Copy link
Copy Markdown
Member

Replaces the vendored web-vitals fork with web-vitals@6 as a dependency.

No behavior change. browser-utils unit tests and the browser-integration web-vitals suites (LCP/CLS/INP/FCP/TTFB + streamed spans) pass, plus we still gate the bfcache web vitals from being sent, so identical behavior as of today.

A couple of concerns we discussed:

  • Bundle-size: It increased here because this is built against develop, once we add soft navs + bfcache vitals back our vendored version becomes larger and it required a similar size limit bumps in feat(browser): Experimental soft navigation web vitals support #22880
  • Browser Compatibility: The argument I led with was that web vitals as a concept only has a single definition which is the upstream repo, it is not a loose spec, it is a concrete implementation detail that is mostly led by chromium and we already have existing compatibility bugs with existing browsers like Firefox. So given webvitals upstream promises baseline-widely available (~30 months) this should be acceptable for this feature, since web vitals emissions behavior can drift and maintaining this has been a huge overhead for us.

@logaretm logaretm changed the title awad/webvitals dep only ref(browser): Replace vendored web-vitals with web-vitals@6 dependency Aug 5, 2026
@logaretm
logaretm force-pushed the awad/webvitals-dep-only branch from d23f63e to 64997f2 Compare August 5, 2026 16:47
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.15 kB - -
@sentry/browser - with treeshaking flags 28.35 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.66 kB - -
@sentry/browser (incl. Tracing) 48.86 kB +2.74% +1.3 kB 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.88 kB +2.77% +1.31 kB 🔺
@sentry/browser (incl. Tracing, Profiling) 53.68 kB +2.61% +1.36 kB 🔺
@sentry/browser (incl. Tracing, Replay) 88.17 kB +1.43% +1.24 kB 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.57 kB +1.59% +1.21 kB 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 92.87 kB +1.33% +1.22 kB 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 105.53 kB +1.2% +1.25 kB 🔺
@sentry/browser (incl. Feedback) 47.48 kB - -
@sentry/browser (incl. sendFeedback) 34.98 kB - -
@sentry/browser (incl. FeedbackAsync) 40.13 kB - -
@sentry/browser (incl. Metrics) 31.22 kB - -
@sentry/browser (incl. Logs) 31.44 kB - -
@sentry/browser (incl. Metrics & Logs) 32.13 kB - -
@sentry/react 31.95 kB - -
@sentry/react (incl. Tracing) 51.02 kB +2.42% +1.21 kB 🔺
@sentry/vue 35.25 kB - -
@sentry/vue (incl. Tracing) 50.79 kB +2.46% +1.22 kB 🔺
@sentry/svelte 30.17 kB - -
CDN Bundle 32.16 kB -0.01% -3 B 🔽
CDN Bundle (incl. Tracing) 49.41 kB +3.31% +1.58 kB 🔺
CDN Bundle (incl. Logs, Metrics) 33.68 kB -0.05% -15 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) 50.74 kB +3.11% +1.53 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 74.22 kB +1.63% +1.19 kB 🔺
CDN Bundle (incl. Tracing, Replay) 86.96 kB +1.74% +1.49 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.23 kB +1.67% +1.44 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.79 kB +1.64% +1.5 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.09 kB +1.6% +1.48 kB 🔺
CDN Bundle - uncompressed 95.34 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 148.23 kB +3.78% +5.4 kB 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.93 kB -0.04% -30 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.21 kB +3.68% +5.4 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 228.86 kB +1.87% +4.2 kB 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.49 kB +2.06% +5.4 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.45 kB +2.03% +5.4 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.19 kB +1.96% +5.39 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.14 kB +1.93% +5.39 kB 🔺
@sentry/nextjs (client) 53.57 kB +2.26% +1.18 kB 🔺
@sentry/sveltekit (client) 49.24 kB +2.58% +1.24 kB 🔺
@sentry/core/server 65.58 kB - -
@sentry/core/browser 51.82 kB - -
@sentry/node 119.28 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 83.3 kB -0.01% -1 B 🔽
@sentry/aws-serverless 92.61 kB +0.01% +1 B 🔺
@sentry/cloudflare (withSentry) - minified 212.61 kB - -
@sentry/cloudflare (withSentry) 524.9 kB - -

View base workflow run

@logaretm
logaretm force-pushed the awad/webvitals-dep-only branch 4 times, most recently from 43daa35 to b2a21b4 Compare August 5, 2026 19:16
Upstream web-vitals v6 covers the metrics we vendored, so consume it as a
dependency instead of maintaining a ~1.9k-line in-tree copy. instrument.ts
imports the metric functions from the package and observes performance entries
with a local PerformanceObserver; the handful of generic browser helpers still
needed (getNavigationEntry, getVisibilityWatcher, whenIdleOrHidden, etc.) move
to metrics/web-vitals-helpers, and the rest of the vendored code is deleted.

No behavior change: browser-utils unit tests and the browser-integration
web-vitals suites (LCP/CLS/INP/FCP/TTFB + streamed spans) all pass.
@logaretm
logaretm force-pushed the awad/webvitals-dep-only branch from b2a21b4 to a786f2c Compare August 5, 2026 19:44
@logaretm
logaretm marked this pull request as ready for review August 5, 2026 20:03
@logaretm
logaretm requested a review from a team as a code owner August 5, 2026 20:03
@logaretm
logaretm requested review from Lms24 and msonnb and removed request for a team August 5, 2026 20:03

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

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a786f2c. Configure here.

Comment thread packages/browser-utils/src/metrics/instrument.ts
Comment thread packages/browser-utils/src/metrics/instrument.ts Outdated
The vendored `observe` helper wrapped PerformanceObserver callbacks in a
microtask to work around a Safari bug where the callback fires synchronously
during `observe()` instead of in a separate task
(GoogleChrome/web-vitals#277). The local
`instrumentPerformanceObserver` dropped that defer, so paint/longtask/event/
element handlers could run synchronously at init on affected Safari versions.
Upstream web-vitals@6 still ships this defer, so restore it here to match.
`instrumentInp` returns the `StopListening` cleanup from `onINP`, matching its
`instrumentCls`/`instrumentLcp`/`instrumentTtfb` siblings and the
`addMetricObserver` `instrumentFn` parameter, but was typed `void`. That
silently discarded the cleanup so a future `stopOnCallback` on INP would no-op.
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