feat: active user billing (#27867)

* factory and statergie

* chore: use correct method of DI

* feat: add onchagne

* add logic to HWM stat

* add webhook resolver methods to each statergy

* move seat tracking + webhooks over to own statergy

* Move to factory base approach

* move logic to correct class

* rename create -> createByTeamId

* fix: remove debug `true ||` overrides from IS_STRIPE_ENABLED and IS_TEAM_BILLING_ENABLED

Remove accidentally committed debug overrides that short-circuited
IS_STRIPE_ENABLED and IS_TEAM_BILLING_ENABLED to always be true,
bypassing Stripe credential checks. This would break self-hosted
instances without Stripe configured.

Identified by cubic (https://cubic.dev)

Co-Authored-By: unknown <>

* feat: active user billing

* add tests

* UI side for users on active billing

* use correct period of stripe sub

* feat: claude feedback

* fix: skip Stripe sync for canceled/expired subscriptions to prevent repeated API calls

Co-Authored-By: unknown <>

* feat: feedback

* feat: only render when active users mode is set

* fix type error

* fix: constants + feature flags

* fix: default to null in tests

* chore: use seats in test

* fix: use node:crypto protocol for Node.js builtin imports

Co-Authored-By: [email protected] <[email protected]>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-02-12 13:57:32 +00:00
1 parent bf348ee209
commit d52e2d9fad
28 files changed
+2327 -79

No files matched your search

@@ -0,0 +1,14 @@
-- CreateEnum
CREATE TYPE "BillingMode" AS ENUM ('SEATS', 'ACTIVE_USERS');
-- AlterTable
ALTER TABLE "TeamBilling" ADD COLUMN "billingMode" "BillingMode" NOT NULL DEFAULT 'SEATS';
-- AlterTable
ALTER TABLE "OrganizationBilling" ADD COLUMN "billingMode" "BillingMode" NOT NULL DEFAULT 'SEATS';
-- Seed feature flag
INSERT INTO "Feature" ("slug", "enabled", "type", "description", "createdAt", "updatedAt")
VALUES
('active-user-billing', false, 'OPERATIONAL', 'Enable active-user-based billing for teams and organizations', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
ON CONFLICT ("slug") DO NOTHING;
+7
View File
@@ -2600,6 +2600,11 @@ enum BillingPeriod {
ANNUALLY
}
enum BillingMode {
SEATS
ACTIVE_USERS
}
model OrganizationOnboarding {
// TODO: Use uuid for id
id String @id @default(uuid())
@@ -3039,6 +3044,7 @@ model TeamBilling {
subscriptionEnd DateTime?
billingPeriod BillingPeriod?
billingMode BillingMode @default(SEATS)
pricePerSeat Int?
paidSeats Int?
monthlyProrations MonthlyProration[]
@@ -3067,6 +3073,7 @@ model OrganizationBilling {
subscriptionEnd DateTime?
billingPeriod BillingPeriod?
billingMode BillingMode @default(SEATS)
pricePerSeat Int?
paidSeats Int?
monthlyProrations MonthlyProration[]