fix(usage): aggregate org dashboard breakdowns in one scan#300
Merged
mgoldsborough merged 3 commits intoJun 2, 2026
Conversation
7a62191 to
b2cccd2
Compare
Allow usage reports to request multiple breakdown dimensions from a single aggregation pass, then update the org usage dashboard to fetch user and day breakdowns with one usage__report call. Refs NimbleBrainInc#286
Import UsageReportOutput in the usage platform-source test instead of redeclaring the report shape, and clarify the aggregator comment for multi-dimension breakdowns.
b2cccd2 to
811ed21
Compare
Collapse the four duplicated declarations of the breakdown-dimension list (aggregator type, aggregator runtime guard, schema StringEnum, schema type) into one canonical USAGE_GROUP_BYS array in schemas/usage.ts. The TypeBox enum, the UsageGroupBy type, and the aggregator's isUsageGroupBy guard all derive from it, so a new dimension is added in exactly one place.
811ed21 to
76de58e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
aggregateUsage()so one usage report can compute multiple breakdown dimensions, includinguserandday, from a single conversation scan.breakdownsto the usage report contract while preserving the existingbreakdownfield for single-dimension/backward-compatible callers.usage__reportcall for both the user table and daily cost chart.Verification
bun test test/unit/conversation/usage-aggregator.test.tsbun test test/unit/tools/platform/usage-source.test.tsbun run checkbun run format:checkbun run lintbun run verify