fix(analytics): expose flat-rate estimates on cost dashboards - #11460
Draft
xiaoyaner0201 wants to merge 3 commits into
Draft
fix(analytics): expose flat-rate estimates on cost dashboards#11460xiaoyaner0201 wants to merge 3 commits into
xiaoyaner0201 wants to merge 3 commits into
Conversation
Signed-off-by: 千乘妍 (Xiaoyaner) <xiaoyaner0201@users.noreply.github.com>
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
Fixes #11459.
Claude Code (
claude/cc) is correctly classified as a flat-rate subscription, so the analytics API reports$0by default. The Costs and Analytics dashboards are estimate-oriented views, but neither originally had a token-price-equivalent view of subscription consumption.This change preserves both meanings:
$0for flat-rate subscriptions);/dashboard/costsand/dashboard/analyticsexplicitly request token-price-equivalent estimates;The defect is confirmed on the latest
release/v3.8.50line. This PR targets the activerelease/v3.8.51branch because #11439 freezes v3.8.50.Changes
includeFlatRateEstimates=true; omitted, false, and unknown values retain the existing$0behavior.includesFlatRateEstimatesin the response.Non-goals
Testing
node --import tsx/esm --test tests/integration/integration-wiring.test.ts tests/unit/usage-analytics-route.test.ts tests/unit/flat-rate-cost-5552.test.ts tests/unit/usage-analytics.test.ts tests/unit/db-usageanalytics-split.test.ts tests/unit/db-usageanalytics-sources-split.test.ts— 148 tests, 144 passed / 4 skipped / 0 failednpm run typecheck:corenpx prettier --checkon the changed filesnpm run check:changelog-integritynpm run check:file-sizegit diff --checkReview notes
The query parameter is deliberately opt-in rather than changing the analytics default. This keeps compatibility with #5552 / #10773 while restoring analytical usefulness on the two dashboards that label cost as an estimate.