Product Benefits Pricing Guides Docs About Contact us Try it out
Analytics tools

PostHog Flutter Opt-Out Replay Tracking

PostHog Flutter opt-out replay tracking: optOut() now stops session replay in 5.51.1. Measure consent state and confirm no recording continues.

· 3 min read

A user taps “no thanks” on your analytics consent screen. Your event capture stops, but is anything still recording their screen? If session replay keeps running after an opt-out, you have a privacy problem that no dashboard will show you.

The PostHog Flutter SDK 5.51.0 added optIn() and optOut(), replacing enable() and disable(). Version 5.51.1 then made optOut() stop session replay, and optIn() start a new recording only if one was actually stopped. That makes consent changes a measurable event rather than a silent switch.

Data Points to Track

  • consent_state: opted_in, opted_out or unknown
  • consent_changed_at: timestamp of the last change
  • consent_source: onboarding, settings screen or system prompt
  • replay_active: whether a recording is running right now
  • replay_stopped_by_opt_out: true when optOut() ended a recording
  • replay_restarted_by_opt_in: true when optIn() began a new recording
  • events_after_opt_out: count of events received after an opt-out
  • recordings_after_opt_out: count of replays that start after an opt-out
  • posthog_flutter_version: SDK version in use
  • platform: iOS, Android or web

Setup Steps

  1. Upgrade posthog_flutter to 5.51.1 or later.
  2. Replace every call to enable() and disable() with optIn() and optOut().
  3. Replace sendFeatureFlagEvents with sendFeatureFlagEvent in your config.
  4. Record consent changes in your own audit log, with the source screen.
  5. Test the opt-out path: start a recording, call optOut(), and confirm it stops.
  6. Test the opt-in path: call optIn() and confirm a new recording begins only if one was stopped.
  7. Check data in PostHog for sessions with a start time after the opt-out.
  8. Alert when recordings_after_opt_out is above zero.

Actionable Insights

Any recording that starts after an opt-out is a defect. Treat it as a bug with high priority, and find out whether it came from an old SDK version still in the wild.

Compare opt-out rates by consent source. A much higher rate on one screen suggests unclear wording, not stronger privacy views.

Watch the gap between a consent change and the last captured event. A long gap can mean a queued batch was sent after the user said no.

Opt-in rates also tell you about trust. If users opt back in from settings, your original prompt may have asked at the wrong moment.

How to Verify It Works

Write a short test plan and run it on every release. Start a session, perform a few taps, then call optOut() and keep using the app for a minute. In PostHog, the recording should end at the moment of opt-out and no new events should appear afterwards. Then call optIn() and confirm a fresh recording starts.

Repeat the test after a cold start with consent already stored. Many consent bugs only appear when the app launches in an opted-out state and a screen initialises the SDK before the saved choice is read. Run the same checks on iOS, Android and, if you ship it, web, because each platform handles startup differently.

Common Pitfalls

Do not rely on the old disable() behaviour. It is deprecated, and replay handling changed.

Do not assume every user has updated. Segment by SDK version before trusting the numbers.

Do not store the consent flag only in memory. It must survive an app restart.

Why Product Teams Should Care

Consent is a promise. Being able to show that a screen recording stopped when a user asked is far stronger than saying it should have.