Skip to content

feat(dashboard): add deployBilling flag + local always-on flag provider#6396

Merged
Flo4604 merged 4 commits into
mainfrom
deploy-billing-flag
Jun 16, 2026
Merged

feat(dashboard): add deployBilling flag + local always-on flag provider#6396
Flo4604 merged 4 commits into
mainfrom
deploy-billing-flag

Conversation

@Flo4604

@Flo4604 Flo4604 commented Jun 9, 2026

Copy link
Copy Markdown
Member

Adds the deployBilling feature 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.

@Flo4604

Flo4604 commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by jj-ryu.

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
dashboard Ready Ready Preview, Comment Jun 16, 2026 9:41am
design Ready Ready Preview, Comment Jun 16, 2026 9:41am

Request Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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 deployBilling flag — new flag<boolean, Entities> in lib/flags/index.ts keyed deploy-billing, defaultValue: false; mirrors the existing helloWorld shape exactly.
  • Local always-on adapteradapter<T>() in lib/flags/plumbing.ts short-circuits to decide: () => true as T when FLAGS_LOCAL_ALL_ON === "true", checked before the vercel-adapter try/catch.
  • Register in resolveAlllib/flags/resolve.ts adds deployBilling to the resolved set so the Flags type and FlagsProvider expose it to client components.
  • Document env var.env.example documents FLAGS_LOCAL_ALL_ON as 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.

Pullfrog  | View workflow run | Using Claude Opus𝕏

@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

ENG-2873

@Flo4604 Flo4604 force-pushed the docs-dashboard-stripe-env branch from 390e072 to f9a62cc Compare June 11, 2026 12:01
@Flo4604 Flo4604 force-pushed the deploy-billing-flag branch from 9da5acd to c1052a0 Compare June 11, 2026 12:01
@Flo4604 Flo4604 force-pushed the docs-dashboard-stripe-env branch from f9a62cc to fe0684a Compare June 11, 2026 15:51
@Flo4604 Flo4604 force-pushed the deploy-billing-flag branch from c1052a0 to e3fcc8c Compare June 11, 2026 15:51
@Flo4604 Flo4604 force-pushed the docs-dashboard-stripe-env branch from fe0684a to e193626 Compare June 11, 2026 15:52
@Flo4604 Flo4604 force-pushed the deploy-billing-flag branch from e3fcc8c to ecbbffa Compare June 11, 2026 15:52
@Flo4604 Flo4604 force-pushed the docs-dashboard-stripe-env branch from e193626 to 1cde9e5 Compare June 11, 2026 16:28
@Flo4604 Flo4604 force-pushed the deploy-billing-flag branch from ecbbffa to bf4ddcf Compare June 11, 2026 16:29
Comment thread web/apps/dashboard/lib/flags/plumbing.ts Outdated

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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_ON with FLAGS_LOCAL_OVERRIDESplumbing.ts now parses a comma-separated list of flag keys into a Set and forces only those keys on, instead of resolving every flag to true. The override layer wraps the base adapter ({ ...base, decide }) and falls through to base.decide for 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.warn was added on the fallback path.
  • Updated .env.example — documents FLAGS_LOCAL_OVERRIDES with a worked example, replacing the old FLAGS_LOCAL_ALL_ON block.

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.

Pullfrog  | View workflow run | Using Claude Opus𝕏

Flo4604 added 3 commits June 15, 2026 15:04
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
Comment thread web/apps/dashboard/lib/flags/index.ts

@chronark chronark left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you go figure it out with oz :D

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.

3 participants