This page describes how to activate and customize Session Replay for your iOS apps.
OneAgent for iOS version 8.323 or later is required for applications compiled with Xcode 26.
Session Replay on iOS allows you to capture your customers' interactions with your mobile app and replay each tap, swipe, and screen rotation in a movie-like experience.
You can also use it to get more context for crash analysis in the form of video-like screen recordings that replay the user actions preceding a detected crash.
Make sure that your system meets the following requirements:
Session Replay is a video-like reconstruction of the user interactions with mobile applications that use captured events and data. Because of this approach, replayed sessions can differ from the actual user experience.
If you haven't done so already, complete all steps described in the initial setup for iOS frontends.
Experience Vitals > Overview.100 percent to capture all sessions.100 percent to capture randomly selected sessions.OneAgent for iOS version 8.249+
If you've already instrumented your SwiftUI app, you can additionally activate Session Replay for such a mobile app.
To activate Session Replay for your instrumented SwiftUI app
Complete all the steps of the Activate Session Replay instruction above.
Set the DTXSwiftUIEnableSessionReplayInstrumentation configuration key to true in your project's Info.plist file.
<key>DTXSwiftUIEnableSessionReplayInstrumentation</key><true/>
We support Session Replay for the following SwiftUI containers:
Dynatrace doesn't instrument the following SwiftUI containers:
Equatable protocolSession Replay comes with three predefined masking levels:
By default, OneAgent applies the Safest masking level. To change it to the Safe or Custom level, use the API to configure OneAgent. If you've opted for the Custom level, see Configure custom masking for details on how to set which application components or views should be masked.
Use the following code to set the masking level to Safe.
let maskingConfiguration = MaskingConfiguration(maskingLevelType: .safe)try? AgentManager.setMaskingConfiguration(maskingConfiguration)
If you set the data masking level to Custom, you can use additional API methods to decide which application components or views should be masked. You can:
You can activate or deactivate rules globally or for the selected components, such as text fields, images, labels, web views, and switches.
try? maskingConfiguration.add(rule: .maskAllImages) // Adds one ruletry? maskingConfiguration.remove(rule: .maskAllSwitches) // Removes one ruletry? maskingConfiguration.addAllRules() // Adds all rulestry? maskingConfiguration.removeAllRules() // Removes all rules
If you remove all masking rules, Session Replay won't mask anything. If you activate all masking rules, it's equivalent to the Safest masking level.
accessibilityIdentifier You can activate or deactivate masking of the selected views based on their accessibilityIdentifier.
try? maskingConfiguration.addMaskedView(viewIds: ["masked_view_id"])try? maskingConfiguration.removeMaskedView(viewIds: ["masked_view_id"])try? maskingConfiguration.addNonMaskedView(viewIds: ["nonMasked_view_id"])try? maskingConfiguration.removeNonMaskedView(viewIds: ["nonMasked_view_id"])
You can also mask a view by adding the data-dtrum-mask masking tag to the view's accessibilityIdentifier. A view with this masking tag is always masked.
You can activate Session Replay logs the same way as for OneAgent. See Debug logging for more information.
Session Replay records only certain events. You can additionally capture custom events that are not supported by default. You can capture a custom event with an included screenshot of a specific view, specific screen region, or full screen.
All methods for capturing custom events can throw a TrackCustomEventError.notInMainThread error if you try to capture a custom event from a thread that is not the main thread. We suggest that you include a do-catch clause until everything works properly; then you can replace the clause with a simpler version that, even in case of an error, just doesn't capture the custom event.
do {try AgentManager.trackCustomEvent(name: "my_event_name", view: nil)} catch {print(error)}
Capture a custom event with a screenshot of the specific view.
try? AgentManager.trackCustomEvent(name: "my_view_name", view: myView)
Capture a custom event with a screenshot of the specific screen region.
try? AgentManager.trackCustomEvent(name: "my_view_name", frame: anyFrame)
Capture a custom event with a screenshot of the full screen.
try? AgentManager.trackCustomEvent(name: "my_view_name")
By default, all data—information on captured events and images—is sent over any connection. However, you can opt to transfer images only when the users are connected to Wi-Fi to save their mobile data.
AgentManager.setTransmissionMode(.wifi) // .data by default
The Session Replay screenshot debugger allows you to see when the screenshots are taken, which parts of the screen are captured, and what data—text fields, images, labels, web views, and toggles—is masked.
You can use the Session Replay screenshot debugger when running your mobile app in the simulator, so you don't have to wait until the session is closed and uploaded to Dynatrace.

After you activate the Session Replay screenshot debugger, you can see the corresponding keys in your project. Note that these keys are not sent to the app code for release or archive compilations, so they are never included in the production code. These keys are used only for debug runs.

To activate the Session Replay screenshot debugger: