Skip to content

Android Session Replay

Prerequisites

#ft-sdk alpha version
curl https://mvnrepo.jiagouyun.com/repository/maven-releases/com/cloudcare/ft/mobile/sdk/tracker/agent/ft-sdk/maven-metadata.xml | grep alpha

#ft-session-replay alpha version
curl https://mvnrepo.jiagouyun.com/repository/maven-releases/com/cloudcare/ft/mobile/sdk/tracker/agent/ft-session-replay/maven-metadata.xml | grep alpha

#ft-session-replay-material alpha version
curl https://mvnrepo.jiagouyun.com/repository/maven-releases/com/cloudcare/ft/mobile/sdk/tracker/agent/ft-session-replay-material/maven-metadata.xml | grep alpha

Configuration

// Add SDK dependency
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-sdk:[latest_alpha_version]
// Need to enable session replay feature
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay:[latest_alpha_version]'
// Need to support material components for session replay
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-material:[latest_alpha_version]'

Code Call

FTSdk.initSessionReplayConfig(new FTSessionReplayConfig().setSampleRate(1f)
            .setTouchPrivacy(TouchPrivacy.SHOW)
            .setTextAndInputPrivacy(TextAndInputPrivacy.MASK_SENSITIVE_INPUTS)
            .addExtensionSupport(new MaterialExtensionSupport()), context);
FTSdk.initSessionReplayConfig(FTSessionReplayConfig().setSampleRate(1f)
            .setTouchPrivacy(TouchPrivacy.SHOW)
            .setTextAndInputPrivacy(TextAndInputPrivacy.MASK_SENSITIVE_INPUTS)
            .addExtensionSupport(MaterialExtensionSupport()), context)
Method Name Type Required Meaning
setSampleRate Float No Set the collection rate, value range [0,1], 0 means no collection, 1 means full collection, default value is 1.
setSessionReplayOnErrorSampleRate Float No Set the error collection rate. When a session is not sampled by setSampleRate, if an error occurs during the session, data from the 1 minute before the error can be collected. Value range [0,1], 0 means no collection, 1 means full collection, default value is 0. Supported in ft-session-replay 0.1.2-alpha01 and above.
setPrivacy SessionReplayPrivacy No SessionReplayPrivacy.ALLOW does not mask private data, SessionReplayPrivacy.MASK masks all data, including text, CheckBox, RadioButton, Switch; SessionReplayPrivacy.USER_INPUT (recommended) masks part of the user input data, including text in input boxes, CheckBox, RadioButton, Switch. Default is SessionReplayPrivacy.MASK. Deprecated soon, compatible for now, it is recommended to use setTouchPrivacy and setTextAndInputPrivacy for masking settings first
setTextAndInputPrivacy TextAndInputPrivacy No TextAndInputPrivacy.MASK_SENSITIVE_INPUTS only masks sensitive information like passwords, TextAndInputPrivacy.MASK_ALL_INPUTS masks part of the user input data, including text in input boxes, CheckBox, RadioButton, Switch, TextAndInputPrivacy.MASK_ALL, masks all data, including text, CheckBox, RadioButton, Switch. Default TextAndInputPrivacy.MASK_ALL. Settings here override the configuration of setPrivacy. Supported in ft-session-replay 0.1.1-alpha01 and above.
setTouchPrivacy TouchPrivacy No TouchPrivacy.SHOW does not mask touch data, TouchPrivacy.HIDE masks touch data. Settings here override the configuration of setPrivacy. Supported in ft-session-replay 0.1.1-alpha01 and above.
addExtensionSupport ExtensionSupport No Add additional custom support. Using ft-session-replay-material allows the use of MaterialExtensionSupport to provide additional Material component collection support.

Privacy Override

Supported in ft-session-replay 0.1.1-alpha01 and above.

The SDK supports not only configuring global masking levels through FTSessionReplayConfig but also overriding these settings at the view level.

View-level privacy override:

  • Supports overriding text and input masking levels and touch masking levels.
  • Supports setting specific views to be completely hidden.

