Skip to content

feat: add manual start and stop recording#256

Open
ioannisj wants to merge 4 commits intomainfrom
feat/start-stop-session-recording
Open

feat: add manual start and stop recording#256
ioannisj wants to merge 4 commits intomainfrom
feat/start-stop-session-recording

Conversation

@ioannisj
Copy link
Collaborator

@ioannisj ioannisj commented Jan 21, 2026

💡 Motivation and Context

Closes #124
Docs PR: PostHog/posthog.com#14487

  • Add manual session recording control APIs (iOS, Android, Web)
  • Expose isSessionReplayActive to match iOS and Android implementation

💚 How did you test it?

Manual testing:

  • iOS
  • Android
  • Web

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

@ioannisj ioannisj marked this pull request as ready for review January 29, 2026 18:35
@ioannisj ioannisj requested a review from a team January 29, 2026 18:35
@@ -1,5 +1,9 @@
## Next

- feat: add manual session recording control APIs ([#256](https://github.com/PostHog/posthog-flutter/pull/256))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do those API work even if config.sessionReplay is disabled or both ways?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what we did for the other sdks I believe. So if local config is false, people can start a recording later on manually.

If remote config/flags is false, then no-op

Trying to validate these with some local testing


@override
Future<void> startSessionRecording({bool resumeCurrent = true}) async {
if (!isSupportedPlatform()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!isSupportedPlatform()) {
if (!isSupportedPlatform() || macOS) {

all those methods should bail if its a macOS app since replay isnt supported, theres no need to call method channels if we know its not gonna work
the code above is just pseudocode

Copy link
Member

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left 2 comments otherwise LGTM

@ioannisj ioannisj requested a review from a team as a code owner February 6, 2026 15:54
@ForTheYin
Copy link

Hi PostHog team,

Thanks for adding this feature for Flutter. I've tried out this feature branch on an app and followed the instructions here.

I have the PostHogConfig.sessionReplay boolean set to false and then I attempted to manually record a session.

This is my config:

    final posthogConfig = PostHogConfig(_config.posthogApiKey);
    posthogConfig.host = _config.posthogHost;
    posthogConfig.debug = kDebugMode;
    posthogConfig.captureApplicationLifecycleEvents = true;
    posthogConfig.sessionReplay = false;
    posthogConfig.sessionReplayConfig.maskAllTexts = false;
    posthogConfig.sessionReplayConfig.maskAllImages = false;

   // Some time later...
   Posthog().startSessionRecording(resumeCurrent: false)

   // Also tried it with
   Posthog().startSessionRecording(resumeCurrent: true)

Both startSessionRecording usages create recordings that have timestamps, but no content in the session replay preview (no images fetched).


The recording work normally when I set sessionReplay to true, but then this creates a unwanted session replay.

I also tried to manually remove the config.sessionReplay check in PostHogWidget, but that didn't work either.

    // posthog_widget.dart - PostHogWidgetState, L34
    if (config == null || !config.sessionReplay) {
      return;
    }

iOS 26.0 Simulator & a real Device, Flutter 3.35.7

@ioannisj
Copy link
Collaborator Author

ioannisj commented Feb 7, 2026

Hey @ForTheYin thanx for testing this out! 🙏 I also noticed the same thing happen to me yesterday during a final test before releasing and held off the merge. This used to work fine before so it must be either some late changes made here or in the ingestion side of things. I'll try to sort this asap

@ioannisj
Copy link
Collaborator Author

ioannisj commented Feb 7, 2026

Actually let me correct myself, this used to work with the config enabled, so the happy path you describe here. I bumped into the same issue when config was disabled

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manually start and stop session recordings

3 participants