Skip to Content

Analytics setup

NativeExpress sends app events to PostHog  once you add your project’s API key and host.

Prerequisites

Complete the app setup before connecting analytics.

Create a PostHog account

Sign up for PostHog , or sign in to your existing account.

Create a new project

Create a project in the PostHog dashboard , then open its React Native setup instructions. Copy the project API key and host URL.

Creating a new React Native project in PostHog

Add the API key and host

Set both values in .env.local:

.env.local
EXPO_PUBLIC_POSTHOG_HOST="<your-posthog-host>" EXPO_PUBLIC_POSTHOG_API_KEY="<your-project-api-key>"

For cloud builds, add both variables to the EAS environment  used by your build profile.

Verify

Restart the development server and reload the app. Sign in with email and password, then find the sign_in_completed event in your PostHog project. Its method property should be email.

If no event appears, check that both environment variables are set and that the key and host belong to the same PostHog project. Analytics stays disabled when either value is missing.

Session replay

Session replay is off by default, in PostHog and in Sentry. Recording the screen costs frame time on every session, and the app’s privacy labels in privacy.config.json don’t declare recordings.

To turn it on for PostHog, install the native replay plugin by following PostHog’s React Native session replay setup . Then set enableSessionReplay: true in src/services/analytics/client.ts, and add the recordings to privacy.config.json before you submit to the stores.

Next

See Analytics usage to add your own events.

Last updated on