feat: add PostHog product analytics #110

Merged
chihlasm merged 1 commits from feat/posthog-analytics into main 2026-03-16 22:24:31 +00:00
chihlasm commented 2026-03-16 22:24:29 +00:00 (Migrated from github.com)

Summary

Adds PostHog product analytics tracking for key user actions. No autocapture — only explicit discrete events to stay well within the free tier (1M events/month).

Events tracked:

  • account_created — on registration
  • login_success — on successful login
  • flow_viewed — when opening a flow's navigate page
  • session_started — when a session is created
  • session_completed — when a session is completed with outcome
  • export_generated — when generating an export (wired but caller TBD)
  • ai_feature_used — when using any AI feature (wired but caller TBD)
  • psa_connected — when connecting PSA integration (wired but caller TBD)
  • session_shared — when creating a share link (wired but caller TBD)

User identification: PostHog identify() called after login with user ID, email, role. reset() on logout. Account grouping via posthog.group().

Configuration: Set VITE_POSTHOG_KEY env var to enable. Without it, all tracking is silently no-op.

Test plan

  • Log in → check PostHog dashboard for login_success event
  • Open a flow → check for flow_viewed event
  • Start and complete a session → check for session_started and session_completed
  • Register new account → check for account_created

🤖 Generated with Claude Code

## Summary Adds PostHog product analytics tracking for key user actions. No autocapture — only explicit discrete events to stay well within the free tier (1M events/month). **Events tracked:** - `account_created` — on registration - `login_success` — on successful login - `flow_viewed` — when opening a flow's navigate page - `session_started` — when a session is created - `session_completed` — when a session is completed with outcome - `export_generated` — when generating an export (wired but caller TBD) - `ai_feature_used` — when using any AI feature (wired but caller TBD) - `psa_connected` — when connecting PSA integration (wired but caller TBD) - `session_shared` — when creating a share link (wired but caller TBD) **User identification:** PostHog `identify()` called after login with user ID, email, role. `reset()` on logout. Account grouping via `posthog.group()`. **Configuration:** Set `VITE_POSTHOG_KEY` env var to enable. Without it, all tracking is silently no-op. ## Test plan - [ ] Log in → check PostHog dashboard for `login_success` event - [ ] Open a flow → check for `flow_viewed` event - [ ] Start and complete a session → check for `session_started` and `session_completed` - [ ] Register new account → check for `account_created` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.