Skip to content

refactor(org-profile): remove Usage Statistics from organization profile page#1260

Merged
jeanduplessis merged 4 commits intomainfrom
remove-usage-stats-from-profile
Mar 20, 2026
Merged

refactor(org-profile): remove Usage Statistics from organization profile page#1260
jeanduplessis merged 4 commits intomainfrom
remove-usage-stats-from-profile

Conversation

@kilo-code-bot
Copy link
Contributor

@kilo-code-bot kilo-code-bot bot commented Mar 19, 2026

Summary

  • Remove the Usage Statistics card (OrganizationUsageSummaryCard) from the organization profile page (OrganizationDashboard), which is the default landing page after login. The usageStats tRPC endpoint queries microdollar_usage with a 30-day SUM/COUNT aggregation on every page load, adding unnecessary database pressure for the most-visited page.
  • The card and its backing hook/endpoint are preserved because the admin dashboard still uses them.
  • Add separate Input Tokens and Output Tokens metric cards to the dedicated usage details page (/organizations/[id]/usage-details), which previously only showed a combined "Total Tokens" figure. This ensures the token breakdown data that was on the profile page is still accessible.
  • Supporting type, hook, formatter, and filter changes across the usage-details module to handle the two new metric keys (input_tokens, output_tokens).

Verification

  • tsgo --noEmit --incremental false — passes with no errors
  • eslint on all 8 changed files — no warnings or errors
  • prettier --check — all files formatted

Visual Changes

Before After
Organization profile page shows a "Usage Statistics" card with Total Spent, Total Requests, Total Input Tokens, Total Output Tokens Card removed; profile page no longer makes the usageStats query
Usage details page shows 5 metric cards: Total Cost, Total Requests, Avg Cost per Request, Total Tokens, Active Users 7 metric cards: adds separate Input Tokens and Output Tokens cards

Reviewer Notes

  • The OrganizationUsageSummaryCard component, useOrganizationUsageStats hook, UsageStatsSchema, and the usageStats tRPC procedure are intentionally kept because OrganizationAdminDashboard still renders the card.
  • The metric card grid on the usage details page changed from lg:grid-cols-5 to lg:grid-cols-4 xl:grid-cols-7 to accommodate 7 cards.
  • The new input/output token metrics reuse the existing timeseries data — no new API calls are introduced.

@kilo-code-bot
Copy link
Contributor Author

kilo-code-bot bot commented Mar 19, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • src/components/organizations/usage-details/hooks/useProcessedMetrics.ts

Reviewed by gpt-5.4-20260305 · 109,354 tokens

kilo-code-bot bot and others added 3 commits March 20, 2026 08:12
…ion profile page

Move input/output token breakdown to the dedicated usage details page,
reducing database load on the default landing page after login.
Prevents chartSplitBy.tokenType from getting stuck in a true state when
the user switches from Total Tokens to Input/Output Tokens or any other
metric, since the Input/Output toggle only renders for the tokens metric.
Replace nested ternary for metric key conversion with a lookup map,
use satisfies instead of as casts, and remove redundant alias/props.
@jeanduplessis jeanduplessis force-pushed the remove-usage-stats-from-profile branch from 6eed4c8 to 123465d Compare March 20, 2026 06:14
The summary card was averaging per-bucket averages (arithmetic mean), which
diverges from the true overall average when request volume differs across
time buckets. Now computes totalCost / totalRequests directly.
@jeanduplessis jeanduplessis merged commit 1253e3f into main Mar 20, 2026
18 checks passed
@jeanduplessis jeanduplessis deleted the remove-usage-stats-from-profile branch March 20, 2026 15:42
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.

2 participants