Skip to content

Respect session replay feature flag after /config endpoint call #441

Open

Description

@ioannisj

Description

Ticket: https://posthoghelp.zendesk.com/agent/tickets/20809 (moved to PostHog: https://us.posthog.com/project/2/support/tickets/29952)

Session recordings start as soon as the app launches, but feature flag evaluation is executed asynchronously.
If the cached value is different that the value returned from /decide endpoint, then the recording may start (and not stop) when the flag evaluates to false

A possible fix is to mem-cache screenshots and skip processing until the /decide API has been successfully called - there are some memory footprint consideration here. We may need to use a different disk-backed queue, and drop or merge the queues once the flag evaluates?

Activity

  1. o-mid commented on Sep 28, 2026

    @o-mid
    Contributor

    Looked at this on current main. I don't think a Dart change is the right fix.

    Flutter does not upload replay itself. sendMetaEvent / sendFullSnapshot become $snapshot captures, and both native SDKs put those on the replay queue:

    • Android: SnapshotSender calls List<RREvent>.capture(), which is PostHog.capture and then replayQueue.add
    • iOS: PosthogFlutterPlugin calls PostHogSDK.shared.capture("$snapshot", ...), which also goes to replayQueue

    That queue is what holds snapshots until the first live /config and drops them if replay is off:

    Dart does start the screenshot loop when PostHogConfig.sessionReplay is true. ScreenshotCapturer.captureScreenshot() still returns without sending when getSessionReplayState() reports isActive == false. While the cached flag is on, isActive stays true and frames are handed to native, which is the buffered path. After /config turns replay off, the next tick stops sending.

    Same conclusion as on the React Native issue: PostHog/posthog-js#3859 (comment)

    The sdk-spec for remote config also treats Flutter as a wrapper: it forwards sessionReplay to the native SDKs and does not own the /config fetch. Happy to revisit if $snapshot from this plugin is supposed to bypass that queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions