Every Flutter app has an awkward gap at launch. The SDK starts, the first screen renders, and the feature flag response has not arrived yet. For a few hundred milliseconds, or several seconds on a poor connection, your app does not know which variant to show or who the user is.
Version 5.31.0 of the PostHog Flutter SDK added a bootstrap option to its config. You can pre-seed a distinct ID and flag values before the first flags response, and early events and flag reads use them straight away.
Without measuring this, first-launch experiments quietly go wrong. Users see the default experience, then flip to a variant mid-session. Events fire against an anonymous ID that later has to be merged. Your funnel and your experiment results both end up muddy.
Data Points to Track
- bootstrap_enabled: whether the session started with bootstrap values supplied
- bootstrap_distinct_id_source: where the ID came from, such as secure storage, your backend or a fresh anonymous ID
- flags_ready_ms: time from SDK setup to the first real flags response
- flag_source: whether a flag read returned a bootstrap value or a server value
- flag_value_changed: true when the server value differs from the bootstrap value
- flag_key and variant: which experiment was affected
- is_first_launch: separates new installs from returning users
- network_type: wifi, cellular or offline at launch
- app_version and sdk_version: to compare releases
Setup Steps
- Upgrade posthog_flutter to 5.31.0 or later.
- Decide what to bootstrap. Usually this is the signed-in user ID and the last known flag values cached from the previous session.
- Set the bootstrap config on PostHogConfig before calling setup().
- Record flag_source every time you read a flag during startup, so you can see how often bootstrap values were used.
- Compare after the response. When the real flags arrive, emit flag_value_changed if any value differs from what you served.
- Capture flags_ready_ms as a property on your first screen view event.
- Build a dashboard showing flags_ready_ms percentiles and the share of sessions with changed flags.
Actionable Insights
A high flag_value_changed rate means your cached values are stale. Refresh them more often, or shorten how long you trust them.
If flags_ready_ms is long on cellular but short on wifi, bootstrap is doing real work for those users. Keep it, and consider showing a neutral loading state for flags that cannot be pre-seeded.
Compare experiment results with and without bootstrap. If the bootstrap group converts differently from the rest, you may have a sample bias, since returning users are more likely to have cached values than new installs.
Check the first-launch cohort separately. New users have nothing to bootstrap, so they carry the worst flicker and the least reliable attribution. Fix that group first.
Common Pitfalls
Do not bootstrap a distinct ID you cannot trust. A wrong ID merges two people into one profile, which is harder to repair than a few anonymous events. Also avoid caching flag values forever. A removed experiment can keep serving its old variant if nothing ever invalidates the cache.
Test cold starts in airplane mode and on a throttled connection before every release. Those are the conditions where bootstrap behaviour matters most.