Skip to content

feat(claim-db-worker): pass the CLI's command tag on to sign-in - #98

Merged
gregory-boch-prisma merged 1 commit into
mainfrom
feat/claim-forward-cli-utm
Nov 30, 2026
Merged

gregory-boch-prisma merged 1 commit into
mainfrom
feat/claim-forward-cli-utm

Conversation

@gregory-boch-prisma

Copy link
Copy Markdown
Contributor

What

The claim button now passes the CLI's tag on to sign-in, so a signup that started with npx create-db (or create-pg, create-postgres) is credited to that command instead of the generic create-db-frontend claim button.

  • app/claim/page.tsx: the button's request to /api/auth/url includes the page's own utm_source, utm_medium and utm_content, which the CLI put on the claim URL.
  • lib/claim-campaign.ts (new): claimCampaign() keeps known values only:
    • utm_source: create-db, create-pg, create-postgres, plus the two existing web tags create-db-frontend and create_db_web;
    • utm_medium: cli or claim_button;
    • utm_content: the CLI output modes default, json, env, quiet.
  • app/api/auth/url/route.ts: uses those tags on the auth.prisma.io/authorize URL instead of the hard-coded pair.

Privacy

The CLI's utm_source on the claim URL is the hidden --user-agent flag when it is set, else PRISMA_ACTOR_NAME/PRISMA_ACTOR_PROJECT from the user's env file, else the command name. The first two are free text and can name a person or a project. They are never passed on:

  • a CLI claim with any other utm_source becomes create-db (the medium cli is kept);
  • anything else unknown falls back to the old create-db-frontend / claim_button;
  • a page without tags (or a cached page from before this change) also keeps the old pair.

What changes in the data

New claim signups show create-db, create-pg or create-postgres as their utm_source, cli as their medium and the output mode as utm_content, where they used to show create-db-frontend / claim_button. A series built on utm_source = create-db-frontend needs to include the command names from the deploy date. The signup is still recognisable as a developer-tool signup by utm_medium (cli or claim_button).

Testing

  • vitest run in apps/claim-db-worker: 24 pass, including 11 new: the route passes create-pg / cli / json through, replaces a Jane Doe/acme-secret-app tag with create-db and never puts it on the URL, keeps the old pair for a page without tags; claimCampaign() normalises case and whitespace and drops unknown mediums and content; the claim page sends its tags in the request body.
  • tsc --noEmit passes.

Needs a human review before merge.

🤖 Generated with Claude Code

The claim button always sent utm_source=create-db-frontend, so a signup from a
claimed database could not be credited to the command that made it. The claim
page now sends its own utm_source, utm_medium and utm_content to
/api/auth/url, and the route keeps only known values: create-db, create-pg,
create-postgres (and the two existing web tags), cli or claim_button, and the
four output modes. A free-text tag from --user-agent or the env file's
PRISMA_ACTOR_NAME/PRISMA_ACTOR_PROJECT becomes create-db, so no value from a
user's environment reaches the signup. A page without tags keeps the old
create-db-frontend / claim_button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary by CodeRabbit

  • New Features
    • Claim links now preserve campaign tracking details through authorization, including source, medium, and content tags.
    • Tracking values are normalized and checked against supported options. Invalid or missing values receive appropriate defaults, keeping claim links usable without trusted campaign tags.

Walkthrough

The claim page now sends utm_source, utm_medium, and utm_content to the auth URL API. The API validates and normalizes those values, then adds truthy campaign tags to the authorization URL. Tests cover tag validation, fallback behavior, and the request and URL parameters.

Merge Risk: Minimal · up to adc19

The claim page now forwards validated campaign tags so signups can be attributed to the CLI command that started them. Unknown or free-text values are replaced with safe defaults, and untagged pages keep their previous attribution. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the claim button now forwards the CLI command tag (utm_source and related tags) to sign-in. It matches the changeset, which adds claimCampaign validation and passes th…
Description check Passed The description states what changes and why. It lists the changed files (page.tsx, claim-campaign.ts, route.ts), the allowlisted tag values, the privacy fallback behavior, the expected data impact, an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the claim button now forwards the CLI command tag (utm_source and related tags) to sign-in. It matches the changeset, which adds claimCampaign validation and passes the tags through /api/auth/url. The title is specific and follows conventional commit form.

Full details: Description check

Explanation

The description states what changes and why. It lists the changed files (page.tsx, claim-campaign.ts, route.ts), the allowlisted tag values, the privacy fallback behavior, the expected data impact, and the tests run. This matches the raw summary and objectives.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/claim-db-worker/__tests__/auth-url-api.test.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

apps/claim-db-worker/__tests__/claim.test.tsx

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

apps/claim-db-worker/app/api/auth/url/route.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

  • 2 others
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 18009d38-577b-42ec-87ea-cabf5ad039d0
Commits

Reviewing files that changed from the base of the PR and between 7965f01 and adc1927.

Files selected for processing: 5

  • apps/claim-db-worker/__tests__/auth-url-api.test.ts
  • apps/claim-db-worker/__tests__/claim.test.tsx
  • apps/claim-db-worker/app/api/auth/url/route.ts
  • apps/claim-db-worker/app/claim/page.tsx
  • apps/claim-db-worker/lib/claim-campaign.ts

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Preview CLIs & Workers are live!

Test the CLIs locally under tag pr98-feat-claim-forward-cli-utm-45806551648:

npx create-db@pr98
npx create-pg@pr98
npx create-postgres@pr98

Worker URLs
• Create-DB Worker: https://create-db-temp.prisma.io
• Claim-DB Worker: https://create-db.prisma.io

These will live as long as this PR exists under tag pr98-feat-claim-forward-cli-utm-45806551648.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
claim-db-worker adc1927 Commit Preview URL

Branch Preview URL
Nov 26 2026, 11:02 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
create-db-worker adc1927 Commit Preview URL

Branch Preview URL
Nov 26 2026, 11:00 AM

@gregory-boch-prisma
gregory-boch-prisma merged commit 4650c41 into main Nov 30, 2026
9 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.

1 participant