Skip to content

iOS Session Replay

Prerequisites

  • Ensure that 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 releases 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' # 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 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. Value range [0,100], 0 means no collection, 100 means full collection, default is 100. This 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], 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: Records all content except sensitive input controls, e.g., password fields.
FTSRPrivacyMaskUserInput: Masks input elements. e.g., UITextField, UISwitch, etc.
FTSRPrivacyMask: Masks all content.
Deprecation notice: Compatible for now, but 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 touches.
FTTouchPrivacyLevelHide: Masks 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: 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 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 sharding.
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 configured via 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 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 the session replay from processing the view before the override is applied.
  • 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 still apply to all subviews, even if it might not take effect immediately.
  • Privacy override priority: Subview > Parent view > Global setting

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 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, 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 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;

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 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, in addition to marking the element as hidden, also use the Touch Override.

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

Webview Session Replay

Supported in SDK 1.6.3.alpha.13 and above.

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

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

Sample Code and Configuration Reference

Feedback

Is this page helpful? ×