fix(analytics): preserve acquisition attribution across marketing and app signup

Closed
IT
13d ago
+3958-80

What & why

Visitors move from paradev.com to app.superset.sh, where separate anonymous identities can break the connection between their acquisition source and account activity. This adds an explicit identity handoff without migrating domains.

Related issue: none; this fixes the acquisition identity gap.

  • Connects the marketing visitor's anonymous PostHog identity to their authenticated account through web signup/login and desktop browser-auth.
  • Stores first-touch and latest non-direct attribution: UTMs, supported ad-click IDs, referrer domain, landing path and observed timestamp.
  • Uses short-lived, single-use, browser-bound tickets backed by the existing KV integrations. No new hosted service.
  • Matches existing PostHog opt-out behavior: no Accept prerequisite; explicit opt-out also suppresses bridge capture. Marketing and docs share the native SDK project consent cookie, including already-open docs revocation; same-site direct docs checks legacy marketing-only opt-outs before SDK initialization. Unsupported cross-site checks return unavailable before loading the iframe.
  • Preserves genuine GitHub referrals, including direct sign-in/sign-up arrivals, while excluding desktop OAuth returns.
  • Keeps existing native authentication validation intact.

Review fixes: ordered sync intents prevent a late enable from overwriting a newer revoke; server touch time does not advance browser intent ordering; revocation does not wait for SDK initialization; direct web-entry source is saved before the acquisition redirect; callback nonce matching preserves abandoned-OAuth and earlier same-host GitHub referrals; per-journey cookies preserve overlapping desktop/signup continuations; all first-touch keys retain a complete original snapshot; PostHog dispatch awaits captureImmediate; script literals escape <; unsupported pathnames retain valid campaign data; loopback-only browser fixtures use atomic CAS. Commit authorship uses the submitting account's ID-based noreply address. This is not CLA signing.

How I tested it

  • Latest scoped consent checks: 14 tests passed, 0 failures, 41 assertions in 2 files, including cross-site rejection and both company roots/local development/exact custom host. Affected shared/docs/marketing typechecks and dependency build: 4/4 tasks (1 valid cached dependency); 2 changed TS files Biome clean.
  • Previous integrated bridge verification at bc079291d is retained for unchanged coverage, not claimed rerun: 160 tests passed, 476 assertions, 12 files; 9/9 typecheck/build tasks and 22 TS/TSX lint files. Latest exact-head CI run43166145428 passed all 8 jobs.
  • Fresh real Chromium: overlapping desktop/signup roundtrips retain each return/state; a tagged marketing→signup emits the expected local identify snapshot. Earlier controlled GitHub signup/signin/desktop referrer evidence is retained for unchanged behavior, not claimed rerun.
  • Integrated docs correction reuses its source-bound 10 Chromium journeys: default/shared identity, UI/native opt-out, already-open docs revocation, accepted re-enable, fresh docs-direct, legacy marketing-only declines and unavailable legacy check. Actual pinned SDK/instrumentation with fixture capture, not production receipt.
  • Actual captureAcquisition with pinned posthog-node and a local deferred HTTP response stayed pending until dispatch completed.
  • Earlier real Redis evidence is reused for unchanged storage/CAS coverage, not claimed rerun.
  • Browser tests use fixture authentication and local capture, not live OAuth, Electron or production PostHog merge verification.
  • Earlier full-suite evidence is retained for unchanged coverage, not presented as a fresh full-suite run for this revision.

Screenshots: no visual UI change. This changes attribution/auth transport; behavioral assertions above verify the sign-up and desktop paths rather than screenshots of unchanged screens.

Rollout and limitations

  • The website (paradev.com) and signed-in app (app.superset.sh) use their existing KV integrations. This implementation needs both sides to access the bridge's shared ticket records; whether their deployed KV configuration already provides that access has not been verified.
  • No new hosted service, environment variable, database schema migration or desktop binary release is introduced by this change.
  • Release the website (paradev.com), docs and signed-in app changes together. Same-site direct docs waits for the small existing-origin consent endpoint before initializing analytics; an unavailable/unsupported cross-site check suppresses that page's SDK initialization without persisting a new choice.
  • This does not migrate domains or transfer a decline stored only on superset.sh to paradev.com. That cross-registrable-domain preference-transfer gap predates the PR; current-origin migration and same-site docs propagation do not solve brand-cutover migration.
  • After deployment, verify a tagged website-to-signup/desktop journey and default/opt-out/docs controls in PostHog. Local fixture results do not establish production ingestion or person merging.
  • Attribution is prospective. This does not recover missing historical links or complete organization/revenue ROAS reporting.
  • At-most-once dispatch can lose a link on a crash or timeout. Previously submitted events or identity merges cannot be recalled by a later opt-out.
  • Preview currently fails because the upstream pull_request workflow cannot receive its Neon/Vercel secrets or a write-capable comment token from a fork PR. No check was disabled and no secrets were moved into the fork. Maintainers need a supported upstream preview route for this existing PR; a rerun alone does not change fork privileges.
  • Contributor reports CLA completion, but supported recheck43165596104 failed and the configured signature record did not contain itsNintu. Signing location/account reconciliation is pending; no assent is asserted by this PR description.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (latest-head CI run 43166145428 passed all 8 jobs, including Lint, Test and Typecheck; affected local checks also passed)
  • "Allow edits from maintainers" is checked on fork PRs
  • I have signed the CLA (the bot asks on your first PR)

Summary by CodeRabbit

  • New Features
    • Carry campaign attribution from the marketing site into web and desktop sign-in flows.
    • Apply analytics consent and opt-out choices across supported sites.
  • Bug Fixes
    • Improved GitHub sign-in and sign-up handling to preserve redirect destinations and avoid misattributing OAuth returns.
    • Consent choices now behave more reliably when browser storage is unavailable or fails.