Enable Session Replay on iOS
Overview
Follow this guide to enable Session Replay for Real User Monitoring (RUM) in your iOS 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 iOS RUM SDK in your app.
Note
The Session Replay feature extends the iOS 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
- Captures screenshots periodically, every 10 seconds.
- Masks all images, faces, and credit card information.
You can customize these defaults using the options below.
Configure and initialize
Use the SessionReplayOptions
class to configure capture behavior, privacy masking, and sampling.
Example
let options = SessionReplayOptions(
captureTimeInterval: 5.0,
maskText: [".*"], // Mask all visible text
maskAllImages: true, // Mask all images
maskFaces: true, // Mask detected faces
autoStartSessionRecording: true
)
SessionReplay.initializeWithOptions(sessionReplayOptions: options)
Options reference
Configuration fields for SessionReplayOptions
:
Option | Type | Description | Default |
---|---|---|---|
autoStartSessionRecording | Bool | Start recording automatically | false |
captureTimeInterval | Double | Seconds between captures. Min: 1.0 | 10.0 |
captureScale | CGFloat | Screenshot resolution scale factor. Lower values reduce image size and memory usage | 2.0 |
captureCompressionQuality | CGFloat | Image compression (0.0 -1.0 ). Lower values reduce fidelity and file size | 1.0 |
sessionRecordingSampleRate | Int (0–100) | % of sessions to capture | 100 |
maskText | [String]? | Text patterns to redact (strings or regex) | nil |
maskImages | Bool | Mask all credit card images | false |
maskAllImages | Bool | Mask all images | true |
maskFaces | Bool | Mask detected faces | false |
creditCardPredicate | [String]? | Custom patterns to detect credit card-related images | nil |
Image capture triggers
Screenshots are captured during session replay in the following cases:
- Periodically, based on the configured
captureTimeInterval
(default: every 10 seconds). - When the user taps the screen.
- When the user navigates between screens or views.
- When an error or crash occurs.
- When a screen capture event is triggered via
SessionReplay.shared.captureEvent()
.
This hybrid approach ensures that relevant context is captured even between interval windows.
Start and stop recording
If autoStartSessionRecording
is false
, use the following methods to manually control recording:
Manually capture screen
Use captureEvent
to manually capture a specific moment in the session.
Example
Privacy and masking
Coralogix provides flexible masking options to help you meet privacy requirements:
- Text masking: Use string or regex patterns in
maskText
to redact on-screen text. - Image masking: Use
maskImages
ormaskAllImages
to control which images are blurred. - Face detection: Enable
maskFaces
to blur detected faces. - Credit card image detection: Use
creditCardPredicate
to define additional patterns for specific card types or formats that may not be covered by the default detection.
Tip: Session Replay masks all images and redacts common credit card patterns by default. Always verify your masking rules in staging before going live.