Move a Flutter app from PostHog to Sumly
Sumly has no Flutter package yet, so the move swaps posthog_flutter for a few lines of Dart that send screens and events to Sumly's events API. PostHog's history comes over in full with a read-only key.
Not yet run in a real app. This is the plain events API, not an SDK: there is no queue, so an event sent while offline is lost unless your app keeps it. The Dart samples are not compiled by our tests, and the PostHog history import has been tested against PostHog's documented API, not yet against a real PostHog project.
Moved in five steps
- 1
In Sumly, open Visitors and copy your project's public key (
sl_…). Add thehttppackage and thesumly.dartbelow. Leave posthog_flutter in for now. - 2
Where the app calls
Posthog().capture, callsumlyTracktoo; where it callsPosthog().identify, keep the same user id for Sumly'suser_id(RevenueCat's app user id, if you use RevenueCat). - 3
Screens: next to
PosthogObserver()innavigatorObservers(or GoRouter'sobservers), addSumlyObserver(). Both readRouteSettings.name, so the names match. - 4
Ship that build and leave both running for a week. Compare people per day, the top screens and one key event.
- 5
In Sumly, Tracking › Import earlier history › PostHog brings PostHog's months before Sumly. Feature flags move too: make each one in Visitors › Flags with the same key and rollout, and read them with
sumlyFlagsbelow. Then remove posthog_flutter.
Call by call
PostHogConfig('phc_…') and Posthog().setup(config), or the manifest and Info.plist keys
Your public key in sumly.dart No setup call: each event carries the key.
Posthog().capture(eventName: 'trial_started', properties: {…})
sumlyTrack('trial_started', {…}) Text, numbers and true or false; a few properties.
PosthogObserver() in navigatorObservers
SumlyObserver() beside it Both name a screen by RouteSettings.name; a route without a name is skipped.
Posthog().identify(userId: 'user_42', …)
user_id on every event The same id RevenueCat has (await Purchases.appUserID). Name and e-mail come from your server, with identify and the secret key.
Posthog().reset()
The next user id Events go under whichever user_id you send.
Posthog().register('team_id', 22)
No equivalent Add the property to the events that need it.
Posthog().disable() and enable()
Your own flag Send nothing until the person agrees, where your app asks first.
Posthog().flush()
Not needed Each event is sent as it happens.
Application lifecycle events
A track event of your own Send app_installed once, on the first launch, if you want installs counted.
Posthog().isFeatureEnabled('new-checkout'), getFeatureFlag
sumlyFlags(), then flags['new-checkout'] One call brings all of a person's flags; keep the answer for the session.
$feature_flag_called
sumlyTrack('$flag_seen', …) for an experiment Once per flag and value, with the flag, variant, unit and reason from the answer.
No Sumly equivalent
- Surveys and session replay: none.
- An offline queue and taps counted by themselves: not without an SDK. Keep events that failed and send them later if they matter.
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.
- Events sent while offline reach PostHog later and never reach Sumly without a queue of your own, so expect Sumly a little lower.
One event per call; the events API also takes up to 1,000 in one list.
import 'dart:convert';
import 'dart:io' show Platform;
import 'package:flutter/widgets.dart';
import 'package:http/http.dart' as http;
const _sumlyKey = 'sl_your_key';
String? sumlyUserId; // set it where Posthog().identify was called
Future<void> _send(Map<String, Object?> event) async {
final userId = sumlyUserId;
if (userId == null) return;
await http.post(
Uri.parse('https://sumly.dev/api/v1/events'),
headers: {'Authorization': 'Bearer $_sumlyKey', 'Content-Type': 'application/json'},
body: jsonEncode({'events': [
{...event, 'user_id': userId, 'platform': Platform.isIOS ? 'ios' : 'android'},
]}),
);
}
Future<void> sumlyScreen(String screen) => _send({'type': 'screen', 'screen': screen});
Future<void> sumlyTrack(String name, [Map<String, Object?>? props]) =>
_send({'type': 'track', 'name': name, if (props != null) 'props': props});
class SumlyObserver extends NavigatorObserver {
@override
void didPush(Route route, Route? previousRoute) {
final name = route.settings.name;
if (name != null) sumlyScreen(name);
}
}
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 Flutter app from PostHog to Sumly: add Sumly's events next to PostHog first, with the same names and user id, 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-flutter; read it if anything below is unclear.
Steps:
1. In Sumly, open Visitors and copy your project's public key (`sl_…`). Add the `http` package and the `sumly.dart` into Sumly. Leave posthog_flutter in for now.
2. Where the app calls `Posthog().capture`, call `sumlyTrack` too; where it calls `Posthog().identify`, keep the same user id for Sumly's `user_id` (RevenueCat's app user id, if you use RevenueCat).
3. Screens: next to `PosthogObserver()` in `navigatorObservers` (or GoRouter's `observers`), add `SumlyObserver()`. Both read `RouteSettings.name`, so the names match.
4. Ship that build and leave both running for a week. Compare people per day, the top screens and one key event.
5. In Sumly, Tracking › Import earlier history › PostHog brings PostHog's months before Sumly. Feature flags move too: make each one in Visitors › Flags with the same key and rollout, and read them with `sumlyFlags` into Sumly. Then remove posthog_flutter.
Call by call (before → Sumly):
- PostHogConfig('phc_…') and Posthog().setup(config), or the manifest and Info.plist keys → Your public key in sumly.dart. No setup call: each event carries the key.
- Posthog().capture(eventName: 'trial_started', properties: {…}) → sumlyTrack('trial_started', {…}). Text, numbers and true or false; a few properties.
- PosthogObserver() in navigatorObservers → SumlyObserver() beside it. Both name a screen by RouteSettings.name; a route without a name is skipped.
- Posthog().identify(userId: 'user_42', …) → user_id on every event. The same id RevenueCat has (await Purchases.appUserID). Name and e-mail come from your server, with identify and the secret key.
- Posthog().reset() → The next user id. Events go under whichever user_id you send.
- Posthog().register('team_id', 22) → No equivalent. Add the property to the events that need it.
- Posthog().disable() and enable() → Your own flag. Send nothing until the person agrees, where your app asks first.
- Posthog().flush() → Not needed. Each event is sent as it happens.
- Application lifecycle events → A track event of your own. Send app_installed once, on the first launch, if you want installs counted.
- Posthog().isFeatureEnabled('new-checkout'), getFeatureFlag → sumlyFlags(), then flags['new-checkout']. One call brings all of a person's flags; keep the answer for the session.
- $feature_flag_called → sumlyTrack('$flag_seen', …) for an experiment. Once per flag and value, with the flag, variant, unit and reason from the answer.
No Sumly equivalent (leave these as they are, or ask me):
- Surveys and session replay: none.
- An offline queue and taps counted by themselves: not without an SDK. Keep events that failed and send them later if they matter.
sumly.dart: One event per call; the events API also takes up to 1,000 in one list.
```
import 'dart:convert';
import 'dart:io' show Platform;
import 'package:flutter/widgets.dart';
import 'package:http/http.dart' as http;
const _sumlyKey = 'sl_your_key';
String? sumlyUserId; // set it where Posthog().identify was called
Future<void> _send(Map<String, Object?> event) async {
final userId = sumlyUserId;
if (userId == null) return;
await http.post(
Uri.parse('https://sumly.dev/api/v1/events'),
headers: {'Authorization': 'Bearer $_sumlyKey', 'Content-Type': 'application/json'},
body: jsonEncode({'events': [
{...event, 'user_id': userId, 'platform': Platform.isIOS ? 'ios' : 'android'},
]}),
);
}
Future<void> sumlyScreen(String screen) => _send({'type': 'screen', 'screen': screen});
Future<void> sumlyTrack(String name, [Map<String, Object?>? props]) =>
_send({'type': 'track', 'name': name, if (props != null) 'props': props});
class SumlyObserver extends NavigatorObserver {
@override
void didPush(Route route, Route? previousRoute) {
final name = route.settings.name;
if (name != null) sumlyScreen(name);
}
}
```
Flags: All of one person's flags in one call, worked out on Sumly's server. Keep the answer for the session; send $flag_seen once when an experiment's value is used.
```
Future<Map<String, dynamic>> sumlyFlags({Map<String, Object> properties = const {}}) async {
final r = await http.post(
Uri.parse('https://sumly.dev/api/v1/flags'),
headers: {'Authorization': 'Bearer $_sumlyKey', 'Content-Type': 'application/json'},
body: jsonEncode({'id': sumlyUserId, 'user_id': sumlyUserId, 'platform': Platform.isIOS ? 'ios' : 'android', 'properties': properties}),
);
if (r.statusCode != 200) return {};
return (jsonDecode(r.body)['flags'] as Map<String, dynamic>);
}
// final flags = await sumlyFlags();
// final on = flags['new-checkout']?['value'] == true;
// final plan = flags['paywall']?['variant'] ?? 'monthly';
```
Side by side: PostHog's lines stay while you compare.
```
MaterialApp(
navigatorObservers: [PosthogObserver(), SumlyObserver()],
// …
);
Future<void> signedIn(String userId) async {
await Posthog().identify(userId: userId);
sumlyUserId = userId;
}
Future<void> startedTrial(String plan) async {
await Posthog().capture(eventName: 'trial_started', properties: {'plan': plan});
await sumlyTrack('trial_started', {'plan': plan});
}
```
Keep in mind: Until the person has a user id, sumly.dart sends nothing. Use RevenueCat's app user id, which exists from the first launch, if you want anonymous people counted too. Imported PostHog months show usage, people and sources; which screen led to a purchase starts with the events you send to Sumly.
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 Flutter'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
With no SDK, consent is your app's to keep: send nothing until the person agrees, where your app asks first.
Purchases
Purchases come from RevenueCat, Adapty or Superwall, not from your app. Send as user_id the person they know, and each purchase 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
- Until the person has a user id, sumly.dart sends nothing. Use RevenueCat's app user id, which exists from the first launch, if you want anonymous people counted too.
- Imported PostHog months show usage, people and sources; which screen led to a purchase starts with the events you send to Sumly.
From From PostHog on Flutter's own documentation, checked 20 November 2026: posthog.com/docs/libraries/flutter, api.flutter.dev/flutter/widgets/NavigatorObserver-class.html, posthog.com/docs/api/queries .
From PostHog on Flutter questions
Is there a Sumly package for Flutter?
Not yet. The events API takes the same screens and events the app SDKs send, with the public key, so a few lines of Dart do the job until there is one.
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.
What about PostHog's feature flags?
They move to Sumly: sumlyFlags asks the flags API once for all of a person's flags, worked out on Sumly's server. An experiment in Visitors › Flags counts each variant's paying customers and revenue. Keep a flag's key and rollout and the same people stay in.
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.