Skip to content

fix(vercel-analytics): skip script in dev to avoid failed insights POSTs#713

Open
harlan-zw wants to merge 1 commit intomainfrom
fix/vercel-analytics-dev-skip
Open

fix(vercel-analytics): skip script in dev to avoid failed insights POSTs#713
harlan-zw wants to merge 1 commit intomainfrom
fix/vercel-analytics-dev-skip

Conversation

@harlan-zw
Copy link
Copy Markdown
Collaborator

🔗 Linked issue

N/A

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

Vercel Analytics collects via a relative /_vercel/insights/* endpoint served by Vercel's edge. Outside Vercel (including nuxt dev) there is no upstream, so the bundled script POSTs to the local origin and 404s. Default the trigger to manual in dev so the script only loads when explicitly triggered, and drop the unused mode/debug options that leaked the old debug-script path. Docs call out the dev behaviour and the first-party table marks Vercel Analytics as bundle-only.

Vercel Analytics collects via a relative `/_vercel/insights/*` endpoint
served by Vercel's edge. Outside a Vercel deployment (including `nuxt
dev`) there's no upstream, so the script POSTs to the local origin and
404s. Default to manual trigger in dev so the script only loads if
explicitly triggered, and drop the unused `mode`/`debug` options that
leaked the old debug-script path.
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 15, 2026

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

Project Deployment Actions Updated (UTC)
scripts-playground Ready Ready Preview, Comment Apr 15, 2026 4:09pm

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts@713

commit: c447f12

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

This pull request refactors the Vercel Analytics integration by removing mode-based runtime switching and the window.vam global variable. The analytics script now bundles code and sends data through Vercel's edge infrastructure via relative /_vercel/insights/* paths, available only on Vercel-hosted deployments. Analytics collection is skipped in development environments. The changes include removing the VercelAnalyticsMode type, mode and debug configuration options, debug script variants, and vitals.vercel-insights.com from proxy domains. Runtime trigger behavior changes from always loading on client hydration to manual triggering in development.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: skipping the Vercel Analytics script in dev to prevent failed insight POST requests.
Description check ✅ Passed The description clearly explains the problem (failed POSTs outside Vercel deployments), the solution (manual trigger in dev, removing mode/debug options), and documentation updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/vercel-analytics-dev-skip

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/content/docs/1.guides/2.first-party.md`:
- Line 353: The Vercel Analytics entry is classified inconsistently: update the
privacy-tier table so the Vercel Analytics row/entry (labelled "Vercel
Analytics" or path "/scripts/vercel-analytics") appears only under the
bundle-only/no-proxy category and remove or relocate it from the proxied IP-only
scripts list so both the table and the prose consistently state it is served via
Vercel edge and only works on Vercel (skipped in nuxt dev); ensure the single
canonical description is used in both places (the table row and any list that
previously included it).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 326e5356-ea54-4ab7-9491-f2a4a516d1d9

📥 Commits

Reviewing files that changed from the base of the PR and between f4a4df6 and c447f12.

📒 Files selected for processing (10)
  • docs/content/docs/1.guides/2.first-party.md
  • docs/content/scripts/vercel-analytics.md
  • packages/script/src/registry-types.json
  • packages/script/src/registry.ts
  • packages/script/src/runtime/registry/schemas.ts
  • packages/script/src/runtime/registry/vercel-analytics.ts
  • playground/pages/third-parties/vercel-analytics/nuxt-scripts.vue
  • scripts/generate-sizes.ts
  • test/e2e-dev/first-party.test.ts
  • test/e2e/basic.test.ts
💤 Files with no reviewable changes (3)
  • test/e2e/basic.test.ts
  • playground/pages/third-parties/vercel-analytics/nuxt-scripts.vue
  • packages/script/src/runtime/registry/schemas.ts

| [Crisp](/scripts/crisp) | SDK loads secondary scripts and CSS at runtime from `client.crisp.chat`. |
| [Mixpanel](/scripts/mixpanel-analytics) | No proxy integration yet. |
| [Bing UET](/scripts/bing-uet) | No proxy integration yet. |
| [Vercel Analytics](/scripts/vercel-analytics) | Collects via relative `/_vercel/insights/*` served by Vercel's edge. Only works on Vercel-hosted deployments; skipped in `nuxt dev`. |
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Resolve contradictory Vercel Analytics classification in this guide.

Line 353 says Vercel Analytics is bundle-only/no-proxy, but Line 66 still lists it under proxied IP-only scripts. Please align the privacy-tier table to avoid conflicting guidance.

📝 Proposed docs fix
-| **IP only** | IP addresses anonymised to subnet level | Plausible, PostHog, Umami, Fathom, CF Web Analytics, Vercel Analytics, Rybbit, Databuddy, Matomo, Intercom, YouTube, Vimeo, Gravatar, Carbon Ads, Lemon Squeezy, Google AdSense |
+| **IP only** | IP addresses anonymised to subnet level | Plausible, PostHog, Umami, Fathom, CF Web Analytics, Rybbit, Databuddy, Matomo, Intercom, YouTube, Vimeo, Gravatar, Carbon Ads, Lemon Squeezy, Google AdSense |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/content/docs/1.guides/2.first-party.md` at line 353, The Vercel
Analytics entry is classified inconsistently: update the privacy-tier table so
the Vercel Analytics row/entry (labelled "Vercel Analytics" or path
"/scripts/vercel-analytics") appears only under the bundle-only/no-proxy
category and remove or relocate it from the proxied IP-only scripts list so both
the table and the prose consistently state it is served via Vercel edge and only
works on Vercel (skipped in nuxt dev); ensure the single canonical description
is used in both places (the table row and any list that previously included it).

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