feat(dashboard): add deployBilling flag + local always-on flag provider#6396
Conversation
This stack of pull requests is managed by jj-ryu. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — adds a deployBilling feature flag (default off, gating the Unkey Deploy billing UI until GA) plus a local dev escape hatch that resolves all flags on without a Vercel Flags setup.
- Add
deployBillingflag — newflag<boolean, Entities>inlib/flags/index.tskeyeddeploy-billing,defaultValue: false; mirrors the existinghelloWorldshape exactly. - Local always-on adapter —
adapter<T>()inlib/flags/plumbing.tsshort-circuits todecide: () => true as TwhenFLAGS_LOCAL_ALL_ON === "true", checked before the vercel-adapter try/catch. - Register in
resolveAll—lib/flags/resolve.tsaddsdeployBillingto the resolved set so theFlagstype andFlagsProviderexpose it to client components. - Document env var —
.env.exampledocumentsFLAGS_LOCAL_ALL_ONas a dev-only convenience.
The change is consistent with the established flag-registry pattern, the defaultValue: false is correct for a GA-gated flag, and the true as T shortcut is sound while all flags remain booleans (the comment documents that assumption). Reading FLAGS_LOCAL_ALL_ON via process.env directly rather than the env.ts zod schema matches the existing flags-plumbing convention.
Claude Opus | 𝕏
22e46ed to
5a996bc
Compare
453ea1b to
cd4b05e
Compare
5a996bc to
bb34dae
Compare
cd4b05e to
6aa771c
Compare
bb34dae to
e48d34d
Compare
6aa771c to
530f9da
Compare
e48d34d to
8ce5550
Compare
390e072 to
f9a62cc
Compare
9da5acd to
c1052a0
Compare
f9a62cc to
fe0684a
Compare
c1052a0 to
e3fcc8c
Compare
fe0684a to
e193626
Compare
e3fcc8c to
ecbbffa
Compare
e193626 to
1cde9e5
Compare
ecbbffa to
bf4ddcf
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — since the prior pullfrog review the all-on local escape hatch was replaced with an explicit per-flag override list, directly addressing @chronark's predictability concern on plumbing.ts.
- Replaced
FLAGS_LOCAL_ALL_ONwithFLAGS_LOCAL_OVERRIDES—plumbing.tsnow parses a comma-separated list of flag keys into aSetand forces only those keyson, instead of resolving every flag totrue. The override layer wraps the base adapter ({ ...base, decide }) and falls through tobase.decidefor non-listed keys, so per-flag prod defaults stay honest. - Override applied after adapter construction — the override no longer short-circuits before the vercel-adapter try/catch; it composes over whichever base adapter (vercel or noop fallback) was built, and a
console.warnwas added on the fallback path. - Updated
.env.example— documentsFLAGS_LOCAL_OVERRIDESwith a worked example, replacing the oldFLAGS_LOCAL_ALL_ONblock.
The new shape is sound: localOverrides is read once at module load (acceptable for a dev-only hatch, matching the prior convention), the true as T cast remains valid while all flags are boolean (documented), and delegating to base.decide for unlisted keys keeps non-overridden flags evaluating normally. This is strictly more predictable than the previous all-on behavior. The deployBilling flag definition and resolveAll registration are unchanged from the prior review.
Claude Opus | 𝕏
Adds the RunDeployBillingPush cron handler: computes month-to-date Deploy usage (CPU, memory, egress, disk) from ClickHouse via the instance meter query and pushes each billable workspace's running total to Stripe Billing Meter events (deploy.* event names). Meters use 'last' aggregation, so posting the absolute month-to-date value overwrites the prior one; retries and overlapping ticks are harmless. Keyed by billing period (YYYY-MM); hourly schedule via restate-cronjobs. No-op unless ClickHouse and a Stripe secret key are configured. ENG-2864
chronark
left a comment
There was a problem hiding this comment.
you go figure it out with oz :D

Adds the
deployBillingfeature flag (Vercel Flags) plus a local always-on flag provider (FLAGS_LOCAL_ALL_ON), so the Compute/Deploy billing UI can be gated per workspace and flipped on for the GA rollout. Defaults off, so prod shows nothing until then.Foundation for the flag-gated billing UI.
Part of ENG-2873.