feat: harden analytics dashboard

This commit is contained in:
2026-05-27 15:19:31 +08:00
parent 5e0ca6a504
commit 356039d9cf
34 changed files with 1424 additions and 879 deletions

View File

@@ -1,4 +1,5 @@
import type { TranslationKey } from "@/lib/i18n";
import { quotaToUsd } from "@/lib/metrics";
export type DetailStatKey =
| "calls"
@@ -32,7 +33,7 @@ export function getDetailStats(data: DetailStatsData): DetailStatItem[] {
return [
{ key: "calls", labelKey: "dash.totalCalls", value: data.calls },
{ key: "total_tokens", labelKey: "th.totalToken", value: data.total_tokens, format: "tokens" },
{ key: "quota", labelKey: "th.cost", value: data.quota / 500000, format: "usd" },
{ key: "quota", labelKey: "th.cost", value: quotaToUsd(data.quota), format: "usd" },
{ key: "prompt_tokens", labelKey: "th.input", value: data.prompt_tokens, format: "tokens" },
{ key: "completion_tokens", labelKey: "th.output", value: data.completion_tokens, format: "tokens" },
{ key: "cache_creation_tokens", labelKey: "th.cacheCreation", value: data.cache_creation_tokens, format: "tokens" },