Screen views are the backbone of most Flutter funnels. They are also easy to get wrong when an app has nested navigators. PostHog’s Flutter SDK 5.56.1, released on 21 October, fixes a leak where PosthogObserver registered itself with WidgetsBinding and never unregistered, leaving one observer behind for every navigator, such as each nested auto_route router.
Without tracking, a leak like this hides in plain sight. Memory creeps up over a long session, and your screen data may carry duplicates or odd timing, because old observers can keep reacting after their screens have gone. Users blame the app for feeling slow, and your dashboards cannot tell you why.
Data Points to Track
- sdk_version: the PostHog Flutter version in the build
- navigator_count: how many navigators the app has created in the session
- screen_view_count: screen views per session
- duplicate_screen_views: same screen name twice within a second
- memory_mb_at_end: memory use when the session ends
- session_length_min: minutes between first and last event
- router_package: the navigation library in use, for example auto_route
- app_version: your own build number
Setup Steps
- Record a baseline of memory use and screen views per session on your current build.
- Upgrade the PostHog Flutter plugin to 5.56.1 or later in a test build.
- Add navigator_count as a property on a custom session event, or log it from your router.
- Detect duplicates by flagging identical screen names fired within one second.
- Sample memory at the end of long sessions using your performance tool.
- Run a soak test that opens and closes nested routes many times, then compare memory before and after.
- Release to a small group and compare sdk_version cohorts for a week.
- Review the results with your mobile team and keep the baseline for future upgrades.
Actionable Insights
If duplicate screen views fall after the upgrade, your funnel counts were inflated before. Expect conversion rates to shift slightly, and note the date so trends are not misread.
If memory at session end flattens on long sessions, the leak was real in your app. If nothing changes, your navigation setup may not have been affected, and you can stop looking at the SDK.
Heavy users matter most. Segment by navigator_count and session length, because people who move through many nested routes were the ones most exposed.
Check router_package too. If the problem clusters around one routing library, share your findings with that project and with your own team before adding workarounds.
Common Pitfalls
Do not compare sessions of very different lengths when judging memory.
Do not edit old screen data. Annotate the version change instead.
Do not remove manual screen events until you have confirmed the observer behaves as expected.
Keeping Navigation Data Reliable
Screen tracking only helps when each view is counted once. Treat observer behaviour as part of your tracking plan, test it after each SDK upgrade, and keep a short log of version changes beside your funnels. That habit makes every later anomaly easier to explain.