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 Version Support: SDK.Version >= 1.6.0.
  • It is recommended to prioritize using the stable officially released version displayed by the badge at the top of the document. Using pre-release versions like alpha, beta, etc., is no longer recommended.

  • If you wish to integrate cutting-edge capabilities early, follow the latest features, or track changes not yet officially released, you can visit GitHub to follow the iOS SDK repository and related changelogs: GuanceCloud/datakit-ios

Configuration

Link the FTSessionReplay feature component from the FTMobileSDK library to your project based on your package manager:

CocoaPods

pod 'FTMobileSDK', 'last_version'
pod 'FTMobileSDK/FTSessionReplay', 'last_version' # New addition

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"), // New addition
        ]),
]

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 main project Target's Frameworks.

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];
   let srConfig = FTSessionReplayConfig.init()
   srConfig.touchPrivacy = .show
   srConfig.textAndInputPrivacy = .maskSensitiveInputs
   srConfig.imagePrivacy = .maskNonBundledOnly
   srConfig.sampleRate = 100
   FTRumSessionReplay.shared().start(with: srConfig)

| Property | Type | Required | Description > | sampleRate | int | No | Sampling rate. Value 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. Value range [0,100], 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 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
Configuration overrides privacy settings
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
Configuration overrides privacy settings
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. Please ensure images do not contain sensitive content before using this setting.
Configuration overrides privacy settings
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 sharding.
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 level, touch masking level, and image masking level (supported in SDK version 1.6.2 and above)
  • Supports 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 cases where session replay processes the view before the applied override takes effect.
  • 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 effect immediately (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 the view instance and set it to one of the values in 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;
   // Set text and input override for a specific view
   myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = .maskAll
   // Remove text and input override settings for the view
   myView.sessionReplayPrivacyOverrides.textAndInputPrivacy = .none

Touch Override

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

Image Override

Supported in SDK version 1.6.2 and above

To override image privacy, use sessionReplayPrivacyOverrides.imagePrivacy on the view instance and set it to one of the values in 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. Please ensure images do not contain 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;
   // Set image override for a specific view
   myImageView.sessionReplayPrivacyOverrides.imagePrivacy = .maskNonBundledOnly
   // Remove image override settings for the view
   myImageView.sessionReplayPrivacyOverrides.imagePrivacy = .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 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.

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

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 page and enable Session Replay within the Webview.

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

Sample Code and Configuration Reference

Feedback

Is this page helpful? ×