Skip to content

Commit c440bd5

Browse files
authored
chore: flutter manual start and stop recording (#14487)
* chore: flutter manual start and stop recording * feat: move manual session controls to replay section * fix: extract privacy note
1 parent c16441b commit c440bd5

13 files changed

+133
-82
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
> Requires PostHog Android SDK version >= [3.16.0](https://github.com/PostHog/posthog-android/releases/tag/3.16.0).
2+
3+
Setting `config.sessionReplay = false` in your PostHog configuration will prevent PostHog from automatically starting session recordings on SDK setup.
4+
5+
You can manually control when to start and stop session recordings using the following methods:
6+
7+
- `startSessionReplay(resumeCurrent: Boolean)`
8+
- Set **resumeCurrent** to `true` to resume a previous session recording (Default).
9+
- Set **resumeCurrent** to `false` to start a new session recording.
10+
- `stopSessionReplay()`
11+
- Stops/pauses the current session recording.
12+
13+
> **Note:** Calling these methods will have no effect if session recordings are disabled in your PostHog [Project Settings](https://app.posthog.com/project/settings).

contents/docs/session-replay/_snippets/android-privacy.mdx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import SensitiveThirdPartyScreens from "./sensitive-third-party-screens.mdx"
2+
13
To replace any type of `View` with a redacted version in the recording, set the [tag](https://developer.android.com/reference/android/view/View#tags) to `ph-no-capture`.
24

35
```xml
@@ -28,20 +30,4 @@ To replace any type of `View` with a redacted version in the recording, set the
2830
...
2931
```
3032

31-
### Handling sensitive third-party screens
32-
33-
Third-party components (like payment forms or authentication screens) are often rendered in separate view hierarchies that can't be accessed or modified for masking.
34-
35-
For these cases, manually controlling the recording state is the only reliable solution. For example:
36-
37-
```android_kotlin
38-
// Stop session recording before showing a third-party payment sheet
39-
PostHog.stopSessionReplay()
40-
41-
// Present third-party payment sheet
42-
presentPaymentSheet()
43-
44-
// ...
45-
// Some time later when the sheet is dismissed, resume recording
46-
PostHog.startSessionReplay()
47-
```
33+
<SensitiveThirdPartyScreens />

contents/docs/session-replay/_snippets/flutter-installation.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,19 @@ This is needed as Flutter renders your app using a browser canvas element.
6464
classes="rounded"
6565
/>
6666

67-
## Step three: Configure replay settings
67+
## Step three: Configure replay settings
6868

69-
Add `sessionReplay = true` to your PostHog configuration alongside any of your other configuration options:
69+
### Automatically start session recordings
70+
71+
Setting `config.sessionReplay = true` in your PostHog configuration will start session recordings on SDK setup.
72+
73+
### Manually control session recordings
74+
75+
You can programmatically start and stop session recordings. See [how to control which sessions you record](/docs/session-replay/how-to-control-which-sessions-you-record#programmatically-start-and-stop-recordings) for details.
76+
77+
### Configuration options
78+
79+
You can customize session replay behavior with the following configuration options:
7080

7181
```dart
7282
final config = PostHogConfig('<ph_project_api_key>');
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
> Requires PostHog Flutter SDK version >= [5.14.0](https://github.com/PostHog/posthog-flutter/releases/5.14.0). Available on iOS, Android, and Web.
2+
3+
Setting `config.sessionReplay = false` in your PostHog configuration will prevent PostHog from automatically starting session recordings on SDK setup.
4+
5+
You can manually control when to start and stop session recordings using the following methods:
6+
7+
- `startSessionRecording({bool resumeCurrent = true})`
8+
- Set **resumeCurrent** to `true` to resume a previous session recording (Default).
9+
- Set **resumeCurrent** to `false` to start a new session recording.
10+
- `stopSessionRecording()`
11+
- Stops/pauses the current session recording.
12+
13+
> **Note:** Calling these methods will have no effect if session recordings are disabled in your PostHog [Project Settings](https://app.posthog.com/project/settings).

contents/docs/session-replay/_snippets/flutter-privacy.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import SensitiveThirdPartyScreens from "./sensitive-third-party-screens.mdx"
2+
13
### Masking All Texts and Images
24

35
```dart
@@ -20,3 +22,5 @@ config.sessionReplayConfig.maskAllImages = false;
2022
const PostHogMaskWidget(child: Text('Sensitive!'))
2123
...
2224
```
25+
26+
<SensitiveThirdPartyScreens />

contents/docs/session-replay/_snippets/ios-installation.mdx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,7 @@ Setting `config.sessionReplay = true` to your PostHog configuration will start s
3636

3737
### Manually control session recordings
3838

39-
Setting `config.sessionReplay = false` to your PostHog configuration will prevent PostHog from automatically starting session recordings on SDK setup.
40-
41-
You can manually control when to start and stop session recordings using the following two methods:
42-
43-
- `startSessionRecording(resumeCurrent: Bool)`
44-
- Set **resumeCurrent** to `true` to resume a previous session recording (Default).
45-
- Set **resumeCurrent** to `false` to start a new session recording.
46-
- `stopSessionRecording()`
47-
- Stops/pauses the current session recording.
48-
49-
> **Note:** Calling these methods will have no effect if session recordings are disabled in your PostHog [Project Settings](https://app.posthog.com/project/settings).
39+
You can programmatically start and stop session recordings. See [how to control which sessions you record](/docs/session-replay/how-to-control-which-sessions-you-record#programmatically-start-and-stop-recordings) for details.
5040

5141
## Configuration options
5242

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
> Requires PostHog iOS SDK version >= [3.19.0](https://github.com/PostHog/posthog-ios/releases/tag/3.19.0).
2+
3+
Setting `config.sessionReplay = false` in your PostHog configuration will prevent PostHog from automatically starting session recordings on SDK setup.
4+
5+
You can manually control when to start and stop session recordings using the following methods:
6+
7+
- `startSessionRecording(resumeCurrent: Bool)`
8+
- Set **resumeCurrent** to `true` to resume a previous session recording (Default).
9+
- Set **resumeCurrent** to `false` to start a new session recording.
10+
- `stopSessionRecording()`
11+
- Stops/pauses the current session recording.
12+
13+
> **Note:** Calling these methods will have no effect if session recordings are disabled in your PostHog [Project Settings](https://app.posthog.com/project/settings).

contents/docs/session-replay/_snippets/ios-privacy.mdx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import SensitiveThirdPartyScreens from "./sensitive-third-party-screens.mdx"
2+
13
To replace any type of `UIView` with a redacted version in the replay, set the [accessibilityIdentifier](https://developer.apple.com/documentation/uikit/uiaccessibilityidentification/1623132-accessibilityidentifier) to `ph-no-capture`:
24

35
```swift
@@ -35,20 +37,4 @@ Apps built with Xcode 26 use a new SwiftUI rendering model that changes how Swif
3537

3638
</CalloutBox>
3739

38-
### Handling sensitive third-party screens
39-
40-
Third-party components (like payment forms or authentication screens) are often rendered in separate view hierarchies that can't be accessed or modified for masking.
41-
42-
For these cases, manually controlling the recording state is the only reliable solution. For example:
43-
44-
```ios_swift
45-
// Stop session recording before showing a third-party payment sheet
46-
PostHogSDK.shared.stopSessionRecording()
47-
48-
// Present third-party payment sheet
49-
presentPaymentSheet()
50-
51-
// ...
52-
// Some time later when the sheet is dismissed, resume recording
53-
PostHogSDK.shared.startSessionRecording()
54-
```
40+
<SensitiveThirdPartyScreens />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support for programmatic start/stop in React Native is planned. You can track progress in [issue #2169](https://github.com/PostHog/posthog-js/issues/2169).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Handling sensitive third-party screens
2+
3+
For third-party components (like payment forms or authentication screens) that can't be masked, you can manually stop and start session recordings. See [how to control which sessions you record](/docs/session-replay/how-to-control-which-sessions-you-record#programmatically-start-and-stop-recordings) for details.

0 commit comments

Comments
 (0)