feat(dashboard): add model/status/account/api-key filters to usage details tab
- Add apiKey column to requestDetails (schema v2 + migration 002) - Persist masked API key via buildRequestDetail across chatCore handlers - Add getRequestDetails apiKey filter + distinct models/apiKeys/statuses helpers - New /api/usage/filters endpoint returning grouped connections per provider - Group account dropdown by provider using <optgroup>; add Status column with success/error badge to the details table Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This commit is contained in:
@@ -57,11 +57,21 @@ export function extractUsageFromResponse(responseBody) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Mask API keys before they reach the requestDetails data blob / DB column.
|
||||
// Only the prefix is kept — enough to distinguish keys without leaking them.
|
||||
export function maskApiKey(key) {
|
||||
if (!key || typeof key !== "string") return undefined;
|
||||
const trimmed = key.trim();
|
||||
if (trimmed.length <= 8) return trimmed.charAt(0) + "***";
|
||||
return trimmed.slice(0, 8) + "***";
|
||||
}
|
||||
|
||||
export function buildRequestDetail(base, overrides = {}) {
|
||||
return {
|
||||
provider: base.provider || "unknown",
|
||||
model: base.model || "unknown",
|
||||
connectionId: base.connectionId || undefined,
|
||||
apiKey: maskApiKey(base.apiKey),
|
||||
timestamp: new Date().toISOString(),
|
||||
latency: base.latency || { ttft: 0, total: 0 },
|
||||
tokens: base.tokens || { prompt_tokens: 0, completion_tokens: 0 },
|
||||
|
||||
Reference in New Issue
Block a user