chore: upgrade Vercel Analytics to v2 + App Router route tracking
Merged
SW
5mo ago+72+72+01234567890123456789-96-96-01234567890123456789
What
Brings chat's Vercel Web Analytics up to the current recommended setup. Three changes:
- Switch
@vercel/analytics/reactโ@vercel/analytics/next. chat is a Next.js App Router app, but it imported the generic/reactAnalytics component, which doesn't hook into Next's router. Result: only the initial page load was tracked, client-side route changes (SPA navigations) were not registered as page views. The/nextvariant adds App Router route detection. - Bump
@vercel/analytics1.6.1 โ 2.0.1. v2 adds Resilient Intake (more robust delivery against ad-blockers / network loss), is now MIT-licensed, and replaces the deprecatedendpointoption witheventEndpoint/viewEndpoint. The<Analytics />API is unchanged for our usage. - Drop the
DeferredAnalyticswrapper.components/DeferredAnalytics.tsxwrapped<Analytics />innext/dynamicwithssr:false. That's redundant โ<Analytics />is already a client component that lazy-loads its script. The root layout now renders<Analytics />from/nextdirectly, per the Vercel quickstart.
Why
The route-tracking fix (#1) is the substantive one: it means analytics now reflect real navigation within the app, not just first loads. #2 and #3 are housekeeping to match the current docs and remove dead indirection.
Verification
tsc --noEmit: no new type errors introduced (the 7 pre-existing errors inlib/emails/__tests__/extractSendEmailResults.test.tsare present onmainand unrelated).pnpm build: client/layout compiles successfully. The local build can't fully complete because API routes require env vars at module load (ARWEAVE_KEY, Supabase creds) that aren't set locally โ unrelated to this change. The Vercel preview build (full env) is the green gate.
๐ค Generated with Claude Code
Summary by cubic
Upgrade Vercel Web Analytics to v2 and switch to @vercel/analytics/next so App Router navigations are tracked as page views, not just the initial load. Remove the custom deferred wrapper and render <Analytics /> directly in the root layout.
-
Refactors
- Delete
components/DeferredAnalytics.tsx;<Analytics />already lazy-loads client-side.
- Delete
-
Dependencies
- Bump
@vercel/analyticsto^2.0.1(adds Resilient Intake, MIT license).
- Bump