Skip to content

Add Web Analytics self-exclusion via localStorage va-disable - #10

Merged
wustep merged 1 commit into
mainfrom
cursor/analytics-opt-out-9c61
Aug 17, 2026
Merged

Add Web Analytics self-exclusion via localStorage va-disable#10
wustep merged 1 commit into
mainfrom
cursor/analytics-opt-out-9c61

Conversation

@wustep

@wustep wustep commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

Wires the official Vercel Web Analytics opt-out onto the existing <Analytics /> mount in src/main.tsx. beforeSend returns null when localStorage.va-disable is set, otherwise the event is sent unchanged. localStorage is read inside a try/catch so missing or blocked storage cannot crash the client.

No second Analytics component, no package change, no UI.

After merge, opt a browser out on stagebench.vercel.app by running this once in the production console (per browser):

localStorage.setItem('va-disable', 'true')

To resume tracking: localStorage.removeItem('va-disable').

Visuals

The gallery is visually identical. Stills of production/main vs this branch:

Before (production / main)

Production gallery on stagebench.vercel.app

After (this branch, local Vite)

Branch gallery with beforeSend opt-out

Test plan

  • pnpm typecheck and pnpm lint clean for this change
  • pnpm test 44/44 on Node 24
  • Production vs branch stills compared — UI unchanged
  • After merge: set localStorage.va-disable on production and confirm the browser no longer appears in Web Analytics

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Drop Web Analytics events when localStorage.va-disable is set, matching
the official beforeSend opt-out pattern. Guard localStorage so missing
or blocked storage cannot crash the client.

Co-authored-by: Stephen Wu <wustep@users.noreply.github.com>
@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
stagebench Ready Ready Preview Aug 17, 2026 4:55am

Request Review

@wustep
wustep marked this pull request as ready for review August 17, 2026 04:56
@wustep
wustep merged commit e2d2e07 into main Aug 17, 2026
3 checks passed
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.

2 participants