Note:

  • To ensure override settings are correctly identified, 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.
  • Privacy overrides affect the view and its child views. This means that even if an override is applied to a view where it might not take immediate effect (e.g., applying an image override to a text input), the override will still apply to all child views.
  • Privacy override priority: Child view > Parent view > Global settings

Text and Input Override

To override text and input privacy, use PrivacyOverrideExtensions.setSessionReplayTextAndInputPrivacy(View,TextAndInputPrivacy) on the view instance, setting it to a value from the TextAndInputPrivacy enum. To remove an existing override rule, simply set this property to null.

// Mark hidden element override for the specified view
PrivacyOverrideExtensions.setSessionReplayTextAndInputPrivacy(view, TextAndInputPrivacy.MASK_ALL);
// Remove the hidden element override setting for the view
PrivacyOverrideExtensions.setSessionReplayTextAndInputPrivacy(view, null);
// Mark hidden element override for the specified view
PrivacyOverrideExtensions.setSessionReplayTextAndInputPrivacy(view, TextAndInputPrivacy.MASK_ALL)
// Remove the hidden element override setting for the view
PrivacyOverrideExtensions.setSessionReplayTextAndInputPrivacy(view, null)

Touch Override

To override touch privacy, use PrivacyOverrideExtensions.setSessionReplayTouchPrivacy(View,TouchPrivacy) on the view instance, setting it to a value from the TouchPrivacy enum. To remove an existing override rule, simply set this property to null.

// Mark hidden element override for the specified view
PrivacyOverrideExtensions.setSessionReplayTouchPrivacy(view, TouchPrivacy.HIDE);
// Remove the hidden element override setting for the view
PrivacyOverrideExtensions.setSessionReplayTouchPrivacy(view, null);
// Mark hidden element override for the specified view
PrivacyOverrideExtensions.setSessionReplayTouchPrivacy(view, TouchPrivacy.HIDE)
// Remove the hidden element override setting for the view
PrivacyOverrideExtensions.setSessionReplayTouchPrivacy(view, null)

Hidden Element Override

For sensitive elements that need to be completely hidden, use PrivacyOverrideExtensions.setSessionReplayHidden(View,Boolean).

When an element is set to hidden, it will be replaced by a "Hidden" placeholder in the replay, and its child views 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 Touch Override.

// Mark hidden element override for the specified view
PrivacyOverrideExtensions.setSessionReplayHidden(view, true)
// Remove the hidden element override setting for the view
PrivacyOverrideExtensions.setSessionReplayHidden(view, false)
// Mark hidden element override for the specified view
PrivacyOverrideExtensions.setSessionReplayHidden(view, true)
// Remove the hidden element override setting for the view
PrivacyOverrideExtensions.setSessionReplayHidden(view, false)

Webview Session Replay

Supported in ft-session-replay 0.1.3-alpha11, ft-sdk 1.7.0-alpha36 and above.

WebView Session Replay requires integrating the Web Monitoring SDK into the WebView accessed page and enabling Session Replay in the Webview.

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

Tencent Webivew X5 Support

FTSdk.initSessionReplayConfig(new FTSessionReplayConfig()
    //...
    // Additional CustomExtensionSupport setting
    .addExtensionSupport(new CustomExtensionSupport()
            .addMapper(new MapperTypeWrapper<>(com.tencent.smtt.sdk.WebView.class,
                    new WebViewXWireframeMapper())))
)
FTSdk.initSessionReplayConfig(FTSessionReplayConfig()
    //...
    // Additional CustomExtensionSupport setting
    .addExtensionSupport(
        CustomExtensionSupport()
            .addMapper(
                MapperTypeWrapper(
                    com.tencent.smtt.sdk.WebView::class.java,
                    WebViewXWireframeMapper()
                )
            )
    )
)

Jetpack Compose Support

Currently, Session Replay recording for Jetpack Compose related interfaces is not supported.

Code and Configuration Reference

Feedback

Is this page helpful? ×