AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Experimental.WebVitalsAttribution Has No Effect On UseReportWebVitals

The experimental.webVitalsAttribution config option is accepted but the attribution data is never attached to metrics reported by useReportWebVitals because the code that consumed __NEXT_WEB_VITALS_ATTRIBUTION was removed. The hook currently imports only the non-attribution web-vitals build.

highConfidence 85%Next.jsAffected V14.2.xAffected V15.0.0Affected V16.3.0-Canary.89

Origin Analysis

The `experimental.webVitalsAttribution` option is injected as `__NEXT_WEB_VITALS_ATTRIBUTION` but nothing reads it after the performance relayer was removed in #64199. `useReportWebVitals` still imports the standard `next/dist/compiled/web-vitals` functions, which do not provide attribution; it never imports or uses the attribution build.
1. Clone https://github.com/dayongkr/webvitals-attribution-repro, then run `npm install && npm run dev` 2. Open http://localhost:3000 with the browser console open 3. Click anywhere on the page (flushes LCP/INP), then switch tabs once (flushes CLS) 4. Compare the `[useReportWebVitals]` logs with the `[web-vitals/attribution]` logs

Fixing Code Block

Edge Case Audit

Enabling the attribution build increases bundle size; static import of both modules may cause attribution module to be included for all users if tree-shaking fails. Additionally, this implementation enables attribution for all metrics when any are configured, not just the whitelisted ones. Rollback by reverting to `import * as webVitals from 'next/dist/compiled/web-vitals'` and removing the attribution import. Verify `process.env.__NEXT_WEB_VITALS_ATTRIBUTION` remains a valid JSON array; malformed JSON is caught but would silently disable attribution.

Ecosystem Topology