Skip to content

feat(billing): remember the referral link until sign-up - #4276

Open
baktun14 wants to merge 1 commit into
feat/billing-attribute-referred-signups-apifrom
feat/billing-capture-referral-link
Open

baktun14 wants to merge 1 commit into
feat/billing-attribute-referred-signups-apifrom
feat/billing-capture-referral-link

Conversation

@baktun14

@baktun14 baktun14 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Why

Closes CON-1189 (with #4275). A visitor who opens an affiliate's link usually browses before signing up, and may sign up days later. Console has to remember the code until then and send it with the sign-up.

Stacked on #4275.

What

  • middleware.ts stores a valid ?ref= code in a console_referral cookie (30 days, HttpOnly, SameSite=Lax, Secure in production). Opening another affiliate's link replaces it, and an invalid code leaves it alone.
  • All three sign-up paths (Auth0 hosted login and social callback, email code, password sign-up) read the cookie and pass it to POST /v1/register-user as referralCode. Without a cookie, the body is unchanged.
  • The API only links brand-new accounts, so a signed-in user opening a link has no effect.

Testing

Unit specs for the cookie helpers, middleware, session service and each sign-up route. The new Auth0 callback spec reloads the route module per test because the route memoizes its handler with once(). Mutation score on changed lines: 88.9%.

@baktun14
baktun14 requested a review from a team as a code owner October 8, 2026 11:45

@claude claude 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review: 1

  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@baktun14

Copy link
Copy Markdown
Contributor Author

@claude review

@claude claude 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.

⚠️ Code review skipped — your organization's remaining monthly code review budget is too low to start another review, so this review was not started.

An organization admin can view or raise the monthly spending cap at claude.ai/admin-settings/usage, on the Claude Code Review row under Services. The cap resets at the start of the next billing period.

Once the cap resets or is raised, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@baktun14
baktun14 force-pushed the feat/billing-attribute-referred-signups-api branch from 487deb0 to febb109 Compare November 4, 2026 07:29
@baktun14
baktun14 force-pushed the feat/billing-capture-referral-link branch from 12234c6 to e036578 Compare November 4, 2026 07:29
@baktun14
baktun14 force-pushed the feat/billing-attribute-referred-signups-api branch from febb109 to 01fccfc Compare November 5, 2026 21:02
@baktun14
baktun14 force-pushed the feat/billing-capture-referral-link branch from e036578 to ad3ecae Compare November 5, 2026 21:02
@baktun14
baktun14 force-pushed the feat/billing-attribute-referred-signups-api branch from 01fccfc to fe2b404 Compare November 5, 2026 21:43
@baktun14
baktun14 force-pushed the feat/billing-capture-referral-link branch from ad3ecae to a39d61e Compare November 5, 2026 21:43
Capture a visitor's ?ref= affiliate code in a cookie at the edge and
forward it to register-user on sign-up, so attribution survives the
gap between clicking a referral link and creating an account.

- add referral-cookie lib: code normalization/validation and cookie read helper
- middleware sets console_referral (30 days, HttpOnly, Secure in prod)
  on a valid ref param, overwriting any prior code
- SessionService.createLocalUser/signUp forward an optional
  referralCode to POST /v1/register-user
- the three sign-up paths (auth0 callback, email code verify, password
  signup) read the cookie and pass it through
@baktun14
baktun14 force-pushed the feat/billing-attribute-referred-signups-api branch from fe2b404 to 5f0e810 Compare November 9, 2026 01:08
@baktun14
baktun14 force-pushed the feat/billing-capture-referral-link branch from a39d61e to ba1c23e Compare November 9, 2026 01:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant