Skip to content

feat(plans): gate Claude tracking to Enterprise per-customer opt-in on cloud - #423

Merged
gkhngyk merged 1 commit into
mainfrom
feature/claude-enterprise-gating
Jul 14, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/claude-enterprise-gating

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

On cloud, API-model (Claude) tracking is no longer part of Growth and becomes a per-customer opt-in on Enterprise. Self-host is untouched (isCloud() === false always resolves to the unrestricted self_hosted plan).

  • Plan config (web plans.ts + server plans.js, kept in sync): Growth and Enterprise both set allowedModels: []. Enabling a specific Enterprise customer is a single DB write — organizations.plan_overrides = { "allowedModels": ["claude-sonnet-5"] } — because the existing override merge (web getOrgPlan, server applyPlanOverrides) already folds plan_overrides into the effective limits. No new mechanism.
  • UI reflects per-customer state: the dashboard layout now computes the effective model allowlist (overrides included) and threads it through PlanProvider as allowedModelIds; the prompt pickers (brand prompts page, brands/new, suggestion card via prop) read it from context instead of the static PLANS[planId], which can't see overrides.
  • Plan-change alignment: alignPromptsToPlanForOrg now reads Enterprise plan_overrides so an alignment run doesn't strip Claude from a customer we've enabled.
  • Runtime guard in the tracking worker: prompt.models is filtered against the org's effective allowlist at run time (applyPlanOverrides exported from the server plan-guard), so stored arrays that still carry Claude ids stop producing API calls immediately on deploy — no data migration required. Task counting uses the filtered list, keeping the progress bar denominator accurate.

Save-path enforcement needed no changes: filterByPlan already resolves through getOrgPlan.

Notes

  • Known edge: the onboarding wizard reads the static plan config, so an Enterprise org with the override set wouldn't see Claude during (re-)onboarding — models can be added from the prompts page afterwards. Left out deliberately to keep the change small.
  • Existing prompts' models arrays have already been cleaned up separately; this PR is the standing rule that keeps things consistent going forward.

Related Issue

N/A — packaging change requested directly.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🧹 Chore / refactor
  • 📝 Documentation
  • 🚨 Breaking change

How to Test

  1. Cloud env (NEXT_PUBLIC_IS_CLOUD=true / IS_CLOUD=true), Growth org → prompt create/edit dialogs show no Claude checkbox; saving a prompt with models: ["claude-sonnet-5"] via the action strips it.
  2. Enterprise org without overrides → same as Growth (no Claude).
  3. Set plan_overrides = {"allowedModels": ["claude-sonnet-5"]} on the Enterprise org → after reload, the Claude checkbox appears; saved prompts keep the model; a tracking run calls the Anthropic API.
  4. Give a Growth org's prompt a stale models: ["claude-sonnet-5"] directly in the DB → the tracking worker logs api-model tracking plan-gated for this org and makes no Anthropic call; progress total excludes the skipped task.
  5. Self-host (no cloud env vars) → Claude picker visible, tracking runs, nothing gated.

Checklist

  • My code follows the project's style guidelines (Prettier clean)
  • I have performed a self-review of my code
  • npx tsc --noEmit passes
  • Web tests pass (45/45), server tests pass (113/113)
  • Manually tested on cloud with a Growth + Enterprise org

…n cloud

On cloud, API-model (Claude) tracking leaves Growth and becomes a
per-customer switch on Enterprise: both plans now set allowedModels: []
and a chosen customer is enabled by setting
organizations.plan_overrides = { "allowedModels": ["claude-sonnet-5"] },
which the existing override merge (web getOrgPlan / server
applyPlanOverrides) already folds into the effective limits. Self-host
resolves to the self_hosted plan and is untouched.

Enforcement covers every path: the dashboard layout now computes the
effective allowlist (overrides included) and threads it through
PlanProvider so the prompt pickers reflect per-customer state; the save
path already filtered via getOrgPlan; alignPromptsToPlanForOrg learns
about enterprise overrides so plan changes don't strip an enabled
customer's Claude; and the tracking worker filters prompt.models at run
time, so existing Growth prompts that still carry claude ids stop
producing API calls immediately without a data migration.
@gkhngyk
gkhngyk merged commit 9485b04 into main Jul 14, 2026
4 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