Skip to content

feat: capture signup attribution in docs middleware#1093

Merged
juan-arcadedev merged 4 commits into
mainfrom
copy-attribution-from-ui-kit
Jul 25, 2026
Merged

feat: capture signup attribution in docs middleware#1093
juan-arcadedev merged 4 commits into
mainfrom
copy-attribution-from-ui-kit

Conversation

@juan-arcadedev

@juan-arcadedev juan-arcadedev commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Captures utm_*/gclid/referrer on the first docs page a visitor lands on and writes the shared .arcade.dev cookie 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 every proxy.ts response, 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 on arcade.dev.

A new withAttribution wrapper runs on every proxy response (including locale and /toolkits redirects) so attribution is persisted before redirects strip the query string. Cookie scope is .arcade.dev in 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.

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>
@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jul 24, 2026 11:55pm

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread proxy.ts
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
Comment thread tests/attribution.test.ts Outdated
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>
Comment thread proxy.ts
// 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

@juan-arcadedev
juan-arcadedev merged commit 36b0a40 into main Jul 25, 2026
7 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