feat: capture signup attribution in docs middleware#1093
Conversation
Capture utm_*/gclid/referrer on the first docs page a visitor lands on and write the shared `.arcade.dev` cookie that identity-ui reads back at registration, using `@arcadeai/ui-kit/utils/attribution` for parity with identity-ui and www. The cookie attaches to every proxy response (including locale redirects) since those drop the query string. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 312df2c. Configure here.
Deriving the cookie domain from the last two hostname labels produced a public-suffix Domain on preview deploys (`.vercel.app`), which browsers reject, dropping attribution capture. Match `.arcade.dev` explicitly — the only cross-subdomain scope we need — and fall back to a host-only cookie everywhere else (previews, localhost). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-ui-kit # Conflicts: # package.json # pnpm-lock.yaml
The extract/build helpers are ui-kit's and already tested there; this file only re-exercised library code. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| // register flow reads back. First-touch wins: skip if the cookie already exists. | ||
| // Attaches to whatever response we return because most first visits hit the | ||
| // locale redirect below, which drops the query string. | ||
| function withAttribution( |
There was a problem hiding this comment.
nit: if we ended up adding this a third time, I think we should add this fn to ui-kit. I don't think it's worth doing that now because we only have it in identity-ui and here.
There was a problem hiding this comment.
Agreed, I'll just go ahead and add it when workign on the dashboard attribution aswell and then will do a follow up and remove it from here and on the landing page

Captures
utm_*/gclid/referrer on the first docs page a visitor lands on and writes the shared.arcade.devcookie that identity-ui reads back at registration, giving docs the same signup attribution as identity-ui and www. Uses@arcadeai/ui-kit/utils/attribution(v0.14.0 — 0.15.0 needs design-system ≥7.1.0, which isn't published yet) so the cookie format stays in parity across repos. The cookie attaches to everyproxy.tsresponse, including the locale redirects, since those drop the query string on first visit. Adds a test covering param capture and the cookie contract identity-ui parses.Note: pulling in ui-kit dragged ~29 transitive packages into the lockfile via pnpm auto-install-peers (Vercel AI SDK, react-query, react-router, arcadejs); none are imported by the attribution module or docs — a standalone attribution lib would avoid this.
Note
Medium Risk
Cross-subdomain cookie behavior affects marketing attribution and must stay aligned with identity-ui; lockfile bloat adds supply-chain surface though runtime usage is limited to attribution utils.
Overview
Docs middleware now records first-touch signup attribution (
utm_*,gclid, referrer) into the same cookie identity-ui uses at registration, so campaigns that land on docs are not lost when users sign up elsewhere onarcade.dev.A new
withAttributionwrapper runs on everyproxyresponse (including locale and/toolkitsredirects) so attribution is persisted before redirects strip the query string. Cookie scope is.arcade.devin production and host-only on preview/local; an existing cookie is left unchanged.Shared helpers come from
@arcadeai/ui-kit@0.14.0(extractAttribution/buildAttributionCookie). The lockfile grows with ui-kit’s peer-related transitive deps; docs only imports the attribution utils.Reviewed by Cursor Bugbot for commit d16d40f. Bugbot is set up for automated code reviews on this repo. Configure here.