Move an iOS app from PostHog to Sumly
Swap PostHog's iOS SDK for one Swift file, call by call, keep both for a week to compare, then bring PostHog's history over. Screens and events stay under the same user id RevenueCat knows, so from then on each purchase shows the screens and the source before it.
Not yet run in a real app. Sumly.swift builds and follows the same rules as the React Native file, which runs in our own apps, but it has not run in a shipped app yet, and the PostHog history import has been tested against PostHog's documented API, not yet against a real PostHog project. Try both in a test build first, and tell us if anything is off.
Moved in five steps
- 1
In Sumly, open Visitors and copy your project's public key (
sl_…). Download https://sumly.dev/sdk/Sumly.swift and add it to your app's target in Xcode. Leave PostHog in for now. - 2
Next to
PostHogSDK.shared.setup(config), callSumly.configure(siteKey: "sl_…"). Wherever the app callsidentify,capture,screenorreseton PostHog, add the Sumly call from the table below, with the same user id. - 3
PostHog counts UIKit screens by itself; Sumly does not. Add
.sumlyScreen("Paywall")to each SwiftUI screen, orSumly.screeninviewDidAppear, with the names your PostHog insights already use. - 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 the PostHog package and its calls.
Call by call
PostHogSDK.shared.setup(PostHogConfig(projectToken: "phc_…", host: …))
Sumly.configure(siteKey: "sl_…") The public key from Visitors. No host to choose; endpoint: only for your own domain.
capture("trial_started", properties: [...])
Sumly.track("trial_started", props: [...]) Text, numbers and true or false; a few properties, not a whole object.
screen("Paywall", properties: [...])
Sumly.screen("Paywall") or .sumlyScreen("Paywall") A screen has its name only.
captureScreenViews (UIKit, on by default)
.sumlyScreen on each SwiftUI view, Sumly.screen in viewDidAppear Named by you, so they match across iOS, Android and the web.
identify("user_42", userProperties: [...])
Sumly.identify("user_42") The same id RevenueCat has (Purchases.shared.appUserID). Name and e-mail come from your server, with identify and the secret key.
alias("…")
Not needed Events from before identify move to the first id you give; identify again when the id changes.
reset()
Sumly.reset() On sign-out, before identify with the next id.
register([...]) and unregister
No equivalent No super properties: give the property on the events that need it.
setPersonProperties(...)
identify from your server Only name and e-mail are kept about a person.
getDistinctId()
Sumly.userID The id events go under now.
optOut, optIn() and optOut()
waitForConsent: true, Sumly.consent(true) and consent(false) consent(false) also empties what waits to be sent.
flush()
Sumly.flush() Batches also go every 15 seconds, at 20 events and when the app goes to the background.
captureApplicationLifecycleEvents
app_installed, sent once No Application Opened or Backgrounded events: sessions are counted from screens.
captureElementInteractions
autocapture: true UIKit controls by themselves; SwiftUI taps marked with .sumlyTap. The project needs Every click, without marking on too.
debug(true)
debug: true in configure Logs what it sends.
isFeatureEnabled("new-checkout")
Sumly.isEnabled("new-checkout") Made in Visitors › Flags with the same key. Give a fallback with default: for the moment before the first answer.
getFeatureFlag("paywall"), getFeatureFlagResult
Sumly.getVariant("paywall", default: "monthly") getFlagDetail says the value, why, and whether it came from the server or the phone's cache.
getFeatureFlagPayload("paywall")
Sumly.getFlagPayload("paywall") The JSON you gave the flag or the variant.
reloadFeatureFlags()
Sumly.reloadFlags() Also by itself at launch, after identify, back in front and every 5 minutes.
group(type: "company", key: "acme")
Sumly.group("company", key: "acme") For flags with one value for everyone in a company.
Experiments
A flag with variants and a goal, in Visitors › Flags Results per variant with people, goal, paying people and revenue; exposures are sent by the SDK.
No Sumly equivalent
- Surveys: none. For where people heard about the app, the heard_from recipe sends one answer as an event.
- Session replay in the app: none. With heatmaps on, Sumly draws the taps over one picture of each screen instead.
- Group analytics (reports by company), cohorts, before_send and PostHog's own dashboards: none. Sumly.group is there for flags with one value per company.
A week side by side: what to compare
- People per day on iOS: Sumly's Visitors, platform iOS, 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 with person profiles for identified users only counts differently before identify, Sumly drops events that waited offline for more than a week, and both count the day in their own time zone, so set the same one.
Both side by side, in the App's init or didFinishLaunching. PostHog's lines are in comments; remove them once you have compared.
import SwiftUI
struct MovedApp: App {
init() {
// let config = PostHogConfig(projectToken: "phc_…", host: "https://eu.i.posthog.com")
// PostHogSDK.shared.setup(config)
Sumly.configure(siteKey: "sl_your_key")
}
var body: some Scene {
WindowGroup { Text("Home").sumlyScreen("Home") }
}
}
/// After sign-in: the same id for both, and for RevenueCat (Purchases.shared.appUserID).
func signedIn(userID: String) {
// PostHogSDK.shared.identify(userID, userProperties: ["plan": "free"])
Sumly.identify(userID)
}
func signedOut() {
// PostHogSDK.shared.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 iOS 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-ios; read it if anything below is unclear.
Steps:
1. In Sumly, open Visitors and copy your project's public key (`sl_…`). Download https://sumly.dev/sdk/Sumly.swift and add it to your app's target in Xcode. Leave PostHog in for now.
2. Next to `PostHogSDK.shared.setup(config)`, call `Sumly.configure(siteKey: "sl_…")`. Wherever the app calls `identify`, `capture`, `screen` or `reset` on PostHog, add the Sumly call from the table into Sumly, with the same user id.
3. PostHog counts UIKit screens by itself; Sumly does not. Add `.sumlyScreen("Paywall")` to each SwiftUI screen, or `Sumly.screen` in `viewDidAppear`, with the names your PostHog insights already use.
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 the PostHog package and its calls.
Call by call (before → Sumly):
- PostHogSDK.shared.setup(PostHogConfig(projectToken: "phc_…", host: …)) → Sumly.configure(siteKey: "sl_…"). The public key from Visitors. No host to choose; endpoint: only for your own domain.
- capture("trial_started", properties: [...]) → Sumly.track("trial_started", props: [...]). Text, numbers and true or false; a few properties, not a whole object.
- screen("Paywall", properties: [...]) → Sumly.screen("Paywall") or .sumlyScreen("Paywall"). A screen has its name only.
- captureScreenViews (UIKit, on by default) → .sumlyScreen on each SwiftUI view, Sumly.screen in viewDidAppear. Named by you, so they match across iOS, Android and the web.
- identify("user_42", userProperties: [...]) → Sumly.identify("user_42"). The same id RevenueCat has (Purchases.shared.appUserID). Name and e-mail come from your server, with identify and the secret key.
- alias("…") → Not needed. Events from before identify move to the first id you give; identify again when the id changes.
- reset() → Sumly.reset(). On sign-out, before identify with the next id.
- register([...]) and unregister → No equivalent. No super properties: give the property on the events that need it.
- setPersonProperties(...) → identify from your server. Only name and e-mail are kept about a person.
- getDistinctId() → Sumly.userID. The id events go under now.
- optOut, optIn() and optOut() → waitForConsent: true, Sumly.consent(true) and consent(false). consent(false) also empties what waits to be sent.
- flush() → Sumly.flush(). Batches also go every 15 seconds, at 20 events and when the app goes to the background.
- captureApplicationLifecycleEvents → app_installed, sent once. No Application Opened or Backgrounded events: sessions are counted from screens.
- captureElementInteractions → autocapture: true. UIKit controls by themselves; SwiftUI taps marked with .sumlyTap. The project needs Every click, without marking on too.
- debug(true) → debug: true in configure. Logs what it sends.
- isFeatureEnabled("new-checkout") → Sumly.isEnabled("new-checkout"). Made in Visitors › Flags with the same key. Give a fallback with default: for the moment before the first answer.
- getFeatureFlag("paywall"), getFeatureFlagResult → Sumly.getVariant("paywall", default: "monthly"). getFlagDetail says the value, why, and whether it came from the server or the phone's cache.
- getFeatureFlagPayload("paywall") → Sumly.getFlagPayload("paywall"). The JSON you gave the flag or the variant.
- reloadFeatureFlags() → Sumly.reloadFlags(). Also by itself at launch, after identify, back in front and every 5 minutes.
- group(type: "company", key: "acme") → Sumly.group("company", key: "acme"). For flags with one value for everyone in a company.
- Experiments → A flag with variants and a goal, in Visitors › Flags. Results per variant with people, goal, paying people and revenue; exposures are sent by the SDK.
No Sumly equivalent (leave these as they are, or ask me):
- Surveys: none. For where people heard about the app, the heard_from recipe sends one answer as an event.
- Session replay in the app: none. With heatmaps on, Sumly draws the taps over one picture of each screen instead.
- Group analytics (reports by company), cohorts, before_send and PostHog's own dashboards: none. Sumly.group is there for flags with one value per company.
Setup: Both side by side, in the App's init or didFinishLaunching. PostHog's lines are in comments; remove them once you have compared.
```
import SwiftUI
struct MovedApp: App {
init() {
// let config = PostHogConfig(projectToken: "phc_…", host: "https://eu.i.posthog.com")
// PostHogSDK.shared.setup(config)
Sumly.configure(siteKey: "sl_your_key")
}
var body: some Scene {
WindowGroup { Text("Home").sumlyScreen("Home") }
}
}
/// After sign-in: the same id for both, and for RevenueCat (Purchases.shared.appUserID).
func signedIn(userID: String) {
// PostHogSDK.shared.identify(userID, userProperties: ["plan": "free"])
Sumly.identify(userID)
}
func signedOut() {
// PostHogSDK.shared.reset()
Sumly.reset()
}
```
Events: capture becomes track. Property values are text, numbers or true and false.
```
func startedTrial(plan: String, days: Int) {
// PostHogSDK.shared.capture("trial_started", properties: ["plan": plan, "days": days])
Sumly.track("trial_started", props: ["plan": .text(plan), "days": .number(Double(days))])
}
func sharedChart() {
// PostHogSDK.shared.capture("chart_shared")
Sumly.track("chart_shared")
}
```
Screens: PostHog named UIKit screens by their class; give Sumly the names your PostHog insights use, so the two lines meet.
```
import SwiftUI
import UIKit
struct MovedPaywall: View {
var body: some View {
// PostHogSDK.shared.screen("Paywall")
Text("Go Pro").sumlyScreen("Paywall")
}
}
final class MovedSettingsController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// PostHogSDK.shared.screen("Settings")
Sumly.screen("Settings")
}
}
```
Consent: PostHog's optOut becomes waiting for consent: nothing is kept or sent until consent(true).
```
func startAnalytics(askFirst: Bool) {
// config.optOut = askFirst
Sumly.configure(siteKey: "sl_your_key", waitForConsent: askFirst)
}
func answeredConsent(_ granted: Bool) {
// granted ? PostHogSDK.shared.optIn() : PostHogSDK.shared.optOut()
Sumly.consent(granted)
}
```
Super properties: register has no twin. Keep what you registered and pass it with the events that need it.
```
enum MovedContext {
// PostHogSDK.shared.register(["team_id": 22])
static let team: [String: Sumly.Value] = ["team_id": 22]
}
func exported(format: String) {
var props = MovedContext.team
props["format"] = .text(format)
Sumly.track("report_exported", props: props)
}
```
Keep in mind: No advertising id and no tracking across apps, so no App Tracking Transparency prompt. In App Privacy, declare Product Interaction, User ID and Coarse Location, used for analytics, and take out what only PostHog needed. In your privacy manifest, declare UserDefaults with reason CA92.1 if it is not there already: the queue is kept there. Revenue comes from the store, not the SDK: connect App Store Connect or RevenueCat 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 iOS'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 advertising id and no tracking across apps, so no App Tracking Transparency prompt. In App Privacy, declare Product Interaction, User ID and Coarse Location, used for analytics, and take out what only PostHog needed.
- In your privacy manifest, declare UserDefaults with reason CA92.1 if it is not there already: the queue is kept there.
- Revenue comes from the store, not the SDK: connect App Store Connect or RevenueCat 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 iOS's own documentation, checked 20 November 2026: posthog.com/docs/libraries/ios, posthog.com/docs/libraries/ios/usage, posthog.com/docs/api/queries .
From PostHog on iOS questions
What about PostHog's feature flags and experiments?
They move to Sumly: Sumly.isEnabled, getVariant and getFlagPayload read flags you make in Visitors › Flags, cached on the phone and worked out on Sumly's server. 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 the App Store (or RevenueCat, or Google Play for Android) in Sumly, and pass Sumly.identify the same app user id RevenueCat has. Each purchase then shows the screens, taps and source before it.
What about Android and Flutter?
They have their own guides: From PostHog on Android, with Sumly.kt, and From PostHog on Flutter, with a few lines of Dart.
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.