Skip to content

Add FLAGS_EVALUATION metric#401

Draft
luismeyer wants to merge 2 commits into
mainfrom
codex/add-aggregated-evaluation-metrics-v1
Draft

Add FLAGS_EVALUATION metric#401
luismeyer wants to merge 2 commits into
mainfrom
codex/add-aggregated-evaluation-metrics-v1

Conversation

@luismeyer

Copy link
Copy Markdown
Member

Adds aggregated flag-evaluation telemetry: a new FLAGS_EVALUATION ingest event that buckets evaluations by flag/variant/reason/clientName and reports a count per bucket, alongside a clientName option for the Vercel Flags client. The usage tracker is refactored into dedicated event types (flags-config-read, flags-evaluation) with a BetterWeakMap for per-request-context dedup, and the ingest path gains retry/aggregation handling.

It also hardens batch flushing: the scheduled flush now awaits the full ingest send (incl. retries) so the waitUntil promise no longer resolves before in-flight batches complete, a 60s max flush window is added alongside the existing 5s idle window so batches still flush under continuous traffic, and shutdown() drains any pending flush instead of orphaning it. Repeated evaluations of the same bucket increment the aggregated count without counting toward the 50-event batch threshold. Covered by new black-box, scheduler, and usage-tracker tests; docs and changesets updated.

🤖 Generated with Claude Code

@luismeyer luismeyer marked this pull request as draft June 16, 2026 15:18
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
flags-playground Ready Ready Preview, Comment, Open in v0 Jun 17, 2026 4:24pm
flags-sdk-dev Ready Ready Preview, Comment, Open in v0 Jun 17, 2026 4:24pm
flags-sdk-snippets Ready Ready Preview, Comment, Open in v0 Jun 17, 2026 4:24pm
flags-sdk-sveltekit-snippets Ready Ready Preview, Comment, Open in v0 Jun 17, 2026 4:24pm
shirt-shop Ready Ready Preview, Comment, Open in v0 Jun 17, 2026 4:24pm
shirt-shop-api Ready Ready Preview, Comment, Open in v0 Jun 17, 2026 4:24pm

Comment thread packages/vercel-flags-core/src/utils/usage-tracker.ts
Comment thread packages/vercel-flags-core/src/utils/scheduler.ts
Comment thread packages/vercel-flags-core/src/utils/usage/flags-evaluation.ts
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