Enable Session Replay on Android
Overview
Follow this guide to enable Session Replay for Real User Monitoring (RUM) in your Android app.
Session Replay captures a visual sequence of user interactions in your app by recording periodic screenshots. This allows you to analyze what the user saw before, during, and after an issue — helping you quickly pinpoint the source of errors, performance slowdowns, or unexpected behavior. Use Session Replay to recreate the user experience and better understand the context behind each session.
Prerequisites
Before enabling Session Replay, you must install and initialize the Coralogix Android RUM SDK in your app.
Note
The Session Replay feature extends the Android RUM SDK and must be initialized after the base SDK setup. Attempting to initialize Session Replay without the base SDK will result in an initialization error.
Session Replay by default
Session Replay on Android:
- Evaluates UI one frame per second (FPS) and captures only if the layout changed since the previous screenshot.
- Masks all text inputs (when
maskAllTexts
is enabled). - Redacts sensitive input field types (passwords, emails, numbers, etc.) if specified.
- Samples 100% of sessions by default.
You can customize these defaults using the configuration options below.
Configure and initialize
Use the SessionReplayOptions
class to configure capture behavior, privacy masking, and sampling.
Example
import android.app.Application
import com.coralogix.android.sdk.session_replay.SessionReplay
import com.coralogix.android.sdk.session_replay.model.SessionReplayOptions
import com.coralogix.android.sdk.internal.infrastructure.display.enums.EditTextType
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
val options = SessionReplayOptions(
captureScale = 0.5f, // Scale screenshots to half resolution
captureCompressQuality = 0.8f, // Compress images for size optimization
sessionRecordingSampleRate = 80, // Capture 80% of sessions
autoStartSessionRecording = true, // Start recording automatically
maskAllTexts = false, // Do not mask all text by default
maskInputFieldsOfTypes = listOf(
EditTextType.PASSWORD,
EditTextType.EMAIL
)
)
SessionReplay.initialize(this, options)
}
}
Options reference
Configuration fields for SessionReplayOptions
:
Option | Type | Description | Default |
---|---|---|---|
autoStartSessionRecording | Boolean | Start recording automatically | true |
captureScale | Float | Screenshot resolution scale factor (0–1). Lower values reduce size and memory usage | 0.5f |
captureCompressQuality | Float | Image compression (0–1). Lower values reduce fidelity and file size | 1.0f |
sessionRecordingSampleRate | Int (0–100) | % of sessions to capture | 100 |
maskAllTexts | Boolean | Redact all on-screen text | true |
maskInputFieldsOfTypes | List<EditTextType> | Redact only specific input fields (e.g., password, email, phone) | emptyList() |
Image capture triggers
Screenshots are captured during session replay in the following cases:
- User taps anywhere on the screen.
- User navigates between activities or fragments.
- Screen layout changes.
- Error or crash occurs.
- Manual screen capture event via
SessionReplay.captureScreenshot()
.
Android Session Replay combines a 1 FPS layout-change sampling *with *event-based captures (click, error), so you still see key moments even if they occur between checks
Start and stop recording
If autoStartSessionRecording
is false
, you can manually control recording:
Manually capture screen
Use captureScreenshot
to capture a specific moment in the session:
Privacy and masking
Coralogix provides flexible masking options to help you meet privacy requirements:
- Text masking: Use
maskAllTexts
to redact all on-screen text, or selectively mask only input fields viamaskInputFieldsOfTypes
. - Input field masking: Protect sensitive data such as passwords, emails, phone numbers, and credit card fields by specifying their
EditTextType
. - View masking: You can programmatically mark a specific view as sensitive:
This ensures that the view’s contents are blurred in session replays.
Tip: Always verify your masking rules in staging before going live, especially for sensitive inputs like login screens and payment forms.