feat(analytics): surface Go game stats in admin dashboard + instrument League Lens - #24
Merged
Merged
Conversation
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
go_players,go_puzzle_attempts) has been dark in/admin/analyticssince 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 thego_tables error (never sinks the Pente stats or the request).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 atsrc/__apiTests__/admin/analytics.test.tsto 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
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 inreadSupabaseStats()src/pages/admin/analytics.tsx— Go stats dashboard sectionsrc/components/nba/LeagueLens.tsx—track()instrumentationsrc/__apiTests__/admin/analytics.test.ts— new coverage for the Go wiringTest steps
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)/nba, open the League Lens tab, switch views and click a scatter point — events fire to/api/events(check Network tab, or/admin/analyticsafter deploy)Agent checklist
yarn buildpasses locallyyarn testpasses — 694/694 (up from 691 baseline; pasted output below)TODO, placeholder, or stub code.envvalues committedog:title,og:description,og:image,twitter:card— N/A, no new pages (dashboard isnoindex)PreText,Reveal,TiltCardused for any new UI text/cards — N/A, dashboard uses the existing card patternnoindex, League Lens change is instrumentation-only)Learn