fix: switch to PostHogProvider per official React integration guide

- Install @posthog/react and wrap app with PostHogProvider
- Use VITE_PUBLIC_POSTHOG_KEY and VITE_PUBLIC_POSTHOG_HOST env vars
- Use defaults: '2026-01-30' for recommended settings
- Remove manual initAnalytics() call — Provider handles initialization
- Analytics module now checks posthog.__loaded for readiness

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-03-16 19:18:15 -04:00
parent c44edc5088
commit cc8b39c4f1
4 changed files with 60 additions and 39 deletions

View File

@@ -13,6 +13,7 @@
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@monaco-editor/react": "^4.7.0",
"@posthog/react": "^1.8.2",
"@sentry/react": "^10.42.0",
"@sentry/vite-plugin": "^5.1.1",
"@stripe/stripe-js": "^8.7.0",
@@ -1597,6 +1598,22 @@
"cross-spawn": "^7.0.6"
}
},
"node_modules/@posthog/react": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@posthog/react/-/react-1.8.2.tgz",
"integrity": "sha512-KzUuXIcAR8fAjU7IeDq+XfEcUTNvzgEGB381WRrFUUsu7jFTcKZZ6crx/ukHRCzTnoEuy5EJDkL7b7sJecPlCg==",
"license": "MIT",
"peerDependencies": {
"@types/react": ">=16.8.0",
"posthog-js": ">=1.257.2",
"react": ">=16.8.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/@posthog/types": {
"version": "1.360.2",
"resolved": "https://registry.npmjs.org/@posthog/types/-/types-1.360.2.tgz",