iOS Session Replay¶
Prerequisites¶
- Ensure you have set up and initialized the 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 above, the Session Replay product name is adjusted to
TrueWatchSessionReplay. Please refer to the Migration Guide. -
It is recommended to prioritize using the officially released stable version indicated by the badge at the top of the document. Pre-release versions such as
alpha,betaare no longer recommended. -
If you wish to integrate advanced capabilities early, follow the latest features, or track changes that have not been officially released, you can visit the GitHub iOS SDK repository and related changelogs: TrueWatchTech/datakit-ios
Configuration¶
Link the TrueWatchSessionReplay feature component from the TrueWatchSDK library to your project according to your package manager:
CocoaPods¶
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 from SDK 1.6.2 and above
When using Carthage or manually integrating Frameworks, in addition to the base SDK, the TrueWatchSessionReplay session replay component must also be added to the main project target's Frameworks.
TrueWatchSessionReplay is a session replay feature component that depends on the TrueWatchSDK base capabilities and cannot be used alone.
Objective-C Entry¶
The Objective-C import path depends on the integration method:
| Integration Method | Recommended Entry |
|---|---|
| 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 syntax; when using 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;
// If you need to collect SwiftUI pages, enable this for SDK 1.6.5 and above
srConfig.enableSwiftUI = YES;
// If you need to enable Session Replay heatmap association, enable this for SDK 1.6.6 and above
srConfig.enableHeatmap = YES;
srConfig.sampleRate = 100;
[[FTRumSessionReplay sharedInstance] startWithSessionReplayConfig:srConfig];
let srConfig = FTSessionReplayConfig.init()
srConfig.touchPrivacy = .show
srConfig.textAndInputPrivacy = .maskSensitiveInputs
srConfig.imagePrivacy = .maskNonBundledOnly
// If you need to collect SwiftUI pages, enable this for SDK 1.6.5 and above
srConfig.enableSwiftUI = true
// If you need to enable Session Replay heatmap association, enable this for SDK 1.6.6 and above
srConfig.enableHeatmap = true
srConfig.sampleRate = 100
FTRumSessionReplay.shared().start(with: srConfig)
| Attribute | Type | Required | Description |
|---|---|---|---|
| sampleRate | int | No | Sampling rate. Range [0,100], 0 means no collection, 100 means full collection, default value is 100. This sampling rate is based on the RUM sampling rate. |
| sessionReplayOnErrorSampleRate | int | No | Sets the error collection rate. When a session is not sampled by sampleRate, if an error occurs during the session, data from the 1-minute range before the error can be collected. Range [0,100], 0 means no collection, 100 means full collection, default value is 0. Supported from SDK 1.6.2 and above. |
| privacy | FTSRPrivacy | No | Sets the privacy level for content masking in Session Replay. Default FTSRPrivacyMask.Masking: text replaced with * or #. FTSRPrivacyAllow: Records text and input 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.Deprecated, but compatible. It is recommended to use touchPrivacy, textAndInputPrivacy, imagePrivacy for fine-grained privacy level settings. |
| touchPrivacy | FTTouchPrivacyLevel | No | Available privacy level for touch masking in session replay. Default FTTouchPrivacyLevelHide.FTTouchPrivacyLevelShow: Shows all user touches.FTTouchPrivacyLevelHide: Masks all user touches.Overrides the privacy configuration when set.Supported from SDK 1.6.1 and above. |
| textAndInputPrivacy | FTTextAndInputPrivacyLevel | No | Available privacy level for text and input masking in session replay. Default FTTextAndInputPrivacyLevelMaskAll.FTTextAndInputPrivacyLevelMaskSensitiveInputs: Shows all text except sensitive inputs, such as password fields.FTTextAndInputPrivacyLevelMaskAllInputs: Masks all input fields, e.g., UITextField, UISwitch, UISlider, etc.FTTextAndInputPrivacyLevelMaskAll: Masks all text and inputs.Overrides the privacy configuration when set.Supported from 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 those downloaded from the network or generated at runtime. Please ensure images do not contain sensitive content before using.Overrides the privacy configuration when set.Supported from SDK 1.6.2 and above. |
| enableSwiftUI | BOOL | No | Enables session replay collection for SwiftUI pages. Default value is NO. Supported from SDK 1.6.5 and above. |
| enableHeatmap | BOOL | No | Enables Session Replay heatmap association capability. Default value is NO. This is an experimental feature. Supported from SDK 1.6.6 and above. |
| enableLinkRUMKeys | NSArray | No | When enabled, based on the keys set, associates the corresponding fields in the RUM Context to the session replay data. Can be used for session replay data routing. Supported from SDK 1.6.2 and above. |
Note:
enableHeatmapis only used to associate automatically collected UIKit Actions. Some UIKit Actions may not support Heatmap. SwiftUI Actions currently do not support automatic collection, so heatmap association viaenableHeatmapis not possible.
Privacy Override¶
Supported from SDK 1.6.1 and above
In addition to configuring the global masking level via 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 from SDK 1.6.2 and above)
- Supports setting specific views to be completely hidden
Notes:
- To ensure correct identification of overrides, apply them as early as possible in the view lifecycle. This prevents session replay from processing the view before the applied overrides.
- Privacy overrides affect the view and its subviews. This means that even if an override is applied to a view where it may not take immediate effect (e.g., applying an image override to a text input), the override will still apply to all subviews.
- Privacy override priority: child view > parent view > global setting.
Text and Input Override¶
To override text and input privacy, use sessionReplayPrivacyOverrides.textAndInputPrivacy on the view instance and set it to a value from the FTTextAndInputPrivacyLevelOverride enum. To remove an existing override, set this property to FTTextAndInputPrivacyLevelOverrideNone.
@import TrueWatchSessionReplay;
// Set 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;
Touch Override¶
To override touch privacy, use sessionReplayPrivacyOverrides.touchPrivacy on the view instance and set it to a value from the FTTouchPrivacyLevelOverride enum. To remove an existing override, set this property to FTTouchPrivacyLevelOverrideNone.
Image Override¶
Supported from SDK 1.6.2 and above
To override image privacy, use sessionReplayPrivacyOverrides.imagePrivacy on the view instance and set it to a value from the FTImagePrivacyLevelOverride enum. To remove an existing override, set this 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 those downloaded from the network or generated at runtime. Please ensure images do not contain sensitive content before using.
@import TrueWatchSessionReplay;
// Set image override for the specified view
myImageView.sessionReplayPrivacyOverrides.imagePrivacy = FTImagePrivacyLevelOverrideMaskNonBundledOnly;
// Remove the image override for the view
myImageView.sessionReplayPrivacyOverrides.imagePrivacy = FTImagePrivacyLevelOverrideNone;
Hidden Element Override¶
For sensitive elements that need to be completely hidden, use sessionReplayPrivacyOverrides.hide to set.
When an element is set to hidden, it will be replaced by a "Hidden" placeholder in the replay, and its subviews will not be recorded.
Note: Marking a view as hidden does not prevent touch interactions from being recorded on that element. To hide touch interactions, use the Touch Override in addition to marking the element as hidden.
Webview Session Replay¶
Supported from SDK 1.6.2 and above
WebView Session Replay requires integrating the Web Monitoring SDK on the page accessed by the WebView and enabling Session Replay in the WebView.