Skip to content

Android Session Replay

Prerequisites

  • Ensure you have set up and initialized the FTSdk RUM configuration and enabled View monitoring collection.
  • Android Session Replay requires ft-sdk:1.7.0 or later.
  • ft-session-replay and ft-session-replay-material must use the same version number.
  • ft-sdk 1.7.2 and later no longer have a hard dependency on ft-session-replay; you only need to add ft-session-replay and related extension dependencies separately when you need to enable Session Replay.
  • We recommend using the stable release version shown in the badge at the top of the document; pre-release versions such as alpha and beta are no longer recommended.

  • If you want to get early access to advanced capabilities, follow the latest features, or track unreleased changes, you can follow the Android SDK repository and related changelogs on GitHub: TrueWatchTech/datakit-android

Android Heatmap (Experimental Feature)

Android Heatmap requires both ft-sdk >= 1.7.4 and ft-session-replay >= 0.1.7, and RUM user behavior collection and Session Replay must be enabled.

ft-sdk >= 1.7.0 remains the minimum version requirement for standard Android Session Replay; the above version combination applies only to Android Heatmap.

Configuration

// Add the SDK dependency
implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-sdk:[latest_version]'
// Enable Session Replay
implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-session-replay:[session_replay_version]'
// To support Session Replay, Material component support is required
implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-session-replay-material:[session_replay_version]'
// To support Session Replay, Compose component support is required
implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-session-replay-compose:[session_replay_version]'

Flutter RUM Context Compatibility

ft-session-replay 0.1.5 and later is compatible with the RUM context fields used when Flutter Session Replay data is uploaded. When an Android native project also contains Flutter pages or Flutter SDK collection pipelines, after upgrading to ft-session-replay:0.1.5 or later, Flutter Replay data can be correctly mapped to the corresponding Replay Segment without additional configuration.

In hybrid scenarios, we still recommend completing RUM initialization before initializing Session Replay to ensure that contexts such as app_id, session_id, and view_id have been established.

Code Sample

FTSdk.initSessionReplayConfig(new FTSessionReplayConfig().setSessionReplaySamplingRate(100f)
                .setTouchPrivacy(TouchPrivacy.SHOW)
                .setImagePrivacy(ImagePrivacy.MASK_LARGE_ONLY)
                .setTextAndInputPrivacy(TextAndInputPrivacy.MASK_SENSITIVE_INPUTS)
                .addExtensionSupport(new MaterialExtensionSupport()), context);
FTSdk.initSessionReplayConfig(FTSessionReplayConfig().setSessionReplaySamplingRate(100f)
                .setTouchPrivacy(TouchPrivacy.SHOW)
                .setImagePrivacy(ImagePrivacy.MASK_LARGE_ONLY)
                .setTextAndInputPrivacy(TextAndInputPrivacy.MASK_SENSITIVE_INPUTS)
                .addExtensionSupport(MaterialExtensionSupport()), context)
Method name Type Required Description
setSessionReplaySamplingRate float No Sampling percentage, range [0,100], default 100, decimals supported; the explicit new field takes precedence over the old field. Supported in ft-session-replay >= 0.1.9.
setSampleRate Float No Deprecated as of ft-session-replay 0.1.9; retained for compatibility with the 0–1 scale. Sets the sampling rate. Value range [0,1]; 0 means no collection, 1 means full collection; the default is 1.
setSessionReplayOnErrorSamplingRate float No Error sampling percentage, range [0,100], default 0, decimals supported; the explicit new field takes precedence over the old field. Supported in ft-session-replay >= 0.1.9.
setSessionReplayOnErrorSampleRate Float No Deprecated as of ft-session-replay 0.1.9; retained for compatibility with the 0–1 scale. Sets the error sampling 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; the default is 0. Supported in ft-session-replay 0.1.2-alpha01 and later
setPrivacy SessionReplayPrivacy No SessionReplayPrivacy.ALLOW does not mask privacy data; SessionReplayPrivacy.MASK masks all data, including text, CheckBox, RadioButton, Switch; SessionReplayPrivacy.USER_INPUT (recommended) masks some user input data, including text in input fields, CheckBox, RadioButton, Switch; the default is SessionReplayPrivacy.MASK. Will be deprecated; retained for compatibility. We recommend using setTouchPrivacy and setTextAndInputPrivacy for masking settings instead
setTextAndInputPrivacy TextAndInputPrivacy No TextAndInputPrivacy.MASK_SENSITIVE_INPUTS masks only sensitive information such as passwords; TextAndInputPrivacy.MASK_ALL_INPUTS masks some user input data, including text in input fields, CheckBox, RadioButton, Switch; TextAndInputPrivacy.MASK_ALL masks all data, including text, CheckBox, RadioButton, Switch. The default is TextAndInputPrivacy.MASK_ALL. After being set, overrides the setPrivacy configuration. Supported in ft-session-replay 0.1.1-alpha01 and later
setImagePrivacy ImagePrivacy No ImagePrivacy.MASK_ALL masks all images; ImagePrivacy.MASK_LARGE_ONLY masks only large image content (content images larger than 100x100 dp); ImagePrivacy.MASK_NONE does not mask images. The default is ImagePrivacy.MASK_ALL. After being set, overrides the setPrivacy configuration. ft-sdk >= 1.7.0-alpha40, ft-session-replay >= 0.1.3-alpha14
setTouchPrivacy TouchPrivacy No TouchPrivacy.SHOW does not mask touch data; TouchPrivacy.HIDE masks touch data. After being set, overrides the setPrivacy configuration. Supported in ft-session-replay 0.1.1-alpha01 and later
addExtensionSupport ExtensionSupport No Adds additional custom support. With ft-session-replay-material, you can use MaterialExtensionSupport to provide additional collection support for Material components

Privacy Overrides

Supported in ft-session-replay 0.1.1-alpha01 and later

In addition to configuring global masking levels through FTSessionReplayConfig, the SDK also supports overriding these settings at the view level.

View-level privacy overrides:

  • Supports overriding the image masking level
  • Supports overriding the text and input masking level and the touch masking level
  • Supports completely hiding specific views

Notes:

  • To ensure override settings are correctly recognized, apply them as early as possible in the view lifecycle. This prevents Session Replay from processing the view before the overrides are applied.
  • Privacy overrides affect the view and its child views. This means that even if an override is applied to a view where it may not take effect immediately (for example, applying an image override to a text input), the override still applies to all child views.
  • Privacy override priority: child views > parent views > global settings

Image Overrides

ft-sdk >= 1.7.0-alpha40, ft-session-replay >= 0.1.3-alpha14

To override image privacy, use PrivacyOverrideExtensions.setSessionReplayImagePrivacy(View,ImagePrivacy) on the view instance to set it to a value in the ImagePrivacy enum. To remove an existing override rule, set the property to null.

// Mark the specified view with an image privacy override
PrivacyOverrideExtensions.setSessionReplayImagePrivacy(view, ImagePrivacy.MASK_ALL);
// Remove the image privacy override setting from the view
PrivacyOverrideExtensions.setSessionReplayImagePrivacy(view, null);
// Mark the specified view with an image privacy override
PrivacyOverrideExtensions.setSessionReplayImagePrivacy(view, ImagePrivacy.MASK_ALL)
// Remove the image privacy override setting from the view
PrivacyOverrideExtensions.setSessionReplayImagePrivacy(view, null)

Text and Input Overrides

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

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

Touch Overrides

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

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

Hidden Element Overrides

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

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

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

Webview Session Replay

Supported in ft-session-replay 0.1.3-alpha11 and ft-sdk 1.7.0-alpha36 and later

First complete the Session Replay initialization described on this page and WebView page initialization, then enable recording in the page:

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

Tencent Webivew X5 Support

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

Jetpack Compose Support

Keep ft-session-replay-compose and ft-session-replay on the same version number.

Android Session Replay now supports collection and replay for Jetpack Compose UIs. When using Compose pages, you need to add the Compose extension dependency and add ComposeExtensionSupport to FTSessionReplayConfig.

Add Dependencies

implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-session-replay-compose:[session_replay_version]'

Initialize Configuration

FTSdk.initSessionReplayConfig(new FTSessionReplayConfig().setSessionReplaySamplingRate(100f)
                .setTouchPrivacy(TouchPrivacy.SHOW)
                .setImagePrivacy(ImagePrivacy.MASK_LARGE_ONLY)
                .setTextAndInputPrivacy(TextAndInputPrivacy.MASK_SENSITIVE_INPUTS)
                .addExtensionSupport(new ComposeExtensionSupport())
                .addExtensionSupport(new MaterialExtensionSupport()), context);
FTSdk.initSessionReplayConfig(FTSessionReplayConfig().setSessionReplaySamplingRate(100f)
                .setTouchPrivacy(TouchPrivacy.SHOW)
                .setImagePrivacy(ImagePrivacy.MASK_LARGE_ONLY)
                .setTextAndInputPrivacy(TextAndInputPrivacy.MASK_SENSITIVE_INPUTS)
                .addExtensionSupport(ComposeExtensionSupport())
                .addExtensionSupport(MaterialExtensionSupport()), context)

Compose Privacy Overrides

Compose pages support overriding Session Replay privacy settings through Modifier:

  • sessionReplayHide(Boolean): Hides the specified Compose node
  • sessionReplayImagePrivacy(ImagePrivacy): Overrides the image privacy level
  • sessionReplayTextAndInputPrivacy(TextAndInputPrivacy): Overrides the text and input privacy level
  • sessionReplayTouchPrivacy(TouchPrivacy): Overrides the touch privacy level

Current Limitations

  • Compose replay relies on semantic nodes and component mapping and does not guarantee pixel-perfect restoration.
  • Replay currently supports common text, input fields, images, buttons, switches, sliders, radio buttons, checkboxes, tabs, and container components.
  • Brush backgrounds are not currently supported; for example, linear gradient and radial gradient backgrounds will not be restored with their original gradient effects. For key demonstration areas, we recommend using solid-color backgrounds.

Code and Configuration Reference