Repository navigation
feat(auth): add first-touch signup attribution - #764
Merged
Merged
Conversation
Capture initial UTM tags and external referrer hostname after cookie consent. Preserve attribution through self-serve and invite registration with nullable User columns and a migration that leaves existing accounts unattributed. Sanitize optional payloads without blocking signup, preserve affiliate behavior, and document consent, direct traffic, retention, and aggregation semantics.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New signups currently have no marketing acquisition data. This change remembers the first landing and saves UTM tags and an external referrer hostname with each new user.
User.utm_source,utm_medium,utm_campaign,utm_content,utm_term(100 characters) andreferrer_host(253 characters), with no defaults or historical backfill.Consent and first-touch behavior:
The existing GA component loads only after accepted cookie consent. Although this is first-party data, acquisition measurement is optional analytics, so this implementation follows the stricter interpretation. The initial landing remains in component memory until accepted consent; only then is a 60-day SameSite=Lax cookie written (Secure on HTTPS). It is scoped to telemetry-tracker.com and its subdomains on the canonical deployment, and host-only elsewhere. Existing attribution, including an all-null direct landing, is not overwritten or refreshed. Rejection deletes the cookie and disables forwarding. The server action independently checks its authoritative consent cookie. The GA integration is unchanged.
Before consent, a full reload or another origin loses the memory-only landing. Consent remains host-specific under the existing consent system, so signup on another subdomain requires accepted consent there. Cookie expiry/deletion or another browser starts another observable first touch. The public API treats attribution as untrusted client input; direct API clients must obtain consent themselves. No new personal fields or full referring URLs are stored.
Affiliate behavior is unchanged:
ref/viacapture remains last-touch, retains its existing sessionStorage and optional consented cookie behavior, and is handled independently. Browser regression tests cover campaign forwarding alongside affiliate codes; the opt-in DB affiliate test now asserts both records are persisted.Validation:
pnpm install --frozen-lockfile,pnpm lint, and the fullpnpm testpass: 1,426 tests passed, 128 opt-in DB tests skipped.pnpm --filter api buildandpnpm --filter dashboard buildpass.tsc --noEmitretains exactly the baseline failures: 106 API test-file diagnostics and six dashboard test-file diagnostics. Compared against an archive oforigin/developwith the same installed dependencies: no new diagnostics. No checks were weakened.origin/develop;git diff --checkpasses.Daily signup aggregation (Prisma timestamps are stored in UTC; NULL includes direct, missing and consent-declined traffic):
Implementation details and limitations:
docs/SIGNUP-ATTRIBUTION.md. No merge, deployment, publication or production data access was performed.