Set Up Session Replay
Learn how to enable Session Replay in your mobile app.
All iOS developers
Before enabling Session Replay in production, verify your masking configuration to ensure no sensitive data is captured. Our default settings aggressively mask potentially sensitive data, but if you modify these settings or update UI frameworks or system SDKs, you must thoroughly test your application. If you find any masking issues or sensitive data that should be masked but isn't, please create a GitHub issue and avoid deploying to production with Session Replay enabled until the issue is resolved.
iOS 26.0+ - Liquid Glass
Due to potential masking issues introduced by Apple's Liquid Glass rendering changes in iOS 26.0, Session Replay is now automatically disabled on apps running iOS 26.0+ when built with Xcode 26.0 or later starting with Sentry Cocoa 8.57.0. This is a defensive measure to protect user privacy and prevent potential PII leaks until masking is reliably supported. Earlier SDK versions do not include this safeguard and may be affected by unreliable masking on iOS 26.0 when built with Xcode 26.0 (Liquid Glass). We recommend upgrading to 8.57.0+ or, if you can't upgrade the SDK, disabling Session Replay manually.
Session Replay will work normally if:
- Your app runs on iOS versions prior to 26.0, OR
- Your app is built with Xcode prior to 26.0, OR
- Your app explicitly sets
UIDesignRequiresCompatibilitytoYESinInfo.plist
Override (use with caution): If you understand the PII risks and want to enable session replay anyway, you can set:
options.experimental.enableSessionReplayInUnreliableEnvironment = true
This experimental override option will be removed in a future minor version once the masking issues are resolved.
Follow the progress on fixing masking for iOS 26.0 (Liquid Glass) in GitHub issue #6390.
Session Replay helps you get to the root cause of an error or latency issue faster by providing you with a reproduction of what was happening in the user's device before, during, and after the issue. You can rewind and replay your application's state and see key user interactions, like taps, swipes, network requests, and console entries, in a single UI.
By default, our Session Replay SDK masks all text content, images, and user input, giving you heightened confidence that no sensitive data will leave the device. To learn more, see product docs.
Make sure your Sentry Cocoa SDK version is at least 8.31.1
If you already have the SDK installed, you can update it to the latest version with:
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "9.6.0"),
To set up the integration, add the following to your Sentry initialization.
SentrySDK.start(configureOptions: { options in
options.dsn = "___PUBLIC_DSN___"
options.debug = true
options.sessionReplay.onErrorSampleRate = 1.0
options.sessionReplay.sessionSampleRate = 0.1
})
While you're testing, we recommend that you set sessionSampleRate to 1.0. This ensures that every user session will be sent to Sentry.
Once testing is complete, we recommend lowering this value in production. We still recommend keeping onErrorSampleRate set to 1.0.
A user session starts when the Sentry SDK is initialized or when the application enters the foreground. The session will capture screen transitions, navigations, touches and other events until the application is sent to the background. If the application is brought back to the foreground within 30 seconds (default), the same replay_id will be used and the session will continue.
The session will be terminated if the application has spent in the background more than 30 seconds or when the maximum duration of 60 minutes is reached. You can adjust the session tracking interval to extend or shorten the duration of a single replay, depending on your needs. Note that if the application exits abnormally while running in the background, the session will also be terminated.
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 section for configuration options.
Sampling allows you to control how much of your app's traffic will result in a Session Replay. There are two sample rates you can adjust to get the replays relevant to you:
sessionSampleRate- The sample rate for replays that begin recording immediately and last the entirety of the user's session.onErrorSampleRate- The sample rate for replays that are recorded when an error happens. This type of replay will record up to a minute of events prior to the error and continue recording until the session ends.
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.
The SDK is recording and aggressively masking all text, images, PDF viewers, 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. If you want to manually mask parts of your app's data, read our guide on custom masking.
If you encounter any data not being redacted with the default settings, please let us know through a GitHub issue.
To disable redaction altogether (not to be used on applications with sensitive data):
options.sessionReplay.maskAllText = false
options.sessionReplay.maskAllImages = false
Errors that happen while a replay is running will be linked to the replay, making it possible to jump between related issues and replays. However, it's possible that in some cases the error count reported on the Replays Details page won't match the actual errors that have been captured. That's because errors can be lost, and while this is uncommon, there are a few reasons why it could happen:
- The replay was rate-limited and couldn't be accepted.
- The replay was deleted by a member of your org.
- There were network errors and the replay wasn't saved.
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").