iOS Session Replay¶
Prerequisites¶
- Ensure you have set up and initialized the FTMobileSDK RUM configuration, and enabled View monitoring collection.
- iOS Session Replay is currently an alpha feature, Version support: SDK.Version >= 1.6.0
- It is recommended to use the version displayed in the badge at the top of the document. Additionally, you can find the available alpha versions released using the command below. The alpha version changelog is here
Configuration¶
Link the FTSessionReplay
feature component from the FTMobileSDK
library to your project based on your package manager:
CocoaPods¶
pod 'FTMobileSDK', 'last_alpha_version'
pod 'FTMobileSDK/FTSessionReplay', 'last_alpha_version' # New addition
Swift Package Manager¶
dependencies: [
.package(url: "https://github.com/GuanceCloud/FTMobileSDK.git",
from: "last_alpha_version")
],
targets: [
.target(
name: "YourTarget",
dependencies: [
.product(name: "FTMobileSDK", package: "FTMobileSDK")
.product(name: "FTSessionReplay", package: "FTMobileSDK"), // New addition
]),
]
Code Sample¶
#import <FTMobileSDK/FTRumSessionReplay.h>
FTSessionReplayConfig *srConfig = [[FTSessionReplayConfig alloc]init];
srConfig.touchPrivacy = FTTouchPrivacyLevelShow;
srConfig.textAndInputPrivacy = FTTextAndInputPrivacyLevelMaskSensitiveInputs;
srConfig.sampleRate = 100;
[[FTRumSessionReplay sharedInstance] startWithSessionReplayConfig:srConfig];
Property | Type | Required | Description |
---|---|---|---|
sampleRate | int | No | Sampling rate. Range [0,100], 0 means no collection, 100 means full collection, default is 100. This sampling rate is based on RUM sampling. |
sessionReplayOnErrorSampleRate | int | No | Set 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. Range [0,100], 0 means no collection, 100 means full collection, default is 0. Supported in SDK 1.6.2-alpha.1 and above |
privacy | FTSRPrivacy | No | Set the privacy level for content masking in Session Replay. Default is FTSRPrivacyMask .Masking: Text is replaced with * or # FTSRPrivacyAllow : Record all content except sensitive input controls, such as password inputFTSRPrivacyMaskUserInput : Mask input elements. For example UITextField , UISwitch , etc.FTSRPrivacyMask : Mask all content.Will be deprecated, compatible for now, recommend using touchPrivacy , textAndInputPrivacy for finer-grained privacy level settings |
touchPrivacy | FTTouchPrivacyLevel | No | Available privacy levels for touch masking in session replay. Default is FTTouchPrivacyLevelHide .FTTouchPrivacyLevelShow : Show all user touchesFTTouchPrivacyLevelHide : Mask all user touchesSetting this overrides the privacy configurationSupported in SDK 1.6.1 and above |
textAndInputPrivacy | FTTextAndInputPrivacyLevel | No | Available privacy levels for text and input masking in session replay. Default is FTTextAndInputPrivacyLevelMaskAll FTTextAndInputPrivacyLevelMaskSensitiveInputs : Show all text except sensitive input, such as password inputFTTextAndInputPrivacyLevelMaskAllInputs : Mask all input fields, such as UITextField , UISwitch , UISlider , etc.FTTextAndInputPrivacyLevelMaskAll : Mask all text and inputSetting this overrides the privacy configurationSupported in SDK 1.6.1 and above |
Privacy Overrides¶
Supported in SDK 1.6.1 and above
In addition to supporting global masking levels through FTSessionReplayConfig
, the SDK also supports overriding these settings at the view level.
View-level privacy overrides:
- Support overriding text and input masking levels and touch masking levels
- Support setting specific views to be completely hidden
Note:
- To ensure correct identification of overrides, they should be applied as early as possible in the view lifecycle. This prevents the 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 that may not immediately take effect (e.g., applying an image override to a text input), the override will still apply to all subviews.
- Privacy override priority: Subviews > Parent views > Global settings
Text and Input Override¶
To override text and input privacy, use sessionReplayOverrides.textAndInputPrivacy
on the view instance to set it to one of the values in the FTTextAndInputPrivacyLevelOverride
enum. 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.touchPrivacy = FTTextAndInputPrivacyLevelOverrideNone;
Touch Override¶
To override touch privacy, use sessionReplayOverrides.touchPrivacy
on the view instance to set it to one of the values in the FTTouchPrivacyLevelOverride
enum. 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;
Hidden 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 with 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, in addition to marking the element as hidden, use Touch Override.