You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 48c815a
Browse filesBrowse the repository at this point in the historyBrowse files
## DESCRIBE YOUR PR
Document manual Session Replay control for Android, including:
- Starting full-session or buffered recording independently of automatic
sampling
- Pausing recording on sensitive screens and resuming the same replay
- Stopping a replay or flushing pending data in session, buffer, and
stopped states
- Disabling automatic recording with both sample rates set to `0.0`
- Calling the APIs safely from any thread
This gives Android developers the same manual lifecycle guidance
available for the JavaScript SDK while documenting Android-specific
behavior such as the 30-second buffer and persistent manual pause.
Depends on getsentry/sentry-java#5978.
Refs JAVA-691
## IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs
to go live.
- [ ] Urgent deadline (GA date, etc.):
- [ ] Other deadline:
- [x] None: Not urgent, can wait up to 1 week+
## SLA
- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
added an urgent due date to it.
Thanks in advance for your help!
## PRE-MERGE CHECKLIST
- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)
---------
Co-authored-by: OpenAI Codex <noreply@openai.com>
| sessionSampleRate |`io.sentry.session-replay.session-sample-rate`| double |`0.0`| Sample rate for replay sessions that start immediately and last the entirety of the user's session. `1.0` collects all sessions. |
16
-
| onErrorSampleRate |`io.sentry.session-replay.on-error-sample-rate`| double |`0.0`| Sample rate for buffered replays that are triggered when an error occurs. The SDK keeps the previous minute of activity and continues until the session ends when an error is sampled.|
16
+
| onErrorSampleRate |`io.sentry.session-replay.on-error-sample-rate`| double |`0.0`| Sample rate for buffered replays that are triggered when an error occurs. The SDK keeps the previous 30 seconds of activity and continues until the session ends when an error is sampled. |
17
17
18
18
and the following options provide further customization:
19
19
@@ -33,6 +33,37 @@ and the following options provide further customization:
33
33
| beforeErrorSampling |`—`|`BeforeErrorSamplingCallback`|`null`| A callback invoked before the `onErrorSampleRate` is checked. Return `false` to skip replay capture for this error, or `true` to proceed with the normal sample rate check. If the callback throws, replay capture proceeds normally (fail-open). Only configurable in code. See [Ignore Certain Errors from Error Sampling](/platforms/android/session-replay/#ignore-certain-errors-from-error-sampling). |
34
34
35
35
36
+
## Disable Automatic Replay Sampling
37
+
38
+
To configure Session Replay to start only after user consent or an app-specific condition, set both sample rates to `0.0` during initialization. This disables automatic session and error recording while keeping the Session Replay integration available for manual control.
Explicit calls to `Sentry.replay().start()` and `Sentry.replay().startBuffering()` bypass these sample rates. With `onErrorSampleRate` set to `0.0`, call `flush()` to send a manually started buffer. See [Manual Control](/platforms/android/session-replay/#manual-control) for the complete API behavior.
66
+
36
67
## Network Details
37
68
38
69
By default, Replay will capture basic information about all outgoing http requests in your application. This includes the URL, request and response body sizes, method, and status code. The intention is to limit the chance of collecting private data.
Copy file name to clipboardExpand all lines: docs/platforms/android/session-replay/index.mdx
+79-2Lines changed: 79 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ The session will be terminated if the application has spent in the background mo
106
106
107
107
### Replay Captures on Errors Only
108
108
109
-
If you prefer not to record an entire session, you can elect to capture a replay only if an error occurs. In this case, the integration will buffer up to one minute worth of events prior to the error being thrown. It will continue to record the session, following the rules above regarding session life and activity. Read the [sampling](#sampling) section for configuration options.
109
+
If you prefer not to record an entire session, you can elect to capture a replay only if an error occurs. In this case, the integration will buffer up to 30 seconds of events before the error. It will continue to record the session, following the rules above regarding session life and activity. Read the [sampling](#sampling) section for configuration options.
110
110
111
111
## Sampling
112
112
@@ -116,7 +116,7 @@ Sampling allows you to control how much of your website's traffic will result in
116
116
replays that begin recording immediately and last the entirety of the user's session.
117
117
2.`onErrorSampleRate` - The sample rate for
118
118
replays that are recorded when an error happens. This type of replay will record
119
-
up to a minute of events prior to the error and continue recording until the session
119
+
up to 30 seconds of events before the error and continue recording until the session
120
120
ends.
121
121
122
122
Sampling begins as soon as a session starts. `sessionSampleRate` is evaluated first. If it's sampled, the replay recording will begin. Otherwise, `onErrorSampleRate` is evaluated and if it's sampled, the integration will begin buffering the replay and will only upload it to Sentry if an error occurs. The remainder of the replay will behave similarly to a whole-session replay.
Use manual control when replay recording depends on user consent, authentication, or a specific workflow. To disable automatic recording, [set both replay sample rates to `0.0`](/platforms/android/session-replay/configuration/#disable-automatic-replay-sampling).
158
+
159
+
You can call the manual control APIs from any thread. Calls return before the requested operation completes because the SDK queues it.
160
+
161
+
### Start Recording
162
+
163
+
Choose the recording mode that fits your use case:
164
+
165
+
-`start()` starts a full-session replay.
166
+
-`startBuffering()` keeps a rolling buffer of up to 30 seconds. If `onErrorSampleRate` samples an error, the SDK sends the buffer automatically. Call `flush()` to send it without an error or sampling decision. After either action, recording continues in session mode.
167
+
168
+
Explicit calls to `start()` and `startBuffering()` bypass the configured replay sample rates when starting recording. If a replay is already recording, both methods do nothing.
169
+
170
+
```kotlin {tabTitle:Kotlin}
171
+
// Start a full-session replay.
172
+
Sentry.replay().start()
173
+
174
+
// Or start a buffered replay instead.
175
+
Sentry.replay().startBuffering()
176
+
```
177
+
178
+
```java {tabTitle:Java}
179
+
// Start a full-session replay.
180
+
Sentry.replay().start();
181
+
182
+
// Or start a buffered replay instead.
183
+
Sentry.replay().startBuffering();
184
+
```
185
+
186
+
### Pause Recording on Sensitive Screens
187
+
188
+
Pause recording before showing sensitive content, such as a PIN entry screen, and resume it after the content is hidden. The SDK preserves a manual pause across app background and foreground transitions and when it automatically starts a new replay session in the same app process. Call `resume()` to continue recording. The pause state resets when the app process restarts. Calling `resume()` when replay is stopped does nothing; call `start()` or `startBuffering()` to create a new replay.
189
+
190
+
```kotlin {tabTitle:Kotlin}
191
+
Sentry.replay().pause()
192
+
193
+
// Resume the same replay after leaving the sensitive screen.
194
+
Sentry.replay().resume()
195
+
```
196
+
197
+
```java {tabTitle:Java}
198
+
Sentry.replay().pause();
199
+
200
+
// Resume the same replay after leaving the sensitive screen.
201
+
Sentry.replay().resume();
202
+
```
203
+
204
+
The SDK can't determine whether foregrounding returns to the same sensitive screen or opens a different screen. For example:
205
+
206
+
- If the app returns to the PIN entry screen, leave replay paused.
207
+
- If a deep link opens a non-sensitive product screen, call `resume()` from that destination after the sensitive content is no longer visible.
208
+
- If a notification or normal navigation opens another non-sensitive screen, call `resume()` from the new screen instead of from the sensitive screen's exit callback.
209
+
210
+
### Stop or Flush Recording
211
+
212
+
Call `stop()` to end the current replay. In session mode, the SDK sends any pending segment before stopping. In buffer mode, it discards the unsent buffer. A later call to `start()` or `startBuffering()` creates a new replay session.
213
+
214
+
```kotlin {tabTitle:Kotlin}
215
+
Sentry.replay().stop()
216
+
```
217
+
218
+
```java {tabTitle:Java}
219
+
Sentry.replay().stop();
220
+
```
221
+
222
+
Call `flush()` to send the current replay data without stopping the recording. In session mode, it sends the pending segment and continues recording. In buffer mode, it sends the buffer and switches to session mode. Calling `flush()` while recording is stopped starts a new full-session replay.
223
+
224
+
```kotlin {tabTitle:Kotlin}
225
+
Sentry.replay().flush()
226
+
```
227
+
228
+
```java {tabTitle:Java}
229
+
Sentry.replay().flush();
230
+
```
231
+
155
232
## Privacy
156
233
157
234
The SDK is recording and aggressively masking all text, images, and webviews by default. If your app has any sensitive data, you should only turn the default masking off after explicitly masking out the sensitive data, using the APIs described below.
0 commit comments