From 4d120d491d4d116185013774a21663ca77d43b73 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Thu, 22 Oct 2026 05:12:36 -0500 Subject: [PATCH] fix(stats): include Go Plus usage (#58075) --- packages/stats/core/src/domain/inference.test.ts | 4 ++-- packages/stats/core/src/domain/inference.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/stats/core/src/domain/inference.test.ts b/packages/stats/core/src/domain/inference.test.ts index 5bae65c4d5e..076c24ec9f9 100644 --- a/packages/stats/core/src/domain/inference.test.ts +++ b/packages/stats/core/src/domain/inference.test.ts @@ -304,7 +304,7 @@ describe("inference stat normalization", () => { expect(queries[6]).toContain("'2026-08-12' AS period_key") expect(queries[0]).toContain('FROM "inference"."generation"') expect(queries[0]).toContain("event_type = 'generation.completed'") - expect(queries[0]).toContain("AND (product = 'go' OR (lower(COALESCE(model_tier, '')) = 'free'") + expect(queries[0]).toContain("AND (product IN ('go', 'go-plus') OR (lower(COALESCE(model_tier, '')) = 'free'") expect(queries[0]).toContain("COALESCE(NULLIF(lower(model_tier), ''), '') AS raw_tier") expect(queries[0]).toContain("WHEN lower(COALESCE(raw_tier, '')) = 'free'") expect(queries[0]).toContain("regexp_replace(NULLIF(route_model, ''), '^.*/', '')") @@ -362,7 +362,7 @@ describe("inference stat normalization", () => { expect(query).toContain("= 'deepseek-flash' THEN 'deepseek-v4.1-flash'") }) expect(queries.map((query) => query.cohortDates)).toEqual([["2026-08-10"], ["2026-08-17"]]) - expect(queries[0]?.query).toContain("AND product = 'go'") + expect(queries[0]?.query).toContain("AND product IN ('go', 'go-plus')") expect(queries[0]?.query).toContain("AND lower(model) NOT IN ('alpha-gpt-next')") expect(queries[0]?.query).toContain( "CASE\n WHEN lower(model) IN ('exo', 'omen-alpha', 'union-alpha') THEN 'unknown'\n", diff --git a/packages/stats/core/src/domain/inference.ts b/packages/stats/core/src/domain/inference.ts index 2ca6747473b..ba7a56dcc1d 100644 --- a/packages/stats/core/src/domain/inference.ts +++ b/packages/stats/core/src/domain/inference.ts @@ -41,6 +41,8 @@ const WEEK_MS = 7 * DAY_MS // boundary. Use one exclusive handoff so the overlapping rows are never counted // from both sources. const LIVE_SOURCE_START = "2026-08-11T10:57:48.186Z" +// Go Plus is a level of the Go subscription, but the lake records it as its own product. +const GO_PRODUCTS = ["go", "go-plus"] // R2 SQL results are cursor-paginated after aggregation. Separate usage and geo // queries per day/week avoid combining costly distinct user/session aggregates @@ -135,7 +137,7 @@ WITH normalized AS ( (source = 'inference-legacy' AND started_at < ${sqlString(LIVE_SOURCE_START)}) OR (source = 'inference' AND started_at >= ${sqlString(LIVE_SOURCE_START)}) ) - AND product = 'go' + AND product IN (${GO_PRODUCTS.map(sqlString).join(", ")}) AND model_requested IS NOT NULL AND model_requested <> '' AND __ingest_ts >= ${scanStartValue} @@ -299,7 +301,7 @@ WITH normalized AS ( (source = 'inference-legacy' AND started_at < ${sqlString(LIVE_SOURCE_START)}) OR (source = 'inference' AND started_at >= ${sqlString(LIVE_SOURCE_START)}) ) - AND (product = 'go' OR (${sourceFreeTier})) + AND (product IN (${GO_PRODUCTS.map(sqlString).join(", ")}) OR (${sourceFreeTier})) AND model_requested IS NOT NULL AND model_requested <> '' AND __ingest_ts >= ${periodStartValue}