Skip to content

[ANALYTICS-001] Add product analytics events and dashboard - #80

Merged
chev0004 merged 13 commits into
developfrom
feat/analytics-001
Jun 30, 2026
Merged

[ANALYTICS-001] Add product analytics events and dashboard#80
chev0004 merged 13 commits into
developfrom
feat/analytics-001

Conversation

@chev0004

Copy link
Copy Markdown
Owner

Outline

Summary

Adds product analytics: a privacy-aware, first-party event-tracking system with a user opt-out and an admin-only metrics dashboard.


Changes & Enhancements

  • Type of Change:
    • Feature
    • Bugfix
    • Refactor
    • Chore
  • Changes:
    • (analytics):
      • Central event catalog and a privacy-aware server trackEvent that never throws and always records locale.
      • Metadata sanitizer that drops everything outside a non-sensitive allowlist, so no private profile content is sent.
      • Client beacon helper and /api/analytics ingest endpoint guarded by a client-event allowlist.
    • (instrumentation):
      • Signup, login, onboarding start and complete, profile save, bump, save-to-favorites, discovery view, profile view, and username copy.
      • Anonymous and authenticated events are both supported.
    • (settings):
      • Product analytics opt-out toggle, enforced server-side before any event is written.
    • (dashboard):
      • Admin-gated /[lang]/analytics with an activation funnel, daily volume, event volume, and recent events.
    • (db):
      • analytics_events table and migration, plus a product_analytics settings column.
    • (i18n):
      • English and Japanese strings for the dashboard and the new setting.

Page / App Changes

Affected Next.js Routes (Local):

  • /[lang]/analytics (new admin dashboard)
  • /[lang]/settings (new Product analytics privacy toggle)
  • /[lang], /[lang]/u/[id], /[lang]/onboarding (emit view events, no visual change)
  • /api/analytics (new client event ingest endpoint)
Before (Screenshot)
After (Screenshot)

Component / Storybook Changes

Affected Storybook Components (Local):

Before (Screenshot)
After (Screenshot)

Analytics dashboard with activation funnel, daily volume, event volume, and recent events
Analytics dashboard empty state
Settings privacy section with the new Product analytics toggle


Not Doing

  • Events for features that do not exist yet (reports, blocks, intro requests, premium upgrades) are defined in the catalog but not emitted; they will be wired up when those features land.

Other (Remarks)

Run bun run db:migrate after merge (adds analytics_events and the product_analytics column). The dashboard is gated by a new POLYCORD_ADMIN_USER_IDS env var (comma-separated Discord IDs), documented in .env.example.


Checklists

  • Code is well-documented (comments, JSDoc, etc.).
  • Existing comments were updated as needed.
  • No out-of-scope changes are included.
  • Write TODO comments where future work is required.
  • Removed unnecessary debug code (e.g., console.log, debugger).
  • Self-reviewed and tested locally.

@chev0004 chev0004 self-assigned this Jun 23, 2026
# Conflicts:
#	drizzle/meta/0008_snapshot.json
#	drizzle/meta/_journal.json
#	src/db/index.ts
#	src/db/schema.ts
@chev0004
chev0004 merged commit d6915d6 into develop Jun 30, 2026
1 check passed
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