Flutter session replay installation
- 1
Install the package
RequiredAdd the PostHog Flutter SDK to your
pubspec.yaml:pubspec.yamlSDK versionSession replay requires PostHog Flutter SDK version 4.7.0 or higher. We recommend always using the latest version.
- 2
Disable auto-init for Android
RequiredFor session replay, you need to use manual initialization. Add this to your
AndroidManifest.xmlto disable auto-init:android/app/src/main/AndroidManifest.xmlUpdate the minimum Android SDK version to 21 in
android/app/build.gradle:android/app/build.gradle - 3
Disable auto-init for iOS
RequiredAdd this to your
Info.plistto disable auto-init:ios/Runner/Info.plistUpdate the minimum platform version to iOS 13.0 in your
Podfile:Podfile - 4
Enable session recordings in project settings
RequiredGo to your PostHog Project Settings and enable Record user sessions. Session recordings will not work without this setting enabled.
If you're using Flutter Web, also enable the Canvas capture setting. This is required as Flutter renders your app using a browser canvas element.
- 5
Initialize PostHog with session replay
RequiredInitialize PostHog in your
main.dartwith session replay enabled. Here are all the available options:main.dartFor more configuration options, see the Flutter session replay docs.
- 6
Wrap your app with PostHogWidget
RequiredFor Session Replay to work, wrap your app with
PostHogWidgetand add thePosthogObserver:MyApp.dartMyApp.dart - 7
Watch session recordings
RecommendedVisit your site or app and interact with it for at least 10 seconds to generate a recording. Navigate between pages, click buttons, and fill out forms to capture meaningful interactions.
- 8
Next steps
RecommendedNow that you're recording sessions, continue with the resources below to learn what else Session Replay enables within the PostHog platform.
Resource Description Watching recordings How to find and watch session recordings Privacy controls How to mask sensitive data in recordings Network recording How to capture network requests in recordings Console log recording How to capture console logs in recordings More tutorials Other real-world examples and use cases