feat(mobile): add PostHog analytics with autocapture and screen tracking#932
feat(mobile): add PostHog analytics with autocapture and screen tracking#932saddlepaddle merged 2 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughThis PR integrates PostHog analytics into the mobile app by adding environment configuration for PostHog credentials, creating a PostHog client and provider, refactoring the root layout to manage QueryClient and PostHog providers, and implementing components for tracking user identity and initializing analytics settings. Changes
Sequence DiagramssequenceDiagram
participant App as Mobile App
participant RootLayout as RootLayout
participant QueryProvider as QueryClientProvider
participant PostHogProv as PostHogProvider
participant PostHog as PostHog Instance
participant PathTracker as PostHogInitializer
App->>RootLayout: Mount
RootLayout->>QueryProvider: Wrap children
QueryProvider->>PostHogProv: Wrap children
PostHogProv->>PostHog: Initialize with config
PostHog-->>PostHogProv: Ready
PathTracker->>PostHog: Register app (app_name: mobile)
PathTracker->>PostHog: Enable debug if configured
PathTracker->>PostHog: Capture initial screen view
PostHogProv->>App: Render Stack + PortalHost
sequenceDiagram
participant Session as Session State
participant UserIdent as PostHogUserIdentifier
participant PostHog as PostHog Instance
Note over Session,PostHog: User logs in
Session->>UserIdent: Session updated with user
UserIdent->>PostHog: identify(userId, {email, name})
PostHog-->>UserIdent: Identified
Note over Session,PostHog: User logs out
Session->>UserIdent: Session becomes null
UserIdent->>PostHog: reset()
PostHog-->>UserIdent: Reset
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
- Configure PostHogProvider with touch autocapture - Add manual screen tracking using expo-router's usePathname - Register app_name super property for mobile events - Identify users on auth with email/name
45a1994 to
5935ae8
Compare
Summary
usePathnameChanges
posthog-react-nativeand required Expo dependencies (expo-application, expo-device, expo-file-system, expo-localization)PostHogProviderwrapper with screen tracking and debug mode supportPostHogUserIdentifiercomponent for authenticated user identificationlib/posthog/with environment variable supportTest plan
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.