zen: track session in usage

This commit is contained in:
Frank
2026-02-22 18:41:34 -05:00
parent ee754c46f9
commit 5712cff5c4
187 changed files with 87618 additions and 47656 deletions

View File

@@ -67,7 +67,7 @@ export const PaymentTable = mysqlTable(
timeRefunded: utc("time_refunded"),
enrichment: json("enrichment").$type<
| {
type: "subscription"
type: "subscription" | "lite"
couponID?: string
}
| {
@@ -93,8 +93,9 @@ export const UsageTable = mysqlTable(
cacheWrite1hTokens: int("cache_write_1h_tokens"),
cost: bigint("cost", { mode: "number" }).notNull(),
keyID: ulid("key_id"),
sessionID: varchar("session_id", { length: 30 }),
enrichment: json("enrichment").$type<{
plan: "sub"
plan: "sub" | "byok" | "lite"
}>(),
},
(table) => [...workspaceIndexes(table), index("usage_time_created").on(table.workspaceID, table.timeCreated)],