feat: send the analytics events through the first party proxy behind a kill switch - #3497
feat: send the analytics events through the first party proxy behind a kill switch#3497braianj wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…a kill switch Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KDE5NS3oeKPcJWXbTTqSBx
b00ba3a to
ab0c226
Compare
Coverage Report for CI Build 33621041934Coverage increased (+0.1%) to 53.843%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
|
✅ Approved by Claude, approved by Codex — route Segment analytics through the first-party proxy with a feature-flag kill switch Checked: all 13 changed files reviewed in full context — proxy logic with localStorage guards and safe defaults, saga persistence on success only, env config consistency across dev/stg/prod, selector and type registration, test coverage for kill switch on/off/absent/invalid/storage-error and saga success/failure paths, CI (test, audit, Vercel deploy all green), security (no secrets, no injection vectors, no auth changes). Cross-model review by Jarvis 🤖 · head ab0c226 · Claude + Codex · Requested by Braian Mellor (<@U03ACDWNHR8>) via Slack |
Builder already loads
analytics.jsand its Segment settings from our first party proxy, but the events it produced still went toapi.segment.io, which ad blockers drop just likecdn.segment.com. For a blocked user nothing was actually recovered: the bundle loaded and every event was then thrown away.decentraland-dapps@29.8.0addsapiHostto the analytics snippet options (the ingestion host, no protocol, shapedhost/basePath; it validates and normalizes the value and falls back to Segment's own ingestion when it is invalid). This passesSEGMENT_API_HOSTalongside the existingSEGMENT_ANALYTICS_URL, so the events reach Segment through the same first party host. The value isapi.e.decentraland.org/v1in the three environments, the same one decentraland.org has been running in production since Aug 19 without a regression (the client IP still reaches Segment, socontext_ipis unaffected).The whole proxy sits behind a kill switch shared with the other dapps: the
dapps-seg-altfeature flag. On means send the analytics straight to Segment, ignoring both the proxy bundle URL and the proxy api host. Off or unknown means use the configured proxy, so merging this while the flag is off changes nothing about today's behaviour. Because the analytics middleware is created while the store is built and the flags only arrive later, the last known value is persisted inlocalStorageunderdcl-analytics-seg-alt('1'on,'0'off) every time the flags are fetched, and the next boot decides with it. Nothing is persisted on a fetch failure and every storage access is guarded, so a flag service outage or an unavailable storage can never disable the tracking.How to test:
analytics.jsis fetched fromevs.e.decentraland.organd that the events are posted toapi.e.decentraland.org/v1/t, not toapi.segment.io. Confirm the events land in Segment.dapps-seg-altfor thedappsapplication, reload twice (the first load persists the value, the second one applies it) and check the events go toapi.segment.ioagain and the bundle tocdn.segment.com.npm run lint,npx tsc --noEmitandnpm testpass locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01KDE5NS3oeKPcJWXbTTqSBx