8000 feat: privacy-first event analytics with Vercel KV by adityamukho · Pull Request #39 · project-minigraf/minigraf-playground · GitHub
[go: up one dir, main page]

Skip to content

feat: privacy-first event analytics with Vercel KV - #39

Merged
adityamukho merged 11 commits into
mainfrom
feat/analytics
Jun 21, 2026
Merged

adityamukho merged 11 commits into
mainfrom
feat/analytics

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Summary

  • Adds trackEvent fire-and-forget utility posting to a new /api/event Edge route
  • /api/event atomically increments daily-bucketed counters in Vercel KV (events:{name}:{YYYY-MM-DD})
  • Tracks 5 events: lesson_started, lesson_completed (dedup-guarded), query_run, tutor_message_sent, outbound_click_github/wiki/docs_rs
  • New Footer component with outbound links (GitHub, Wiki, docs.rs, Terms); crates.io omitted as the crate is not yet published
  • GitHub icon added to NavBar (inline SVG — lucide-react v1.8 doesn't export Github)
  • Fixes long-standing bug: <Analytics /> was imported in app/layout.tsx but never rendered

New dependency

@vercel/kv — required for the /api/event route. KV store is provisioned via the Upstash Redis integration on Vercel (KV_REST_API_URL + KV_REST_API_TOKEN env vars).

Test plan

  • npm test — 222 tests passing (9 new tests across analytics.test.ts and event.test.ts)
  • npm run build — clean
  • Deploy and verify manually: lesson_started, lesson_completed, query_run, tutor_message_sent, outbound_click_github each fire and appear in the admin dashboard

🤖 Generated with Claude Code

adityamukho and others added 11 commits June 21, 2026 10:28
Implements Task 1 foundational analytics infrastructure with EventName type union
and fire-and-forget trackEvent utility for client-side event tracking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implement edge runtime POST endpoint to track analytics events. Validates
event names against EventName type and ISO 8601 dates, then increments
counters in Vercel KV. Includes comprehensive test suite with mocked KV.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
vercel Bot commented Jun 21, 2026 •
Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
minigraf-playground Ready Ready Preview, Comment Jun 21, 2026 1:06pm

@adityamukho
adityamukho merged commit 18d1738 into main Jun 21, 2026
3 checks passed
@adityamukho
adityamukho deleted the feat/analytics branch June 21, 2026 13:06

This branch was successfully deployed

1 active deployment
Preview — 1aab0927 Deployed Jun 21, 2026 by vercel[bot]
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.

1 participant

0