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. Alpha version changelogs are available 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];
| Attribute | Type | Required | Description |
|---|---|---|---|
| sampleRate | int | No | Sampling rate. Range [0,100], 0 means no sampling, 100 means full sampling, default is 100. This sampling rate is based on RUM sampling. |
| sessionReplayOnErrorSampleRate | int | No | Sets the error sampling 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 sampled. Range [0,100], 0 means no sampling, 100 means full sampling, default is 0. Supported in SDK 1.6.2-alpha.1 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 all content except sensitive input controls, such as password inputFTSRPrivacyMaskUserInput: Masks input elements. For example, UITextField, UISwitch, etc.FTSRPrivacyMask: Masks all content.Deprecated, compatible for use, it is recommended to use touchPrivacy and textAndInputPrivacy for finer-grained privacy level settings |
| touchPrivacy | FTTouchPrivacyLevel | No | Available privacy levels for touch masking in Session Replay. Default is FTTouchPrivacyLevelHide.FTTouchPrivacyLevelShow: Shows all user touchesFTTouchPrivacyLevelHide: Masks all user touchesOverrides 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 FTTextAndInputPrivacyLevelMaskAllFTTextAndInputPrivacyLevelMaskSensitiveInputs: Shows all text except sensitive inputs, such as password inputFTTextAndInputPrivacyLevelMaskAllInputs: Masks all input fields, such as UITextField, UISwitch, UISlider, etc.FTTextAndInputPrivacyLevelMaskAll: Masks all text and inputsOverrides 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:
- Supports overriding text and input masking levels and touch masking levels
- Supports completely hiding specific views
Note:
- To ensure proper 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 override is applied.
- 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: Subview > Parent view > Global settings
Text and Input Override¶
To override text and input privacy, use sessionReplayOverrides.textAndInputPrivacy on the view instance and 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 and 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 marked as 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.