feat(usage): break usage down by request type, project, environment or SDK - #8343
Draft
talissoncosta wants to merge 10 commits into
Draft
feat(usage): break usage down by request type, project, environment or SDK#8343talissoncosta wants to merge 10 commits into
talissoncosta wants to merge 10 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
talissoncosta
force-pushed
the
feat/usage-breakdown-8186
branch
from
August 21, 2026 16:36
6a7bc06 to
dbf1eed
Compare
talissoncosta
force-pushed
the
feat/usage-breakdown-8186
branch
from
August 21, 2026 22:23
80bb450 to
35abec8
Compare
Request type sums the four billable fields; SDK groups by user agent. Both come from the response the charts already fetch, so neither costs a request. Usage from before user agents were captured is grouped as Unknown rather than dropped, otherwise the rows would not sum to the total shown above them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Carries no plan limit: a single request type or project has no allowance of its own, so a limit line would invite a comparison that means nothing. Each bar is scaled to the largest row while the percentage is the share of the total, because "which is biggest" and "how much of my usage is this" are different questions and one bar cannot answer both. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The endpoint filters by project and environment rather than grouping by them, so a breakdown needs one request per key. Those cannot be a loop of hooks: the key list starts empty and fills once loaded, and React requires the same hooks in the same order every render. Each scope gets a component that fetches its own total and reports it up. Rows appear as each request lands rather than waiting for the slowest. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributes to #8186 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two defects in the per-scope breakdown: - totals were keyed by name, so two projects sharing one would overwrite each other. They key on the scope now - totals were never cleared, so changing the period or project left the previous numbers on screen while the new requests were in flight, with nothing to mark them stale. They reset when the query identity changes The section also waits for every scope rather than filling in, because a partial list ranks wrongly and ranking is the point. Extracts shared/BarTrack from UsageBar and UsageBreakdownRow, which had near-identical markup and each hand-wrote the same transition and reduced-motion guard. Rows carry the colour each request type has always had on the usage page. Also: the barrel exports the container, so callers stop reaching past it; UsageBreakdownList replaces a function-in-render; skipToken replaces a cast; and the row's flex, spacing and border move to utilities. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
BarTrack led with the noun and named the groove. Everything else here is <Noun>Bar: ButterBar, CalloutBar, DistributionBar, UsageBar. Not ProgressBar: half its callers compare values against the largest row rather than tracking a task, which is why the progressbar semantics are optional rather than built in. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ARIA reserves progressbar for a task advancing and meter for a value inside a known range. Usage against a plan allowance is the second, so a screen reader was told a task was underway. Changes what ProjectUsageTab and EnvironmentOverrideUsage announce as well, since they share the bar. No selectors depend on the old role. Note that meter has patchier assistive-tech support than progressbar, which is the trade being taken deliberately. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
They were the legend for a stacked chart that is no longer there. Without it the colour distinguished nothing the adjacent label and the bar length did not already, and only request-type rows had one, so the same section looked colour-coded on one dimension and plain on the next. A categorical palette is still available in CHART_COLOURS if a chart ever needs one; it does not have to live on a breakdown row to be reachable. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three of them, so they move into components/ and drop the prefix the path already supplies: Row, List, ScopeTotal. The pair also matches UsageDashboard now. The bare name is the container, so the folder, the file and the default export agree, and callers stop reaching past the barrel for it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
talissoncosta
force-pushed
the
feat/usage-breakdown-8186
branch
from
August 22, 2026 14:07
35abec8 to
db6b895
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.
Reviewing this
Stacked on #8320, so review that first. This diff is only the breakdown section.
Start with
UsageBreakdownContainer.tsxfor how each dimension gets its data. The one non-obvious piece isUsageScopeTotal.tsx, explained inline.docs/if required so people know about the feature.Changes
Contributes to #8186
A section under the chart showing where the usage came from, with a menu for request type, project, environment or SDK. Ranked rows, no plan limit: a single request type has no allowance of its own, so a limit line there would mean nothing.
Totals only, deliberately. The chart above answers "where am I heading against my plan", and that is where the projection lands in #8188. A second chart here would compete with it.
group_bywould collapse that into one request, and would also remove the wait: rows only rank correctly once every scope has answeredOn whether this replaces the old tabs. It replaces them functionally: By Endpoint is now By request type, and By SDK is a dimension. The sidebar and the two old containers stay for now because they are what renders when
usage_dashboardis off, which is everywhere today. Removing them, and retiringsdk_usage_chartswith them, belongs to the flag-removal PR.Two changes reach outside this feature:
shared/ValueBaris extracted fromUsageBar, which had the same track-and-fill markup and duplicated its transition.ProjectUsageTabandEnvironmentOverrideUsagerender it unchangedrole="meter"rather thanrole="progressbar". ARIA reserves progressbar for a task advancing, and usage against an allowance is a value in a known range. Meter has patchier screen-reader support, so it is a deliberate tradeHow did you test this code?
11 unit tests over the derivations, including same-named projects and unattributed SDK usage.
With
usage_dashboardon:Project and environment need an organisation with several of each, so use the preview deployment rather than localhost. Every state is also in Storybook under
Pages > Usage Dashboard > Components > UsageBreakdown.