From 394b5ac5fdd0a177363b4fcc7ec09fb3aceb2ac1 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Thu, 20 Aug 2026 00:43:44 -0400 Subject: [PATCH] feat(stats): combine free and go usage (#43577) Co-authored-by: thdxr --- packages/stats/core/src/domain/geo.ts | 2 +- packages/stats/core/src/domain/home.ts | 10 +++++++--- packages/stats/core/src/domain/model.ts | 2 +- packages/stats/core/src/domain/provider.ts | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/stats/core/src/domain/geo.ts b/packages/stats/core/src/domain/geo.ts index b75e08a34b..9da03b54ca 100644 --- a/packages/stats/core/src/domain/geo.ts +++ b/packages/stats/core/src/domain/geo.ts @@ -93,7 +93,7 @@ export class GeoStatRepo extends Context.Service { await queryRows(`select period_key, updated_at, tier, provider, model, sessions, unique_users, input_tokens, output_tokens, reasoning_tokens, cache_read_tokens, total_tokens, input_cost_microcents, output_cost_microcents, total_cost_microcents from model_stat where grain = 'day' and client = 'all' and source = 'all' - and tier in ('Go', 'go') order by period_key`) + and tier in ('Free', 'free', 'Go', 'go') order by period_key`) ).map((row) => ({ periodKey: stringValue(row.period_key), updatedAt: dateValue(row.updated_at), @@ -238,7 +238,8 @@ async function listModelDaily(): Promise { async function listProviderDaily(): Promise { return ( await queryRows(`select period_key, updated_at, tier, provider, total_tokens from provider_stat - where grain = 'day' and client = 'all' and source = 'all' and tier in ('Go', 'go') order by period_key`) + where grain = 'day' and client = 'all' and source = 'all' + and tier in ('Free', 'free', 'Go', 'go') order by period_key`) ).map((row) => ({ periodKey: stringValue(row.period_key), updatedAt: dateValue(row.updated_at), @@ -259,7 +260,8 @@ async function listGeoDaily(opts?: { provider?: string; model?: string }): Promi return ( await queryRows( `select period_key, updated_at, tier, provider, model, country, continent, total_tokens from geo_stat - where grain = 'day' and client = 'all' and source = 'all' and tier in ('Go', 'go') ${scope} order by period_key`, + where grain = 'day' and client = 'all' and source = 'all' + and tier in ('Free', 'free', 'Go', 'go') ${scope} order by period_key`, params, ) ).map((row) => ({ @@ -735,6 +737,7 @@ function rowsForProduct( end: number, ) { const windowRows = rows.filter((row) => row.periodStart >= start && row.periodStart < end) + if (product === "Go") return windowRows.filter((row) => row.tier === "Free" || row.tier === "Go") if (product !== "All Users") return windowRows.filter((row) => row.tier === product) const allRows = windowRows.filter((row) => row.tier === "all") @@ -947,6 +950,7 @@ function normalizeGeoRow(row: GeoStatMetric): GeoMetricRow[] { function normalizeTier(value: string) { const normalized = value.toLowerCase() if (normalized === "paid" || normalized === "zen") return "Zen" + if (normalized === "free") return "Free" if (normalized === "go") return "Go" if (normalized === "enterprise") return "Enterprise" if (normalized === "all") return "all" diff --git a/packages/stats/core/src/domain/model.ts b/packages/stats/core/src/domain/model.ts index ebaf93e1c8..b5d5abd406 100644 --- a/packages/stats/core/src/domain/model.ts +++ b/packages/stats/core/src/domain/model.ts @@ -211,7 +211,7 @@ function modelDailyScope() { eq(modelStat.grain, "day"), eq(modelStat.client, "all"), eq(modelStat.source, "all"), - inArray(modelStat.tier, ["Go", "go"]), + inArray(modelStat.tier, ["Free", "free", "Go", "go"]), ) } diff --git a/packages/stats/core/src/domain/provider.ts b/packages/stats/core/src/domain/provider.ts index 1b177e8e83..4c891a685c 100644 --- a/packages/stats/core/src/domain/provider.ts +++ b/packages/stats/core/src/domain/provider.ts @@ -69,7 +69,7 @@ export class ProviderStatRepo extends Context.Service