fix: switch to PostHogProvider per official React guide #112

Merged
chihlasm merged 1 commits from fix/posthog-react-provider into main 2026-03-16 23:18:31 +00:00
chihlasm commented 2026-03-16 23:18:29 +00:00 (Migrated from github.com)

Summary

Switches from manual posthog.init() to the official @posthog/react PostHogProvider wrapper per PostHog's React integration guide.

Changes:

  • Install @posthog/react
  • Wrap app with PostHogProvider in main.tsx (replaces manual initAnalytics())
  • Use VITE_PUBLIC_POSTHOG_KEY and VITE_PUBLIC_POSTHOG_HOST env vars
  • Use defaults: '2026-01-30' for recommended PostHog settings
  • Analytics module checks posthog.__loaded for readiness instead of a manual flag

Railway env vars needed (frontend service):

  • VITE_PUBLIC_POSTHOG_KEY=phc_dS59G33cVarNsTKD2yP26MIRhkQtmYdVg9oSYDqTlRg
  • VITE_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
  • Remove old VITE_POSTHOG_KEY if set

🤖 Generated with Claude Code

## Summary Switches from manual `posthog.init()` to the official `@posthog/react` PostHogProvider wrapper per PostHog's React integration guide. **Changes:** - Install `@posthog/react` - Wrap app with `PostHogProvider` in `main.tsx` (replaces manual `initAnalytics()`) - Use `VITE_PUBLIC_POSTHOG_KEY` and `VITE_PUBLIC_POSTHOG_HOST` env vars - Use `defaults: '2026-01-30'` for recommended PostHog settings - Analytics module checks `posthog.__loaded` for readiness instead of a manual flag **Railway env vars needed (frontend service):** - `VITE_PUBLIC_POSTHOG_KEY=phc_dS59G33cVarNsTKD2yP26MIRhkQtmYdVg9oSYDqTlRg` - `VITE_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com` - Remove old `VITE_POSTHOG_KEY` if set 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.