Define events once in TypeScript and build dashboards from those same names with a script.

6 files · 26 KB

PostHog ↗

Why I keep it

I keep WithSeismic’s event names and payloads in analytics-events.ts, so a misspelling fails a type check before it splits a funnel. Calls go through one typed track() function, while a script builds the dashboards from the same vocabulary.

I want analytics changes to travel with the code, so I’ve included that event map, the tracking wrapper, a server sink and the dashboard seeder. Replace the example events with yours and preview the seeder’s changes before it writes to your PostHog project.

Take the files

6 files · 26 KB

  • README.md3 KB
  • env.example629 B
  • lib/analytics-events.ts5 KB
  • lib/analytics.ts1 KB
  • scripts/posthog-dashboards.mjs14 KB
  • server/analytics.ts3 KB

Keep building your setup: The stack

Back to the shelves →
  • 015 files · 151 KB

    The SaaS starter

    Start with accounts, organisations, email and analytics wired into a React app and Hono API.

  • 025 files · 6 KB

    Turborepo

    Run builds, tests and type checks across your apps in dependency order, with cached results.

  • 0316 files · 18 KB

    Hono

    Give your API typed routes, generated docs and a consistent error response before adding features.

  • 048 files · 8 KB

    Drizzle

    Keep your database schema typed and your SQL migrations checked in beside the code that needs them.

  • 052 files · 5 KB

    Better Auth with passkeys

    Keep accounts, organisations and passkey sign-in in your own Hono API and Postgres database.

  • 069 files · 10 KB

    TanStack

    Keep React routes, session checks and cached server data working from the same types.