Configuration
Learn about the general Session Replay configuration fields.
On Android you configure Session Replay by creating <meta-data> entries inside your AndroidManifest.xml (Options configuration), or alternatively in code SentryAndroid.init(context) { options -> ... } (Manual Initialization).
The SDK exposes the following main options to configure Session Replay for your project:
| Key | AndroidManifest | Type | Default | Description |
|---|---|---|---|---|
| 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. |
| 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. |
and the following options provide further customization:
| Key | AndroidManifest | Type | Default | Description |
|---|---|---|---|---|
| maskAllText | io.sentry.session-replay.mask-all-text | boolean | true | Masks all text-containing views by default. Setting this to false adds TextView classes to the unmask list so text appears in replays. |
| maskAllImages | io.sentry.session-replay.mask-all-images | boolean | true | Masks image views by default. Turning this off moves ImageView into the unmask list so bitmap content is visible in replays. |
| quality | — | enum | SentryReplayQuality.MEDIUM | Defines the image quality of the session replay; higher quality yields a more accurate replay at the cost of more data transfer and CPU work. |
| screenshotStrategy | io.sentry.session-replay.screenshot-strategy | enum | ScreenshotStrategyType.PIXEL_COPY | Determines how the SDK captures screenshots. PIXEL_COPY is the default and offers better performance with masking, while CANVAS always masks text and images and is intended for strict PII environments (See ScreenshotStrategy). |
| networkDetailAllowUrls | io.sentry.session-replay.network-detail-allow-urls | List<String> | [] | Regexp patterns of URLs to enable capture of request/response bodies and headers. You can mix plain strings and regexes to capture only the traffic you want. |
| networkDetailDenyUrls | io.sentry.session-replay.network-detail-deny-urls | List<String> | [] | Regexp patterns of URLs to never enable capture of request/response bodies and headers, even if an allow pattern matches them. |
| networkCaptureBodies | io.sentry.session-replay.network-capture-bodies | boolean | true | Controls whether request and response bodies are captured for allowed URLs. |
| networkRequestHeaders | io.sentry.session-replay.network-request-headers | List<String> | ['Content-Type', 'Content-Length', 'Accept'] | Request header names to capture for enabled URLs. |
| networkResponseHeaders | io.sentry.session-replay.network-response-headers | List<String> | ['Content-Type', 'Content-Length', 'Accept'] | Response header names to capture for enabled URLs. |
| debug | io.sentry.session-replay.debug | boolean | false | Enables Session Replay debug logging, which prints diagnostic information when a replay is recorded. |
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.
To capture additional information such as request and response headers or bodies, you'll need to opt-in via networkDetailAllowUrls. This will make it possible for you to elect to only add URLs that are safe for capturing bodies and avoid any endpoints that may contain Personal Identifiable Information (PII).
Body and header content will be PII-sanitized server-side, based on object keys and values. Refer to Server-Side Scrubbing for more details.
- SDK version >= 8.29.0
- Android Gradle Plugin version >= 6.0.0-beta.3
- OkHttp
If you've configured networkDetailAllowUrls but don't see request/response bodies or headers in your replays, see our troubleshooting guide for help.
Any URL matching the given pattern(s) will then be captured with additional details:
SentryAndroid.init(this) { options ->
options.sessionReplay.networkDetailAllowUrls = listOf("https://example.com")
}
If you give us a string, we'll match any URL that contains that string using Java's String#matches()). This way, you can use a regex to handle exact or more complex matches.
Requests to a URL matched by the configured patterns will be enhanced with request and response bodies, as well as the following default headers:
Content-TypeContent-LengthAccept
If you want to capture additional headers, you'll have to configure them with the options networkRequestHeaders and networkResponseHeaders, for example:
<application>
<meta-data
android:name="io.sentry.session-replay.network-request-headers"
android:value="Cache-Control,X-My-Header"
/>
<meta-data
android:name="io.sentry.session-replay.network-response-headers"
android:value="Referrer-Policy,X-Response-Header"
/>
</application>
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").