iOS SESSION REPLAY¶
Prerequisites¶
- Ensure you have set up and initialized the FTMobileSDK RUM configuration and enabled View monitoring collection.
- iOS Session Replay version support: SDK.Version >= 1.6.0.
- It is recommended to prioritize using the stable release version indicated by the badge at the top of the document. Using pre-release versions such as
alphaorbetais no longer recommended. - If you wish to integrate advanced capabilities early, follow the latest features, or track changes not yet officially released, you can visit the GitHub repository for the iOS SDK and its changelog: GuanceCloud/datakit-ios
Configuration¶
Link the FTSessionReplay feature component from the FTMobileSDK library to your project based on your package manager:
CocoaPods¶
Swift Package Manager¶
dependencies: [
.package(url: "https://github.com/GuanceCloud/FTMobileSDK.git",
from: "last_version")
],
targets: [
.target(
name: "YourTarget",
dependencies: [
.product(name: "FTMobileSDK", package: "FTMobileSDK")
.product(name: "FTSessionReplay", package: "FTMobileSDK"), //Added
]),
]
Carthage/Framework¶
Supported in SDK version 1.6.2 and above
When using Carthage or manually integrating the Framework, in addition to the base SDK, you also need to add the FTSessionReplay session replay component to the Frameworks of the main project's Target.
FTSessionReplay is the session replay feature component, which depends on the FTMobileSDK base capabilities and cannot be used alone.
Code Sample¶
#import <FTMobileSDK/FTRumSessionReplay.h>
// or
#import <FTSessionReplay/FTRumSessionReplay.h>
FTSessionReplayConfig *srConfig = [[FTSessionReplayConfig alloc]init];
srConfig.touchPrivacy = FTTouchPrivacyLevelShow;
srConfig.textAndInputPrivacy = FTTextAndInputPrivacyLevelMaskSensitiveInputs;
srConfig.imagePrivacy = FTImagePrivacyLevelMaskNonBundledOnly;
srConfig.sampleRate = 100;
[[FTRumSessionReplay sharedInstance] startWithSessionReplayConfig:srConfig];
| Property | Type | Required | Description |
|---|---|---|---|
| sampleRate | int | No | Sampling rate. Value range [0,100], where 0 means no collection, 100 means full collection. Default is 100. This sampling rate is applied on top of 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 before the error can be collected. Value range [0,100], where 0 means no collection, 100 means full collection. Default is 0. Supported in SDK version 1.6.2 and above. |
| privacy | FTSRPrivacy | No | Sets the privacy level for content masking in Session Replay. Default is FTSRPrivacyMask.Masking process: Text is replaced with * or #. FTSRPrivacyAllow: Records text and input except for sensitive input controls, shows 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, input, touches, and images.Deprecated soon, compatible for now. It is recommended to use touchPrivacy, textAndInputPrivacy, imagePrivacy for fine-grained privacy level settings. |
| touchPrivacy | FTTouchPrivacyLevel | No | Available privacy levels for touch masking in session replay. Default is FTTouchPrivacyLevelHide.FTTouchPrivacyLevelShow: Shows all user touches.FTTouchPrivacyLevelHide: Masks all user touches.Once set, overrides the configuration in privacy.Supported in SDK version 1.6.1 and above. |
| textAndInputPrivacy | FTTextAndInputPrivacyLevel | No | Available privacy levels for text and input masking in session replay. Default is FTTextAndInputPrivacyLevelMaskAll.FTTextAndInputPrivacyLevelMaskSensitiveInputs: Shows all text except sensitive inputs, e.g., password fields.FTTextAndInputPrivacyLevelMaskAllInputs: Masks all input fields, e.g., UITextField, UISwitch, UISlider, etc.FTTextAndInputPrivacyLevelMaskAll: Masks all text and input.Once set, overrides the configuration in privacy.Supported in SDK version 1.6.1 and above. |
| imagePrivacy | FTImagePrivacyLevel | No | Available privacy levels for image masking in session replay. Default is 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. Ensure images contain no sensitive content before using this setting.Once set, overrides the configuration in privacy.Supported in SDK version 1.6.2 and above. |
| enableLinkRUMKeys | NSArray | No | When enabled, associates corresponding fields from the RUM Context to the session replay data based on the set keys. Can be used to implement session replay data shunting. Supported in SDK version 1.6.2 and above. |
Privacy Overrides¶
Supported in SDK version 1.6.1 and above
In addition to supporting global masking level configuration via FTSessionReplayConfig, the SDK also supports overriding these settings at the view level.
View-level privacy overrides:
- Supports overriding text and input masking levels, touch masking levels, and image masking levels (supported in SDK version 1.6.2 and above).
- Supports setting specific views to be completely hidden.
Note:
- To ensure correct override identification, they should be applied as early as possible in the view's lifecycle. This prevents the session replay from processing the view before the override settings are applied.
- Privacy overrides affect the view and its subviews. This means that even if an override is applied to a view where it might 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: Subview > Parent view > Global settings
Text and Input Override¶
To override text and input privacy, use sessionReplayPrivacyOverrides.textAndInputPrivacy on a view instance and set it to a value from the FTTextAndInputPrivacyLevelOverride enumeration. To remove an existing override rule, simply set this property to FTTextAndInputPrivacyLevelOverrideNone.
#import <FTMobileSDK/UIView+FTSRPrivacy.h>
// Set text and input override for a specific view
myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = FTTextAndInputPrivacyLevelOverrideMaskAll;
// Remove text and input override settings for the view
myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = FTTextAndInputPrivacyLevelOverrideNone;
Touch Override¶
To override touch privacy, use sessionReplayPrivacyOverrides.touchPrivacy on a view instance and set it to a value from the FTTouchPrivacyLevelOverride enumeration. To remove an existing override rule, simply set this property to FTTouchPrivacyLevelOverrideNone.
#import <FTMobileSDK/UIView+FTSRPrivacy.h>
// Set touch override for a specific view
myView.sessionReplayPrivacyOverrides.touchPrivacy = FTTouchPrivacyLevelOverrideShow;
// Remove touch override settings for the view
myView.sessionReplayPrivacyOverrides.touchPrivacy = FTTouchPrivacyLevelOverrideNone;
Image Override¶
Supported in SDK version 1.6.2 and above
To override image privacy, use sessionReplayPrivacyOverrides.imagePrivacy on a view instance and set it to a value from the FTImagePrivacyLevelOverride enumeration. To remove an existing override rule, simply 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. Ensure images contain no sensitive content before using this setting.
#import <FTMobileSDK/UIView+FTSRPrivacy.h>
// Set image override for a specific view
myImageView.sessionReplayPrivacyOverrides.imagePrivacy = FTImagePrivacyLevelOverrideMaskNonBundledOnly;
// Remove image override settings for the view
myImageView.sessionReplayPrivacyOverrides.imagePrivacy = FTImagePrivacyLevelOverrideNone;
Hide Element Override¶
For sensitive elements that need to be completely hidden, use sessionReplayPrivacyOverrides.hide to set them.
When an element is set to hidden, it will be replaced by a placeholder marked as "Hidden" 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, in addition to marking the element as hidden, also use Touch Override.
Webview Session Replay¶
Supported in SDK version 1.6.2 and above
For WebView Session Replay, you need to integrate the Web Monitoring SDK into the WebView-accessed page and enable Session Replay within the Webview.