This sends product analytics to PostHog: src/lib/analytics.ts builds a posthog-react-native 4.x client once analytics consent is given and implements analytics.track/identify/screen, with an AnalyticsProvider (order 40) that follows consent and asks for ATT when enabled. PostHogProvider is not mounted - it needs a client at mount, and swapping one in after consent would remount the app - so usePostHog() and posthog-react-native's own hooks don't work; use analytics.*, useFeatureFlag, or getPostHog() / usePostHogClient() for the raw client (both undefined until consent). The root layout already calls analytics.screen(pathname) on every route change, so screen autocapture is off and touch autocapture is off too. If you set up with --with-examples there's an example at /examples/analytics with a list of the last events sent. @/lib/analytics keeps the same API whichever option you pick - pick PostHog when you want events, feature flags and a generous free tier from one service you can also self-host.
At a glance
- Runs in Expo Go
- Yes
- Files added
- 6
- npm packages
- 5
- Keys to paste
EXPO_PUBLIC_POSTHOG_KEY,EXPO_PUBLIC_POSTHOG_HOST- Included in
- Pro
Set it up
bun run setup --analytics posthogSetup copies the module in, installs SDK-matched versions and removes the options you did not pick. Then bun run doctor lists every key still missing, with a link to where you get it. The step-by-step guide is in the PostHog docs.
Other analytics options
Get it
PostHog ships in Pro: one payment, lifetime updates. See pricing or browse every module.