Skip to content

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 by the badge at the top of the document. Additionally, you can find the available published alpha versions using the command below. Alpha version changelogs are here
pod trunk info FTMobileSDK | grep alpha

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' # Add this line

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"), //Add this line
        ]),
]

Code Invocation

#import <FTMobileSDK/FTRumSessionReplay.h>

   FTSessionReplayConfig *srConfig = [[FTSessionReplayConfig alloc]init];
   srConfig.touchPrivacy = FTTouchPrivacyLevelShow;
   srConfig.textAndInputPrivacy = FTTextAndInputPrivacyLevelMaskSensitiveInputs;
   srConfig.sampleRate = 100;
   [[FTRumSessionReplay sharedInstance] startWithSessionReplayConfig:srConfig];
   let srConfig = FTSessionReplayConfig.init()
   srConfig.touchPrivacy = .show
   srConfig.textAndInputPrivacy = .maskSensitiveInputs
   srConfig.sampleRate = 100
   FTRumSessionReplay.shared().start(with: srConfig)
Property Type Required Meaning
sampleRate int No Sampling rate. Valid range [0,100], 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. Valid 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 Sets the privacy level for content masking in Session Replay. Default is FTSRPrivacyMask.
Masking process: Text is replaced with * or #
FTSRPrivacyAllow: Record all content except sensitive input controls, e.g., password fields
FTSRPrivacyMaskUserInput: Mask input elements. e.g., UITextField, UISwitch, etc.
FTSRPrivacyMask: Mask all content.
Deprecated soon, compatible for now, recommended to use touchPrivacy and textAndInputPrivacy for finer-grained privacy level settings instead
touchPrivacy FTTouchPrivacyLevel No Available privacy levels for touch masking in Session Replay. Default is FTTouchPrivacyLevelHide.
FTTouchPrivacyLevelShow: Show all user touches
FTTouchPrivacyLevelHide: Mask all user touches
Overrides the privacy configuration once set
Supported 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 inputs, e.g., password fields
FTTextAndInputPrivacyLevelMaskAllInputs: Mask all input fields, e.g., UITextField, UISwitch, UISlider, etc.
FTTextAndInputPrivacyLevelMaskAll: Mask all text and inputs
Overrides the privacy configuration once set
Supported in SDK 1.6.1 and above.
enableLinkRUMKeys NSArray No When enabled, associates the corresponding fields from the RUM Context to the Session Replay data based on the set keys. Can be used for Session Replay data routing.
Supported in SDK 1.6.3-alpha.13 and above.

Privacy Overrides

Supported in SDK 1.6.1 and above.

In addition to supporting global masking levels via 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 overrides are recognized correctly, they should be applied as early as possible in the view's lifecycle. This prevents cases where Session Replay processes the view before the applied override is set.
  • Privacy overrides affect the view and its subviews. This means that an override applied to a view (e.g., applying an image override to a text input) will apply to all subviews, even if it might not take effect immediately.
  • Privacy override priority: Subview > Parent View > Global Settings

Text and Input Override

To override text and input privacy, set sessionReplayOverrides.textAndInputPrivacy on the view instance to one of the values 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 the text and input override setting for the view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = FTTextAndInputPrivacyLevelOverrideNone;
   // Set text and input override for a specific view
   myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = .maskAll
   // Remove the text and input override setting for the view
   myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = .none

Touch Override

To override touch privacy, set sessionReplayOverrides.touchPrivacy on the view instance to one of the values 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 the touch override setting for the view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = FTTouchPrivacyLevelOverrideNone;
   // Set touch override for a specific view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = .show;
   // Remove the touch override setting for the view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = .none;

Hide Element Override

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

When an element is set to be 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 on that element from being recorded. To hide touch interactions, use the Touch Override in addition to marking the element as hidden.

#import <FTMobileSDK/UIView+FTSRPrivacy.h>
   // Mark hide element override for a specific view
   myView.sessionReplayPrivacyOverrides.hide = YES;
   // Remove the hide element override setting for the view
   myView.sessionReplayPrivacyOverrides.hide = NO;
   // Mark hide element override for a specific view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = true;
   // Remove the hide element override setting for the view
   myView.sessionReplayPrivacyOverrides.touchPrivacy = false;

Webview Session Replay

Supported in SDK 1.6.2.alpha.13 and above.

For WebView Session Replay, you need to integrate the Web Monitoring SDK into the page accessed by the WebView, and enable Session Replay within the Webview.

// In addition to the webview RUM settings
window.DATAFLUX_RUM.startSessionReplayRecording();

Sample Code and Configuration Reference