feat(billing): add usage analytics charts and summary totals

Add daily usage trend charts with multi-metric toggles, overview vs user
analysis views, date-range filtering, and usage summary API for interval
and all-time totals.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-31 11:28:47 +08:00
parent 2a1c221bb3
commit 2550b3b323
9 changed files with 1843 additions and 68 deletions
+39
View File
@@ -247,6 +247,37 @@ export type UsageRecord = {
createdAt: number;
};
export type UsageStatsBucket = {
day: string;
count: number;
inputTokens: number;
outputTokens: number;
costCents: number;
};
export type UsageTotals = {
count: number;
inputTokens: number;
outputTokens: number;
costCents: number;
};
export type UsageRangeTotals = UsageTotals & {
startAt: number;
endAt: number;
};
export type UsageSummaryResult = {
range: UsageRangeTotals | null;
allTime: UsageTotals;
};
export type UsageStatsResult = {
buckets: UsageStatsBucket[];
startAt: number;
endAt: number;
};
export type LedgerEntry = {
id: number;
userId: string;
@@ -343,6 +374,14 @@ export type MemoryV2AdminConfigResponse = {
updatedBy: string | null;
};
export type MemoryV2ConfigRuntimeState = {
source: string;
updatedAt: number | null;
updatedBy: string | null;
fingerprint?: string;
overrides: Record<string, string>;
};
export type MemoryV2RuntimeStatusResponse = {
ok: boolean;
checkedAt?: number;