Skip to content

Enable Vercel Web Analytics and Speed Insights#4

Closed
petradonka wants to merge 1 commit into
mainfrom
petra/enable-vercel-analytics
Closed

Enable Vercel Web Analytics and Speed Insights#4
petradonka wants to merge 1 commit into
mainfrom
petra/enable-vercel-analytics

Conversation

@petradonka

Copy link
Copy Markdown
Collaborator

Summary

Pass webAnalytics: { enabled: true } and speedInsights: { enabled: true } to the Astro Vercel adapter so the trackers are actually injected.

Why

@vercel/analytics and @vercel/speed-insights are already in package.json, and the CSP in vercel.json already allowlists va.vercel-scripts.com and vitals.vercel-insights.com — but the Astro Vercel adapter only adds the tracker <script> tags when you opt in via these options. Without them, the live HTML on docs.warp.dev has no Vercel script tags, so both the Analytics and Speed Insights tabs in the Vercel project stay at 0 visitors / 0 RUM samples (currently showing -100% over the last 7 days).

Verification

npm run build succeeds locally. The rendered dist/index.html now contains the Vercel Analytics initialization stub:

window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };

After deploy, the Vercel Analytics dashboard for the docs project should start populating within a few minutes.


Conversation

Co-Authored-By: Oz oz-agent@warp.dev

The @vercel/analytics and @vercel/speed-insights packages were
already in package.json, but the Astro Vercel adapter only injects
their tracker script tags when you opt in via webAnalytics and
speedInsights options. Without those flags both Vercel dashboards
stay empty (0 visitors / 0 RUM samples).

Verified locally: 'npm run build' succeeds and the rendered HTML
now contains the Vercel Analytics initialization stub
(window.va = ...) on every page.

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Apr 30, 2026
@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 30, 2026 7:40pm

Request Review

@petradonka

Copy link
Copy Markdown
Collaborator Author

Closing — this PR isn't needed.

The <Analytics /> and <SpeedInsights /> v2 components are already wired up in src/components/CustomHead.astro (lines 3–4, 49–50) and the trackers are loading on every page (/_vercel/insights/script.js and /_vercel/speed-insights/script.js both return 200).

The reason both Vercel dashboards show 0 visitors / 0 RUM samples is that the ingestion endpoints are 404'ing:

/_vercel/insights/view              404
/_vercel/speed-insights/vitals      404

Vercel only mounts those routes after the feature is enabled in the project dashboard. Fix is to click Enable on both the Analytics and Speed Insights tabs of the docs project in Vercel and redeploy — no code change needed.

Per the official Astro adapter docs, with @vercel/analytics@1.4.0+ (we're on v2) the webAnalytics: { enabled: true } adapter flag should NOT be used; the <Analytics /> component is the supported path. So this PR's adapter changes would have been redundant at best and conflicting at worst.

@petradonka petradonka closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants