Skip to content

feat: add virtual key rankings dimension to dashboard - #4427

Merged
akshaydeo merged 1 commit into
devfrom
06-16-feat_add_virtual_key_rankings_tab_in_dashboard
Jun 19, 2026
Merged

feat: add virtual key rankings dimension to dashboard#4427
akshaydeo merged 1 commit into
devfrom
06-16-feat_add_virtual_key_rankings_tab_in_dashboard

Conversation

@impoiler

Copy link
Copy Markdown
Contributor

Summary

Adds "Virtual Key" as a new ranking dimension across the backend and dashboard UI, allowing users to view and export usage rankings broken down by virtual key.

Changes

  • Added RankingDimensionVirtualKey constant and registered it in ValidRankingDimensions and dimensionColumns with virtual_key_id and virtual_key_name column mappings
  • Added virtual_key to the RankingDimension TypeScript union type
  • Added virtualKeyRankingsData to the DashboardData interface and initialized it as null in the dashboard state
  • Added a "Virtual Key Rankings" tab to the dashboard with a DimensionRankingsTabView component wired to the virtual_key dimension
  • Added virtual-key-rankings to the ExportTab type and included it in CSV export logic via dimensionRankingsToCSV

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

  1. Navigate to the dashboard and confirm a "Virtual Key Rankings" tab appears alongside the existing User, Customer, and Business Unit rankings tabs.
  2. Select the Virtual Key Rankings tab and verify rankings data loads correctly with virtual key names and IDs.
  3. Export the dashboard data (CSV) and confirm a virtual-key-rankings sheet/section is included with the correct columns.
  4. Verify the "Export All" option includes virtual key rankings data.
# Core/Transports
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build

Screenshots/Recordings

Add before/after screenshots of the dashboard tab bar showing the new Virtual Key Rankings tab.

Breaking changes

  • Yes
  • No

Related issues

Security considerations

Virtual key IDs and names are treated the same as other ranking dimension identifiers. No additional PII or secrets exposure beyond what already exists for user and customer rankings.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@impoiler, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 5 minutes and 11 seconds. Learn how PR review limits work.

To continue reviewing without waiting, enable usage-based billing in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f821ae8-d43d-4f43-a823-3717daf97e73

📥 Commits

Reviewing files that changed from the base of the PR and between 6403ad8 and f5870e3.

📒 Files selected for processing (4)
  • framework/logstore/tables.go
  • ui/app/workspace/dashboard/page.tsx
  • ui/app/workspace/dashboard/utils/exportUtils.ts
  • ui/lib/types/logs.ts
📝 Walkthrough

Walkthrough

Extends the dimension rankings system with a new virtual_key dimension. The backend registers RankingDimensionVirtualKey as a constant, adds it to validation, and maps it to database columns. The frontend extends the RankingDimension type, adds the tab UI, export contracts, and CSV generation logic.

Changes

Virtual Key Ranking Dimension

Layer / File(s) Summary
Backend: constant, validation, and DB columns
framework/logstore/tables.go
Adds RankingDimensionVirtualKey = "virtual_key" constant, registers it in ValidRankingDimensions, and maps it to virtual_key_id/virtual_key_name in dimensionColumns.
Frontend type contract and export data shape
ui/lib/types/logs.ts, ui/app/workspace/dashboard/utils/exportUtils.ts
Extends RankingDimension with "virtual_key", adds virtualKeyRankingsData to DashboardData, adds "virtual-key-rankings" to ExportTab, and adds CSV section generation for the new tab.
Dashboard tab UI wiring and PDF export
ui/app/workspace/dashboard/page.tsx
Adds virtualKeyRankingsRef, includes it in allRefs and getDashboardData(), registers the DOM section id for PDF export, and mounts the TabsTrigger and DimensionRankingsTabView TabsContent for virtual-key-rankings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • maximhq/bifrost#3766: Introduced the original dimension-rankings system (RankingDimension type, backend allowlist/mapping, and dashboard tab flow) that this PR extends with the virtual_key dimension.
  • maximhq/bifrost#3797: Refactored DimensionRankingsTabView refs and export aggregation in page.tsx, which is the exact wiring pattern this PR replicates for the new virtual key tab.

Suggested reviewers

  • akshaydeo
  • danpiths

Poem

🐰 A virtual key, once lost in the dark,
Now ranks in the dashboard — what a new spark!
The backend maps columns, the frontend wires refs,
CSV exports hum along, no more regrets.
Every dimension finds its place in the chart ~
Hop hop, virtual_key, you're a work of art! 🗝️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding virtual key as a new ranking dimension to the dashboard.
Description check ✅ Passed The description follows the template with all key sections completed: summary, changes, type of change, affected areas, testing steps, security considerations, and checklist items addressed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 06-16-feat_add_virtual_key_rankings_tab_in_dashboard

Comment @coderabbitai help to get the list of available commands and usage tips.

@impoiler
impoiler force-pushed the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch from e1fd621 to e194038 Compare June 16, 2026 11:57
@impoiler
impoiler force-pushed the 06-16-chore_ui_dependency_updates_for_npn_audit branch from c042391 to ed9fb68 Compare June 16, 2026 11:57
@impoiler
impoiler force-pushed the 06-16-chore_ui_dependency_updates_for_npn_audit branch from ed9fb68 to fd184f7 Compare June 16, 2026 12:18
@impoiler
impoiler force-pushed the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch from e194038 to efbea28 Compare June 16, 2026 12:18
@impoiler
impoiler force-pushed the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch from efbea28 to f0a0f78 Compare June 17, 2026 14:04
@impoiler
impoiler force-pushed the 06-16-chore_ui_dependency_updates_for_npn_audit branch from 579ea94 to 77fdd10 Compare June 18, 2026 06:38
@impoiler
impoiler force-pushed the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch 2 times, most recently from 627f692 to f6d72a1 Compare June 18, 2026 07:12
@impoiler
impoiler force-pushed the 06-16-chore_ui_dependency_updates_for_npn_audit branch from 00dff79 to 869d671 Compare June 18, 2026 08:37
@impoiler
impoiler force-pushed the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch from f6d72a1 to 216c340 Compare June 18, 2026 08:37
@impoiler
impoiler marked this pull request as ready for review June 18, 2026 08:51
@coderabbitai
coderabbitai Bot requested review from akshaydeo and danpiths June 18, 2026 08:52
@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the change is additive, reuses well-tested generic infrastructure, and touches no critical paths.

All four changed files follow the established per-dimension pattern exactly. The virtual_key_id/virtual_key_name columns already exist in logs and mv_logs_hourly, so no schema migration is needed and both the raw-table and matview query paths work without modification. The only gap is that the error-message strings in logging.go omit virtual_key from the documented valid values list, which has no runtime impact.

transports/bifrost-http/handlers/logging.go — error message strings need to include virtual_key in the valid-values list.

Important Files Changed

Filename Overview
framework/logstore/tables.go Adds RankingDimensionVirtualKey constant, registers it in ValidRankingDimensions, and maps virtual_key_id/virtual_key_name in dimensionColumns. Both columns exist in the logs schema and mv_logs_hourly matview, and the generic query infrastructure handles them correctly.
ui/app/workspace/dashboard/page.tsx Adds virtualKeyRankingsRef, initializes virtualKeyRankingsData: null, inserts the "Virtual Key Rankings" tab trigger and content, and registers the section ID for PDF export. All wiring follows the existing per-dimension pattern.
ui/app/workspace/dashboard/utils/exportUtils.ts Adds virtualKeyRankingsData to DashboardData, virtual-key-rankings to ExportTab, and the corresponding getCSVSections branch — mirrors the pattern used for every other dimension ranking.
ui/lib/types/logs.ts Extends RankingDimension union type with "virtual_key" to match the new backend constant. Minimal, correct change.

Reviews (7): Last reviewed commit: "feat: add Virtual Key Rankings tab in da..." | Re-trigger Greptile

Comment thread ui/app/workspace/dashboard/page.tsx
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 18, 2026
@impoiler
impoiler force-pushed the 06-16-chore_ui_dependency_updates_for_npn_audit branch 2 times, most recently from befbab1 to f5082fa Compare June 18, 2026 17:11
@impoiler
impoiler force-pushed the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch 2 times, most recently from cfbed3e to c32fc56 Compare June 18, 2026 17:39
@impoiler
impoiler force-pushed the 06-16-chore_ui_dependency_updates_for_npn_audit branch from f5082fa to 20f4396 Compare June 18, 2026 17:39
@impoiler
impoiler force-pushed the 06-16-chore_ui_dependency_updates_for_npn_audit branch from 20f4396 to efb3ba1 Compare June 19, 2026 06:43
@impoiler
impoiler force-pushed the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch from c32fc56 to 6403ad8 Compare June 19, 2026 06:43
@impoiler
impoiler force-pushed the 06-16-chore_ui_dependency_updates_for_npn_audit branch from efb3ba1 to bd87d8e Compare June 19, 2026 06:46
@impoiler
impoiler force-pushed the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch from 6403ad8 to 5c1099c Compare June 19, 2026 06:46
@impoiler
impoiler force-pushed the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch from 5c1099c to f5870e3 Compare June 19, 2026 06:51
@impoiler
impoiler force-pushed the 06-16-chore_ui_dependency_updates_for_npn_audit branch from bd87d8e to 8f7af65 Compare June 19, 2026 06:51

akshaydeo commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Jun 19, 6:55 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 19, 6:59 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo changed the base branch from 06-16-chore_ui_dependency_updates_for_npn_audit to graphite-base/4427 June 19, 2026 06:58
@akshaydeo
akshaydeo changed the base branch from graphite-base/4427 to dev June 19, 2026 06:59
@akshaydeo
akshaydeo dismissed coderabbitai[bot]’s stale review June 19, 2026 06:59

The base branch was changed.

@akshaydeo
akshaydeo merged commit 60b06d8 into dev Jun 19, 2026
11 checks passed
@akshaydeo
akshaydeo deleted the 06-16-feat_add_virtual_key_rankings_tab_in_dashboard branch June 19, 2026 06:59
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