Blocks/Analytics Tracker
BeginnerUtility

Analytics Tracker

Typed event tracking with PostHog + Supabase fallback

Privacy-friendly analytics with a typed event catalogue (20 events), PostHog wrapper with lazy initialization, user identification, usePageTracking() hook for automatic Next.js route tracking, a Supabase self-hosted fallback, and ready-made SQL queries for DAU, WAU, conversion funnel, and retention cohorts.

5h
Time saved
279
Lines of code
100%
TypeScript
#analytics#posthog#tracking#events

Dependencies

posthog-js

Code preview

blocks/analytics/index.ts
1track('purchase_completed', { blockId: 'auth', amount: 19 })
2
3identifyUser(session.user.id, { email: session.user.email, role: 'user' })
4
5var(--text-3);font-style:italic">// usePageTracking() in providers.tsx auto-tracks all route changes

Short excerpt. Full block includes SQL migrations, error handling, RLS policies, and complete file structure.

$9

One-time Β· Instant GitHub access

πŸ”œ Payments launching soon

We are setting up secure checkout. Email samarthofficial52@gmail.com to get early access.

You might also like