diff --git a/packages/stats/core/src/domain/inference.test.ts b/packages/stats/core/src/domain/inference.test.ts index 20538aa15bd..e1d24c1650a 100644 --- a/packages/stats/core/src/domain/inference.test.ts +++ b/packages/stats/core/src/domain/inference.test.ts @@ -319,7 +319,9 @@ 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 IN ('go', 'go-plus') OR (lower(COALESCE(model_tier, '')) = 'free'") + expect(queries[0]).toContain( + "AND (product IN ('go', 'go-plus', 'go-teams') 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, ''), '^.*/', '')") @@ -365,6 +367,21 @@ describe("inference stat normalization", () => { expect(query).toContain("(source = 'inference' AND started_at >= '2026-08-11T10:57:48.186Z')") }) + test("counts every Go product level, including Go Teams", () => { + const source = { namespace: "inference", table: "generation", dataset: "zen" } + const [query] = buildStatsQueries( + new Date("2026-08-11T00:00:00.000Z"), + new Date("2026-08-12T00:00:00.000Z"), + source, + ) + + expect(query).toContain("product IN ('go', 'go-plus', 'go-teams')") + expect( + buildRetentionQueries(new Date("2026-08-10T00:00:00.000Z"), new Date("2026-08-31T00:00:00.000Z"), source)[0] + ?.query, + ).toContain("AND product IN ('go', 'go-plus', 'go-teams')") + }) + test("builds complete week-over-week retention queries", () => { const queries = buildRetentionQueries(new Date("2026-08-10T00:00:00.000Z"), new Date("2026-08-31T00:00:00.000Z"), { namespace: "inference", @@ -377,7 +394,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 IN ('go', 'go-plus')") + expect(queries[0]?.query).toContain("AND product IN ('go', 'go-plus', 'go-teams')") expect(queries[0]?.query).toContain("AND lower(model) NOT IN ('alpha-gpt-next')") expect(queries[0]?.query).toContain( "CASE\n WHEN lower(model) IN ('crouton-alpha', 'exo', 'iceman', 'iceman-contributor', 'omen-alpha', 'pulse-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 99d00027f33..912169a471f 100644 --- a/packages/stats/core/src/domain/inference.ts +++ b/packages/stats/core/src/domain/inference.ts @@ -42,8 +42,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"] +// Go Plus and Go Teams are levels of the Go subscription, but the lake records each as its own product. +const GO_PRODUCTS = ["go", "go-plus", "go-teams"] // Requests rejected before routing (unknown model, auth, rate limit) never reach an upstream // and carry no usage. Counting them would publish any requested model name as a stats page. const ROUTED_ONLY = "attempts > 0"