Skip to content

feat(analytics): surface Go game stats in admin dashboard + instrument League Lens - #24

Merged
brooksRoley merged 2 commits into
mainfrom
claude/youthful-davinci-mtgp7g
Aug 21, 2026
Merged

feat(analytics): surface Go game stats in admin dashboard + instrument League Lens#24
brooksRoley merged 2 commits into
mainfrom
claude/youthful-davinci-mtgp7g

Conversation

@brooksRoley

@brooksRoley brooksRoley commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Go game data (go_players, go_puzzle_attempts) has been dark in /admin/analytics since it shipped — isolated in its own Supabase tables per CLAUDE.md, but that also meant Go engagement had zero visibility. Wires in player count/avg ELO and puzzle attempt totals/solve rate, degrading independently to zero/null if the go_ tables error (never sinks the Pente stats or the request).
  • Instruments League Lens (league_lens_view, league_lens_view_switch, league_lens_player_select) — closes the "zero track() instrumentation" ledger item flagged 2026-08-04 by this same Chief Data Scientist role.

Note on scope: an earlier version of this PR also relocated 6 pre-existing test files out of src/pages/api/**/__tests__ (they ship as live public routes under Next's Pages Router). That duplicated PR #23, which already fixed the same 6 files — open since 2026-08-08, CI green, zero conflicts, just waiting on a merge. Reverted that part here to avoid a conflict between the two PRs; this PR's own new test file is placed at src/__apiTests__/admin/analytics.test.ts to match PR #23's convention so it doesn't add another instance once #23 lands. #23 merging is still the actual unblock for the other 6 — flagged 3x in the project ledger already.

Livelihood stream

  • Games
  • Portfolio signal (hiring)

Go engagement data now informs whether it's worth investing further in the game vs. Pente.

Files changed

  • src/pages/api/admin/analytics.ts — Go stats in readSupabaseStats()
  • src/pages/admin/analytics.tsx — Go stats dashboard section
  • src/components/nba/LeagueLens.tsxtrack() instrumentation
  • src/__apiTests__/admin/analytics.test.ts — new coverage for the Go wiring

Test steps

  1. yarn dev, log in at /login, visit /admin/analytics — confirm the new "Go (Supabase)" card renders (0s if Supabase env vars aren't set locally)
  2. Visit /nba, open the League Lens tab, switch views and click a scatter point — events fire to /api/events (check Network tab, or /admin/analytics after deploy)

Agent checklist

  • yarn build passes locally
  • yarn test passes — 694/694 (up from 691 baseline; pasted output below)
  • No TODO, placeholder, or stub code
  • No secrets, API keys, or .env values committed
  • New pages include og:title, og:description, og:image, twitter:card — N/A, no new pages (dashboard is noindex)
  • PreText, Reveal, TiltCard used for any new UI text/cards — N/A, dashboard uses the existing card pattern
  • Lighthouse scores not regressed — not run locally; no client-facing page changed (admin dashboard is noindex, League Lens change is instrumentation-only)
  • README updated if new pages or components were added — N/A, no new pages/components
yarn test
 Test Files  61 passed (61)
      Tests  694 passed (694)

yarn lint
$ eslint src --max-warnings 0
Done in 18.34s.

yarn build
✓ Compiled successfully

Learn

Next.js Pages Router treats every file under pages/api/** as a route candidate regardless of filename — __tests__ dirs and .test.ts files are not exempt. When adding a new API route test, put it outside pages/ from the start (this repo's convention, per PR #23, is src/__apiTests__/<mirrored-path>/) rather than relying on remembering to move it later.

…recurring test-as-route leak

Go game data (go_players, go_puzzle_attempts) has been dark in the admin
analytics dashboard since it shipped — isolated in its own Supabase tables
per CLAUDE.md, but that isolation meant Go engagement had zero visibility
next to Pente's stats. Wires it in: player count/avg ELO and puzzle attempt
totals/solve rate, degrading independently to zero/null if the go_ tables
error (never sinks Pente's stats or the request).

Closes the "League Lens zero track() instrumentation" ledger item flagged
2026-08-04 (Chief Data Scientist): view load, tab switches, and player
selection now emit events, matching every other tool/game on the site.

Also fixes a recurring bug: Next's Pages Router builds a route for every
file under src/pages/api/**, including __tests__ dirs — 6 vitest files were
shipping as live public API routes (this class of bug was previously marked
resolved 2026-08-08, but the fix only moved some files and 2 new instances
had already reappeared under nba/tft; verified today's build output showed
/api/admin/__tests__/leads.test, /api/nba/tft/__tests__/summary.test, etc.
all still present as routes). Relocated all 7 (6 pre-existing + this PR's
own new analytics.test.ts, which would otherwise have added an 8th) to
mirror src/lib/**/__tests__ paths outside pages/, importing the handler via
the src/ alias. Verified the post-move build manifest has zero __tests__/.test
routes.

Livelihood stream: Games (Pente/Go) + Portfolio signal — Go engagement data
now informs whether it's worth investing further in the game, and the route
leak was a live deployment-hygiene risk on every /api/admin, /api/intake,
/api/nba/tft, and /api/pente/game-result surface.

694/694 tests passing (up from 691 baseline), lint clean, build clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Snbceop1BJxZH6BXN88Pyp
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zero-next Ready Ready Preview Aug 11, 2026 4:06pm

PR #23 (open since 2026-08-08, still unmerged) already moved these same 6
files out of src/pages/api/**/__tests__ to fix the exact same route-leak bug
— to src/__apiTests__/**, not src/lib/**/__tests__ as the previous commit
here did independently. Shipping both would conflict on the same file
deletions when either merges.

Reverted those 6 files to their original src/pages/api/**/__tests__
locations (PR #23's problem to resolve — it's ready, just waiting on a
merge) and relocated this PR's own new analytics.test.ts to
src/__apiTests__/admin/, matching PR #23's convention, so it doesn't add an
8th live-route instance once #23 lands.

694/694 tests passing, lint clean, build clean (route manifest still shows
zero __tests__/.test entries for the files this PR actually touches).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Snbceop1BJxZH6BXN88Pyp
@brooksRoley brooksRoley changed the title feat(analytics): surface Go game stats + instrument League Lens; fix recurring test-as-route leak feat(analytics): surface Go game stats in admin dashboard + instrument League Lens Aug 11, 2026
@brooksRoley
brooksRoley merged commit 8b069db into main Aug 21, 2026
4 checks passed
@brooksRoley
brooksRoley deleted the claude/youthful-davinci-mtgp7g branch August 21, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants