Skip to content

iOS Session Replay

Prerequisites

SDK 1.6.8+ requires iOS 15+; when upgrading from an older version, see 1.6.8 Upgrade Requirements. * Make sure you have set up and initialized TrueWatchSDKRUM configuration and enabled View monitoring collection. * iOS Session Replay version support: SDK.Version >= 1.6.0. * When upgrading from an older version to SDK 1.6.6 or later, the Session Replay product name has been changed to TrueWatchSessionReplay. Refer to the Migration Guide. * It is recommended to use the official stable release shown in the badge at the top of this document. Pre-release versions such as alpha and beta are no longer recommended.

  • If you want to integrate advanced capabilities ahead of time, keep up with the latest features, or track unreleased changes, visit GitHub to follow the iOS SDK repository and related changelogs: TrueWatchTech/datakit-ios

Configuration

Depending on your package manager, link the TrueWatchSessionReplay feature component from the TrueWatchSDK library to your project:

CocoaPods

pod 'TrueWatchSDK', 'last_version'
pod 'TrueWatchSDK/SessionReplay', 'last_version' # new

Swift Package Manager

dependencies: [
.package(url: "https://github.com/TrueWatchTech/datakit-ios.git",
from: "last_version")
],
targets: [
    .target(
        name: "YourTarget",
        dependencies: [
            .product(name: "TrueWatchSDK", package: "TrueWatchSDK"),
            .product(name: "TrueWatchSessionReplay", package: "TrueWatchSDK"), // new
        ]),
]

Carthage/Framework

Supported in SDK 1.6.2 and above

When using Carthage or manually integrating a Framework, in addition to the base SDK, you also need to add the TrueWatchSessionReplay Session Replay component to the Frameworks of the main project target.

TrueWatchSessionReplay is the Session Replay feature component. It depends on the base capabilities of TrueWatchSDK and cannot be used standalone.

Objective-C Entry Point

The Objective-C import path depends on the integration method:

Integration Method Recommended Entry Point
CocoaPods #import <TrueWatchSDK/TrueWatchSessionReplay.h>
Swift Package Manager @import TrueWatchSessionReplay;
Carthage / Framework #import <TrueWatchSessionReplay/TrueWatchSessionReplay.h>
The following Objective-C examples uniformly use the Swift Package Manager import style. For CocoaPods or Carthage/Framework integration, replace the entry line according to the table above.

Code Invocation

@import TrueWatchSessionReplay;
FTSessionReplayConfig *srConfig = [[FTSessionReplayConfig alloc]init];
   srConfig.touchPrivacy = FTTouchPrivacyLevelShow;
   srConfig.textAndInputPrivacy = FTTextAndInputPrivacyLevelMaskSensitiveInputs;
   srConfig.imagePrivacy = FTImagePrivacyLevelMaskNonBundledOnly;
   // To collect SwiftUI pages, enable this in SDK 1.6.5 and above
   srConfig.enableSwiftUI = YES;
   // To enable Session Replay heatmap association, enable this in SDK 1.6.6 and above
   srConfig.enableHeatmap = YES;
   srConfig.sessionReplaySamplingRate = 100; // SDK 1.6.8+
   [[FTRumSessionReplay sharedInstance] startWithSessionReplayConfig:srConfig];
   let srConfig = FTSessionReplayConfig.init()
   srConfig.touchPrivacy = .show
   srConfig.textAndInputPrivacy = .maskSensitiveInputs
   srConfig.imagePrivacy = .maskNonBundledOnly
   // To collect SwiftUI pages, enable this in SDK 1.6.5 and above
   srConfig.enableSwiftUI = true
   // To enable Session Replay heatmap association, enable this in SDK 1.6.6 and above
   srConfig.enableHeatmap = true
   srConfig.sessionReplaySamplingRate = 100 // SDK 1.6.8+
   FTRumSessionReplay.shared().start(with: srConfig)
Property Type Required Description
sessionReplaySamplingRate float No SDK 1.6.8+: Session Replay percentage sampling rate, range [0,100], supports decimals (0.1 means 0.1%, 1 means 1%), default 100 (full sampling). Replay sampling is performed on top of RUM session sampling. The legacy remote field uses a [0,1] ratio; see Remote Sampling Configuration
sampleRate int No Integer percentage sampling rate. Deprecated from SDK 1.6.8 and may be removed in future versions; use sessionReplaySamplingRate instead.
sessionReplayOnErrorSamplingRate float No SDK 1.6.8+: Replay error backfill sampling percentage, range [0,100], supports decimals, default 0; used for sessions that do not hit the regular Replay sampling
sessionReplayOnErrorSampleRate int No Integer percentage error backfill sampling configuration. Deprecated from SDK 1.6.8 and may be removed in future versions; use sessionReplayOnErrorSamplingRate instead.
privacy FTSRPrivacy No Sets the privacy level for content masking in Session Replay. Default FTSRPrivacyMask.
Masking behavior: text is replaced with * or #.
FTSRPrivacyAllow: records text and input content except sensitive input controls, displays user touches, and records all images.
FTSRPrivacyMaskUserInput: masks input elements and hides user touches; only records SF Symbols and images loaded via [UIImage imageNamed:] / UIImage(named:) that are bundled with the app.
FTSRPrivacyMask: masks all text, inputs, touches, and images.
To be deprecated soon, still supported for compatibility. It is recommended to use touchPrivacy, textAndInputPrivacy, and imagePrivacy for fine-grained privacy masking
touchPrivacy FTTouchPrivacyLevel No Available privacy level for touch masking in Session Replay. Default FTTouchPrivacyLevelHide.
FTTouchPrivacyLevelShow: displays all user touches
FTTouchPrivacyLevelHide: masks all user touches
Overrides the privacy configuration when set
Supported in SDK 1.6.1 and above
textAndInputPrivacy FTTextAndInputPrivacyLevel No Available privacy level for text and input masking in Session Replay. Default FTTextAndInputPrivacyLevelMaskAll
FTTextAndInputPrivacyLevelMaskSensitiveInputs: displays all text except sensitive inputs, such as password inputs
FTTextAndInputPrivacyLevelMaskAllInputs: masks all input fields, such as UITextField, UISwitch, UISlider, etc.
FTTextAndInputPrivacyLevelMaskAll: masks all text and inputs
Overrides the privacy configuration when set
Supported in SDK 1.6.1 and above
imagePrivacy FTImagePrivacyLevel No Available privacy level for image masking in Session Replay. Default FTImagePrivacyLevelMaskAll.
FTImagePrivacyLevelMaskNonBundledOnly: only records SF Symbols and images loaded via [UIImage imageNamed:] / UIImage(named:) that are bundled with the app; images downloaded from the network or generated at runtime are masked.
FTImagePrivacyLevelMaskAll: masks all images.
FTImagePrivacyLevelMaskNone: records all images, including network-downloaded or runtime-generated images. Only use after confirming that the images do not contain sensitive content.
Overrides the privacy configuration when set
Supported in SDK 1.6.2 and above
enableSwiftUI BOOL No Enables Session Replay collection for SwiftUI pages. Default value is NO. Supported in SDK 1.6.5 and above
enableHeatmap BOOL No Enables Session Replay heatmap association. Default value is NO. This is an experimental feature. Supported in SDK 1.6.6 and above
enableLinkRUMKeys NSArray No When enabled, associates the corresponding fields in the RUM Context with the Session Replay data based on the configured keys. Can be used to route Session Replay data.
Supported in SDK 1.6.2 and above

Note: enableHeatmap is only used to associate automatically collected UIKit Actions. Some UIKit Actions may not support the Heatmap. SwiftUI Actions currently do not support automatic collection and therefore cannot be associated with the heatmap via enableHeatmap.

Privacy Overrides

Supported in SDK 1.6.1 and above

In addition to configuring global masking levels through FTSessionReplayConfig, the SDK also supports overriding these settings at the view level.

View-level privacy overrides:

  • Supports overriding the text and input masking level, touch masking level, and image masking level (supported in SDK 1.6.2 and above)
  • Supports completely hiding specific views

Notes:

  • To ensure overrides are correctly recognized, apply them as early as possible in the view lifecycle. This prevents Session Replay from processing a view before the configured overrides are applied.
  • Privacy overrides affect a view and its subviews. This means that even if an override is applied to a view where it may not take effect immediately (for example, applying an image override to a text input), the override still applies to all subviews.
  • Privacy override precedence: subview > parent view > global settings

Text and Input Override

To override text and input privacy, set sessionReplayPrivacyOverrides.textAndInputPrivacy on the view instance to one of the values in the FTTextAndInputPrivacyLevelOverride enumeration. To remove an existing override, simply set the property to FTTextAndInputPrivacyLevelOverrideNone.

@import TrueWatchSessionReplay;
// Set the text and input override for the specified view
   myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = FTTextAndInputPrivacyLevelOverrideMaskAll;
   // Remove the text and input override for the view
   myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = FTTextAndInputPrivacyLevelOverrideNone;
   // Set the text and input override for the specified view
   myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = .maskAll
   // Remove the text and input override for the view
   myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = .none

Touch Override

To override touch privacy, set sessionReplayPrivacyOverrides.touchPrivacy on the view instance to one of the values in the FTTouchPrivacyLevelOverride enumeration. To remove an existing override, simply set the property to FTTouchPrivacyLevelOverrideNone.

@import TrueWatchSessionReplay;
// Set the touch override for the specified view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = FTTouchPrivacyLevelOverrideShow;
   // Remove the touch override for the view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = FTTouchPrivacyLevelOverrideNone;
   // Set the touch override for the specified view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = .show;
   // Remove the touch override for the view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = .none;

Image Override

Supported in SDK 1.6.2 and above

To override image privacy, set sessionReplayPrivacyOverrides.imagePrivacy on the view instance to one of the values in the FTImagePrivacyLevelOverride enumeration. To remove an existing override, simply set the property to FTImagePrivacyLevelOverrideNone.

Available image override levels:

  • FTImagePrivacyLevelOverrideMaskNonBundledOnly: only records SF Symbols and images loaded via [UIImage imageNamed:] / UIImage(named:) that are bundled with the app; images downloaded from the network or generated at runtime are masked.
  • FTImagePrivacyLevelOverrideMaskAll: masks all images.
  • FTImagePrivacyLevelOverrideMaskNone: records all images, including network-downloaded or runtime-generated images. Only use after confirming that the images do not contain sensitive content.
@import TrueWatchSessionReplay;
// Set the image override for the specified view
   myImageView.sessionReplayPrivacyOverrides.imagePrivacy = FTImagePrivacyLevelOverrideMaskNonBundledOnly;
   // Remove the image override for the view
   myImageView.sessionReplayPrivacyOverrides.imagePrivacy = FTImagePrivacyLevelOverrideNone;
   // Set the image override for the specified view
   myImageView.sessionReplayPrivacyOverrides.imagePrivacy = .maskNonBundledOnly
   // Remove the image override for the view
   myImageView.sessionReplayPrivacyOverrides.imagePrivacy = .none

Hidden Element Override

For sensitive elements that need to be completely hidden, use sessionReplayPrivacyOverrides.hide.

When an element is set to hidden, it is replaced in the replay with a placeholder marked as "Hidden", and its subviews are not recorded.

Note: Marking a view as hidden does not prevent touch interactions from being recorded on that element. To hide touch interactions, in addition to marking the element as hidden, also use Touch Override.

@import TrueWatchSessionReplay;
// Mark the hidden element override for the specified view
   myView.sessionReplayPrivacyOverrides.hide = YES;
   // Remove the hidden element override for the view
   myView.sessionReplayPrivacyOverrides.hide = NO;
   // Mark the hidden element override for the specified view
   myView.sessionReplayPrivacyOverrides.hide = true;
   // Remove the hidden element override for the view
   myView.sessionReplayPrivacyOverrides.hide = false;

WebView Session Replay

Supported in SDK 1.6.2 and above

For WebView Session Replay, integrate the Web Monitoring SDK into the pages accessed by the WebView and enable Session Replay in the WebView.

// In addition to the WebView RUM configuration
window.DATAFLUX_RUM.startSessionReplayRecording();

Code and Configuration Reference