feat(usage): API key name in Recent Requests + Usage by Combo tracking#48
Closed
mahdiwafy wants to merge 5 commits into
Closed
feat(usage): API key name in Recent Requests + Usage by Combo tracking#48mahdiwafy wants to merge 5 commits into
mahdiwafy wants to merge 5 commits into
Conversation
…mbo tracking - Add 'Key' column to Recent Requests card showing API key name - Add comboName field to usageHistory DB table (migration 004) - Wire comboName through entire request pipeline: chat.js → chatCore → streamingHandler/nonStreamingHandler → requestDetail → usageRepo - Add byCombo aggregation in usageDaily and getUsageStats - Add 'Usage by Combo' option in usage table selector - Include apiKey + keyName in recentRequests API response Files changed: - open-sse/handlers/chatCore.js: accept comboName param, add to sharedCtx - open-sse/handlers/chatCore/requestDetail.js: pass comboName to saveRequestUsage - open-sse/handlers/chatCore/streamingHandler.js: pass comboName to saveUsageStats - open-sse/handlers/chatCore/nonStreamingHandler.js: pass comboName to saveUsageStats - src/sse/handlers/chat.js: pass comboName through handleSingleModelChat - src/lib/db/migrations/004-add-combo-name-column.js: new migration - src/lib/db/migrations/index.js: register migration 004 - src/lib/db/schema.js: add comboName column - src/lib/db/repos/usageRepo.js: comboName in INSERT, SELECT, aggregation, recentRequests - src/shared/components/UsageStats.js: Key column in RecentRequests, Usage by Combo table
Owner
|
open-sse/handlers/chatCore/sseToJsonHandler.js is skipped. comboName is not destructured in handleForcedSSEToJson and missing from saveUsageStats calls (line 142 & 218). fix sseToJsonHandler.js to pass comboName down, then request re-review. |
Author
|
Fixed. |
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
Adds API key name column to the Recent Requests card and introduces per-combo usage tracking.
Changes
Recent Requests — API Key column
The Recent Requests card now shows which API key was used for each request. Previously only showed: Status | Model | In/Out | When. Now shows: Status | Key | Model | In/Out | When.
Usage by Combo — new table view
comboNamecolumn inusageHistorytable (migration 004)comboNameflows through the entire request pipeline:chat.js→chatCore→streamingHandler/nonStreamingHandler→requestDetail→saveRequestUsagebyComboaggregation inusageDailyandgetUsageStats()Files changed (11 files, +108/-20)
open-sse/handlers/chatCore.jscomboNameparam, add tosharedCtxopen-sse/handlers/chatCore/requestDetail.jscomboNametosaveRequestUsageopen-sse/handlers/chatCore/streamingHandler.jscomboNametosaveUsageStatsopen-sse/handlers/chatCore/nonStreamingHandler.jscomboNametosaveUsageStatssrc/sse/handlers/chat.jscomboNamethroughhandleSingleModelChatsrc/lib/db/migrations/004-add-combo-name-column.jscomboName TEXTcolumnsrc/lib/db/migrations/index.jssrc/lib/db/schema.jscomboNameto schemasrc/lib/db/repos/usageRepo.jscomboNamein INSERT, SELECT, aggregation, recentRequestssrc/shared/components/UsageStats.jsMigration
Migration 004 adds
comboName TEXTcolumn tousageHistory. Non-breaking — existing rows get NULL, new rows populate automatically when request comes through a combo.Testing
keyNameandcomboNamefields inrecentRequestsbyApiKeyaggregation unaffected (33 entries verified)byComboaggregation works (0 entries for legacy data, will populate for new combo requests)