Move a React Native or Expo app from PostHog to Sumly
Swap posthog-react-native for one TypeScript file with no native module, call by call, keep both for a week to compare, then bring PostHog's history over. Screens and events stay under the user id RevenueCat knows, so each purchase shows what came before it.
Not yet run in a real app. The PostHog history import has been tested against PostHog's documented API, not yet against a real PostHog project. Try it on a project you can check by hand first.
Moved in five steps
- 1
In Sumly, open Visitors and copy your project's public key (
sl_…). Add the SDK withnpm i @sumly/sdk(or copy it as one file:curl -o sumly.ts https://sumly.dev/sdk/sumly.ts). Leave PostHog in for now. - 2
Call
Sumly.init({ siteKey: 'sl_…', storage: AsyncStorage })once, outside any component, next to wherePostHogProvideris set up. Wherever the app callsposthog.identify,capture,screenorreset, add the Sumly call from the table below, with the same user id. - 3
Screens: PostHog's captureScreens counted them by itself. With React Navigation, call
Sumly.screenon the container'sonReadyandonStateChange; with Expo Router, on each change ofusePathname(). - 4
Ship that build and leave both running for a week. Compare the numbers in the list below; small gaps are expected, a large one means a call is missing.
- 5
In Sumly, Tracking › Import earlier history › PostHog brings PostHog's months before Sumly. Its feature flags move too: make each one in Visitors › Flags with the same key and rollout (Sumly buckets people the same way, so the same people stay in), then swap the calls from the table. Then remove posthog-react-native and its provider.
Call by call
<PostHogProvider apiKey="phc_…" options={{ host }}>
Sumly.init({ siteKey: 'sl_…', storage: AsyncStorage }) Once, outside any component. No provider needed, except Sumly.Touches for taps.
const posthog = usePostHog()
import { Sumly } from './sumly' No hook: call Sumly anywhere.
posthog.capture('trial_started', { plan })
Sumly.track('trial_started', { plan }) Text, numbers and true or false; a few properties.
posthog.screen('Paywall', { … })
Sumly.screen('Paywall') A screen has its name only.
autocapture={{ captureScreens: true }}
Sumly.screen in onStateChange, or on usePathname() Named by you; Sumly.onNavigationChange(state) does it for React Navigation's state.
autocapture={{ captureTouches: true }}
autocapture: true and <Sumly.Touches> The project needs Every click, without marking on too.
posthog.identify('user_42', { email })
Sumly.identify('user_42') The id RevenueCat has (await Purchases.getAppUserID()). Name and e-mail come from your server, with identify and the secret key.
posthog.alias('…')
Not needed Events from before identify move to the first id you give.
posthog.reset()
Sumly.reset() On sign-out, before identify with the next id.
posthog.register({ … })
No equivalent No super properties: give the property on the events that need it.
posthog.get_distinct_id()
await Sumly.userId() The id events go under now.
posthog.optIn() and optOut()
waitForConsent: true, Sumly.consent(true) and consent(false) consent(false) also empties what waits to be sent.
await posthog.flush()
Sumly.flush() Batches also go on their own, and when the app goes to the background.
captureAppLifecycleEvents
app_installed, sent once No Application Opened events: sessions are counted from screens.
useFeatureFlagEnabled('new-checkout')
useFlag('new-checkout', false) Made in Visitors › Flags with the same key; renders again when the value changes.
useFeatureFlagVariantKey('paywall'), useFeatureFlag
useVariant('paywall', 'monthly') The fallback is what it gives before the first answer.
posthog.isFeatureEnabled('new-checkout')
Sumly.isEnabled('new-checkout') Outside components.
posthog.getFeatureFlagPayload('paywall')
Sumly.getFlagPayload('paywall') The JSON you gave the flag or the variant.
posthog.reloadFeatureFlagsAsync(), onFeatureFlags
Sumly.reloadFlags(), Sumly.onFlags Also by itself at launch, after identify, back in front and every 5 minutes.
bootstrap: { featureFlags }
bootstrapFlags in Sumly.init Values to use until the first answer.
posthog.group('company', 'acme')
Sumly.group('company', 'acme') For flags with one value for everyone in a company.
No Sumly equivalent
- Surveys: none. The heard_from recipe asks where people heard about the app.
- Session replay in the app: none. With heatmaps on, Sumly draws the taps over one picture of each screen instead.
- Group analytics, cohorts and PostHog's own dashboards: none.
A week side by side: what to compare
- People per day on each platform: Sumly's Visitors by platform against a PostHog trend of unique users on $screen.
- Your top five screens by views, with the same names in both.
- One event that matters, such as trial_started, and the installs.
- Expect a few percent apart: PostHog counts anonymous users differently with person profiles for identified users only, and both count the day in their own time zone, so set the same one.
Both side by side while you compare; PostHog's lines are in comments. The other tabs use these imports too.
// App.tsx
import AsyncStorage from '@react-native-async-storage/async-storage';
import Purchases from 'react-native-purchases';
import { Sumly } from '@sumly/sdk/react-native';
// <PostHogProvider apiKey="phc_…" options={{ host: 'https://eu.i.posthog.com' }}> around the app
Sumly.init({ siteKey: 'sl_your_key', storage: AsyncStorage });
export async function signedIn(userId: string): Promise<void> {
await Purchases.logIn(userId);
// posthog.identify(userId, { plan: 'free' })
Sumly.identify(await Purchases.getAppUserID());
}
export function signedOut(): void {
// posthog.reset()
Sumly.reset();
}
Or let your coding assistant do it
Paste this into Claude Code, Cursor or Codex in your project. It fits the code to how your project is built, asks you for the dashboard steps and leaves the keys to you.
See what it says
Move this React Native or Expo app from PostHog to Sumly: add Sumly next to PostHog first, with the same calls, so both run for a week.
Sumly (https://sumly.dev) shows revenue next to the visits and app users it came from. The full guide is https://sumly.dev/install/posthog-react-native; read it if anything below is unclear.
Steps:
1. In Sumly, open Visitors and copy your project's public key (`sl_…`). Add the SDK with `npm i @sumly/sdk` (or copy it as one file: `curl -o sumly.ts https://sumly.dev/sdk/sumly.ts`). Leave PostHog in for now.
2. Call `Sumly.init({ siteKey: 'sl_…', storage: AsyncStorage })` once, outside any component, next to where `PostHogProvider` is set up. Wherever the app calls `posthog.identify`, `capture`, `screen` or `reset`, add the Sumly call from the table into Sumly, with the same user id.
3. Screens: PostHog's captureScreens counted them by itself. With React Navigation, call `Sumly.screen` on the container's `onReady` and `onStateChange`; with Expo Router, on each change of `usePathname()`.
4. Ship that build and leave both running for a week. Compare the numbers in the list into Sumly; small gaps are expected, a large one means a call is missing.
5. In Sumly, Tracking › Import earlier history › PostHog brings PostHog's months before Sumly. Its feature flags move too: make each one in Visitors › Flags with the same key and rollout (Sumly buckets people the same way, so the same people stay in), then swap the calls from the table. Then remove posthog-react-native and its provider.
Call by call (before → Sumly):
- <PostHogProvider apiKey="phc_…" options={{ host }}> → Sumly.init({ siteKey: 'sl_…', storage: AsyncStorage }). Once, outside any component. No provider needed, except Sumly.Touches for taps.
- const posthog = usePostHog() → import { Sumly } from './sumly'. No hook: call Sumly anywhere.
- posthog.capture('trial_started', { plan }) → Sumly.track('trial_started', { plan }). Text, numbers and true or false; a few properties.
- posthog.screen('Paywall', { … }) → Sumly.screen('Paywall'). A screen has its name only.
- autocapture={{ captureScreens: true }} → Sumly.screen in onStateChange, or on usePathname(). Named by you; Sumly.onNavigationChange(state) does it for React Navigation's state.
- autocapture={{ captureTouches: true }} → autocapture: true and <Sumly.Touches>. The project needs Every click, without marking on too.
- posthog.identify('user_42', { email }) → Sumly.identify('user_42'). The id RevenueCat has (await Purchases.getAppUserID()). Name and e-mail come from your server, with identify and the secret key.
- posthog.alias('…') → Not needed. Events from before identify move to the first id you give.
- posthog.reset() → Sumly.reset(). On sign-out, before identify with the next id.
- posthog.register({ … }) → No equivalent. No super properties: give the property on the events that need it.
- posthog.get_distinct_id() → await Sumly.userId(). The id events go under now.
- posthog.optIn() and optOut() → waitForConsent: true, Sumly.consent(true) and consent(false). consent(false) also empties what waits to be sent.
- await posthog.flush() → Sumly.flush(). Batches also go on their own, and when the app goes to the background.
- captureAppLifecycleEvents → app_installed, sent once. No Application Opened events: sessions are counted from screens.
- useFeatureFlagEnabled('new-checkout') → useFlag('new-checkout', false). Made in Visitors › Flags with the same key; renders again when the value changes.
- useFeatureFlagVariantKey('paywall'), useFeatureFlag → useVariant('paywall', 'monthly'). The fallback is what it gives before the first answer.
- posthog.isFeatureEnabled('new-checkout') → Sumly.isEnabled('new-checkout'). Outside components.
- posthog.getFeatureFlagPayload('paywall') → Sumly.getFlagPayload('paywall'). The JSON you gave the flag or the variant.
- posthog.reloadFeatureFlagsAsync(), onFeatureFlags → Sumly.reloadFlags(), Sumly.onFlags. Also by itself at launch, after identify, back in front and every 5 minutes.
- bootstrap: { featureFlags } → bootstrapFlags in Sumly.init. Values to use until the first answer.
- posthog.group('company', 'acme') → Sumly.group('company', 'acme'). For flags with one value for everyone in a company.
No Sumly equivalent (leave these as they are, or ask me):
- Surveys: none. The heard_from recipe asks where people heard about the app.
- Session replay in the app: none. With heatmaps on, Sumly draws the taps over one picture of each screen instead.
- Group analytics, cohorts and PostHog's own dashboards: none.
Setup: Both side by side while you compare; PostHog's lines are in comments. The other tabs use these imports too.
```
// App.tsx
import AsyncStorage from '@react-native-async-storage/async-storage';
import Purchases from 'react-native-purchases';
import { Sumly } from '@sumly/sdk/react-native';
// <PostHogProvider apiKey="phc_…" options={{ host: 'https://eu.i.posthog.com' }}> around the app
Sumly.init({ siteKey: 'sl_your_key', storage: AsyncStorage });
export async function signedIn(userId: string): Promise<void> {
await Purchases.logIn(userId);
// posthog.identify(userId, { plan: 'free' })
Sumly.identify(await Purchases.getAppUserID());
}
export function signedOut(): void {
// posthog.reset()
Sumly.reset();
}
```
Events: capture becomes track, with the same name and properties.
```
export function startedTrial(plan: string, days: number): void {
// posthog.capture('trial_started', { plan, days })
Sumly.track('trial_started', { plan, days });
}
```
Screens: React Navigation: onReady counts the first screen, onStateChange the rest. With Expo Router, Sumly.screen(usePathname()) in the root layout.
```
import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
// was: <PostHogProvider autocapture={{ captureScreens: true }}>
export function MovedRoot() {
const navigationRef = useNavigationContainerRef();
const count = () => Sumly.screen(navigationRef.getCurrentRoute()?.name ?? 'App');
return (
<NavigationContainer ref={navigationRef} onReady={count} onStateChange={count}>
<AppNavigator />
</NavigationContainer>
);
}
```
Consent: optOut becomes waiting for consent: nothing is kept or sent until consent(true).
```
Sumly.init({ siteKey: 'sl_your_key', storage: AsyncStorage, waitForConsent: true });
export function answeredConsent(granted: boolean): void {
// granted ? posthog.optIn() : posthog.optOut()
Sumly.consent(granted);
}
```
Keep in mind: No native module: nothing to rebuild for Sumly, and expo-file-system, expo-application and the other packages PostHog needed can go if nothing else uses them. Revenue comes from the stores: connect RevenueCat, App Store Connect or Google Play in Projects and integrations, and give Sumly.identify the id RevenueCat uses. Imported PostHog months show usage, people and sources; which screen led to a purchase starts with Sumly's SDK.
How to work:
- Look at how this project is built first, and fit the code to its framework and its way of doing things; the examples above are a starting point, not something to paste as is.
- Steps that happen in a dashboard (Sumly, or From PostHog on React Native's own) are mine: tell me exactly what to click, then wait for me.
- Keys the code needs belong in environment variables, never in the code or the repository. Never ask me to paste a secret key into this chat; tell me which variable to set.
- Change only what this needs, show me the changes before you commit, and tell me how to check that it works.
- sl_your_key stands for the project's public key; it is on the Visitors page in Sumly. Ask me for it.
Consent
Where your app asks first, start with waitForConsent: nothing is kept or sent until consent(true), and consent(false) stops sending and empties the queue. The answer is remembered.
Purchases
Purchases do not come through the app: Sumly reads them from RevenueCat, Adapty or Superwall. Give identify the same person they know: RevenueCat's app user id (the anonymous one too), or the user id you pass to Adapty.identify or Superwall.identify. Each purchase then shows the screens and the source that came before it.
Buyers' names
Apple and Google never share who bought. To see a buyer's name or e-mail on their payments, send it from your server with the secret key: { "type": "identify", "user_id": "u_42", "traits": { "name": "Ana Novak", "email": "[email protected]" } } to /api/v1/events, with the same user id RevenueCat knows. Payments already kept take the name too. An empty trait clears it, and { "type": "forget", "user_id": "u_42" } removes them when they delete their account. Only the name and e-mail are kept, never shown publicly; without them the buyer stays "App user u_42".
Your own domain
Optional. The own address of your site's script (one DNS record on Visitors, on every plan) takes app events too: give it as the endpoint and the app sends to /api/v1/events there.
Good to know
- No native module: nothing to rebuild for Sumly, and expo-file-system, expo-application and the other packages PostHog needed can go if nothing else uses them.
- Revenue comes from the stores: connect RevenueCat, App Store Connect or Google Play in Projects and integrations, and give Sumly.identify the id RevenueCat uses.
- Imported PostHog months show usage, people and sources; which screen led to a purchase starts with Sumly's SDK.
From From PostHog on React Native's own documentation, checked 20 November 2026: posthog.com/docs/libraries/react-native, posthog.com/docs/api/queries .
From PostHog on React Native questions
What about PostHog's feature flags and experiments?
They move to Sumly: useFlag and useVariant replace useFeatureFlagEnabled and useFeatureFlagVariantKey, with flags you make in Visitors › Flags. An experiment there counts each variant's paying customers and revenue, not only clicks. Keep a flag's key and rollout and the same people stay in, as Sumly buckets them the way PostHog does.
Do I lose my PostHog history?
No. Import earlier history › PostHog reads it with a key that can only read and brings its screens, events and people for the days before Sumly started. Remove takes it out again.
How do purchases tie in?
Connect RevenueCat (or the App Store and Google Play) in Sumly, and pass Sumly.identify the same app user id RevenueCat has. Each purchase then shows the screens, taps and source before it.
Does it work on the web too?
Your website gets Sumly's line of script instead of posthog-js; the same identify id joins a person's web visits and app screens.
Other apps
Try it with your own projects
Sign in with Google or a code by e-mail and connect your first project. The first 14 days of a paid plan are free, with no card.
Start freeOr look around first: open the live demo.