Skip to content

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:
OptionTypeDescriptionDefault
autoStartSessionRecordingBoolStart recording automaticallyfalse
captureTimeIntervalDoubleSeconds between captures. Min: 1.010.0
captureScaleCGFloatScreenshot resolution scale factor. Lower values reduce image size and memory usage2.0
captureCompressionQualityCGFloatImage compression (0.0-1.0). Lower values reduce fidelity and file size1.0
sessionRecordingSampleRateInt (0–100)% of sessions to capture100
maskText[String]?Text patterns to redact (strings or regex)nil
maskImagesBoolMask all credit card imagesfalse
maskAllImagesBoolMask all imagestrue
maskFacesBoolMask detected facesfalse
creditCardPredicate[String]?Custom patterns to detect credit card-related imagesnil

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:

SessionReplay.shared.startRecording()
SessionReplay.shared.stopRecording()

Manually capture screen

Use captureEvent to manually capture a specific moment in the session.

Example

_ = SessionReplay.shared.captureEvent()

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 or maskAllImages 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.