Skip to content

Feat/seat based billing#8006

Open
dstaley wants to merge 3 commits intomainfrom
feat/seat-based-billing
Open

Feat/seat based billing#8006
dstaley wants to merge 3 commits intomainfrom
feat/seat-based-billing

Conversation

@dstaley
Copy link
Member

@dstaley dstaley commented Mar 6, 2026

Description

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

Release Notes

  • New Features
    • Added seat-based billing support for subscription items
    • Added per-unit pricing structures to billing plans
    • Added per-unit cost breakdown in checkout totals

@vercel
Copy link

vercel bot commented Mar 6, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Mar 6, 2026 4:48pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2026

🦋 Changeset detected

Latest commit: f2e39f4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
Name Type
@clerk/clerk-js Minor
@clerk/shared Minor
@clerk/chrome-extension Patch
@clerk/expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/localizations Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/react Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/ui Patch
@clerk/vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 6, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8006

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8006

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8006

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8006

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8006

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8006

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8006

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8006

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8006

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8006

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8006

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8006

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8006

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8006

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8006

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8006

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8006

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8006

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8006

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8006

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8006

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8006

commit: f2e39f4

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

This pull request adds support for seat-based billing and per-unit pricing structures to the billing system. New type definitions are introduced for billing unit prices, tiers, and subscription seats in both the shared types and JSON schema files. The BillingPlan resource is extended with a unitPrices field, BillingSubscription is extended with a seats field, and billing totals are expanded to include a perUnitTotals breakdown. JSON deserialization logic is updated to parse these new fields from the API response. A changeset file documents these minor version bumps.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat/seat based billing' is related to the changeset, which adds seat-based and per-unit billing structures across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/clerk-js/src/utils/billing.ts`:
- Around line 23-33: The change adds a new parser billingPerUnitTotalsFromJSON
(and related types like BillingPerUnitTotalJSON) but no tests were added; add
unit tests that cover the happy-path mapping of per_unit_totals to
BillingPerUnitTotal (verify name, block_size -> blockSize, tiers array,
fee_per_block and total mapped via billingMoneyAmountFromJSON) and
negative/null/optional cases (e.g., missing tiers, null fee_per_block/total) to
detect regressions—place tests exercising the billingPerUnitTotalsFromJSON
function and any upstream parsing that produces per_unit_totals so future
changes to unit_prices/seats/per_unit_totals are guarded.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b7290789-ebef-42a4-ad61-b568277203b5

📥 Commits

Reviewing files that changed from the base of the PR and between 79d0ecf and f2e39f4.

📒 Files selected for processing (6)
  • .changeset/cute-ideas-appear.md
  • packages/clerk-js/src/core/resources/BillingPlan.ts
  • packages/clerk-js/src/core/resources/BillingSubscription.ts
  • packages/clerk-js/src/utils/billing.ts
  • packages/shared/src/types/billing.ts
  • packages/shared/src/types/json.ts

Comment on lines +23 to +33
const billingPerUnitTotalsFromJSON = (data: BillingPerUnitTotalJSON[]): BillingPerUnitTotal[] => {
return data.map(unitTotal => ({
name: unitTotal.name,
blockSize: unitTotal.block_size,
tiers: unitTotal.tiers.map(tier => ({
quantity: tier.quantity,
feePerBlock: billingMoneyAmountFromJSON(tier.fee_per_block),
total: billingMoneyAmountFromJSON(tier.total),
})),
}));
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add regression tests for new billing parsers before merge.

This adds new parsing paths (per_unit_totals) and is part of a broader rollout (unit_prices, seats) but no tests were added/updated in this PR context. Please add coverage for happy-path mapping and null/optional field handling to prevent silent contract regressions.

As per coding guidelines: "**/*: If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes."

Also applies to: 70-72

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/clerk-js/src/utils/billing.ts` around lines 23 - 33, The change adds
a new parser billingPerUnitTotalsFromJSON (and related types like
BillingPerUnitTotalJSON) but no tests were added; add unit tests that cover the
happy-path mapping of per_unit_totals to BillingPerUnitTotal (verify name,
block_size -> blockSize, tiers array, fee_per_block and total mapped via
billingMoneyAmountFromJSON) and negative/null/optional cases (e.g., missing
tiers, null fee_per_block/total) to detect regressions—place tests exercising
the billingPerUnitTotalsFromJSON function and any upstream parsing that produces
per_unit_totals so future changes to unit_prices/seats/per_unit_totals are
guarded.

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