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.0or higher. ft-session-replayandft-session-replay-materialmust use the same version number.- Starting from
ft-sdkversion 1.7.2, there is no longer a strong dependency onft-session-replay. You only need to add theft-session-replayand related extension dependencies when you need to enable Session Replay. - It is recommended to prioritize using the stable release version displayed by the badges at the top of the document. Using pre-release versions like
alphaorbetais no longer recommended. - If you wish to access cutting-edge capabilities early, stay updated on the latest features, or follow changes not yet officially released, you can visit the GitHub repository for the Android SDK and its changelog: GuanceCloud/datakit-android
Configuration¶
// Add SDK dependency
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-sdk:[latest_version]'
// Required to enable session replay functionality
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay:[session_replay_version]'
// Required to support Material components for session replay
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-material:[session_replay_version]'
// Required to support Compose components for session replay
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-compose:[session_replay_version]'
Flutter RUM Context Compatibility¶
Versions of ft-session-replay 0.1.5 and above are compatible with the RUM context fields used by Flutter Session Replay for data upload. When Flutter pages or Flutter SDK collection traces exist within a native Android project, upgrading to ft-session-replay:0.1.5 or higher allows Flutter Replay data to be correctly mapped to the corresponding Replay Segment without additional configuration.
In hybrid scenarios, it is still recommended to complete RUM initialization before initializing Session Replay to ensure that context such as
app_id,session_id, andview_idis established.
Code Sample¶
| Method Name | Type | Required | Description |
|---|---|---|---|
| setSampleRate | Float | No | Sets the sampling rate. Value range [0,1]. 0 means no sampling, 1 means full sampling. Default is 1. |
| setSessionReplayOnErrorSampleRate | Float | No | 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 sampling, 1 means full sampling. Default is 0. Supported in ft-session-replay 0.1.2-alpha01 and above. |
| 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 user input data, including text in input fields, CheckBox, RadioButton, Switch. Default is SessionReplayPrivacy.MASK. Deprecated soon, can be used compatibly. It is recommended to prioritize using setTouchPrivacy and setTextAndInputPrivacy for masking settings. |
| setTextAndInputPrivacy | TextAndInputPrivacy | No | TextAndInputPrivacy.MASK_SENSITIVE_INPUTS only masks sensitive information like passwords. TextAndInputPrivacy.MASK_ALL_INPUTS masks user input data, including text in input fields, CheckBox, RadioButton, Switch. TextAndInputPrivacy.MASK_ALL masks all data, including text, CheckBox, RadioButton, Switch. Default is TextAndInputPrivacy.MASK_ALL. Settings here override configurations from setPrivacy. Supported in ft-session-replay 0.1.1-alpha01 and above. |
| setImagePrivacy | ImagePrivacy | No | ImagePrivacy.MASK_ALL masks all images. ImagePrivacy.MASK_LARGE_ONLY only masks large image content (content images larger than 100x100 dp). ImagePrivacy.MASK_NONE does not mask images. Default is ImagePrivacy.MASK_ALL. Settings here override configurations from setPrivacy. Requires 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. Settings here override configurations from setPrivacy. Supported in ft-session-replay 0.1.1-alpha01 and above. |
| addExtensionSupport | ExtensionSupport | No | Adds 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.
In addition to supporting global masking levels configured via FTSessionReplayConfig, the SDK also supports overriding these settings at the view level.
View-level privacy override:
- Supports overriding image masking level.
- Supports overriding text and input masking level and touch masking level.
- Supports setting specific views to be completely hidden.
Note:
- To ensure correct identification of override settings, 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 child views. 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 child views.
- Privacy override priority: Child view > Parent view > Global setting
Image Override¶
Requires
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, setting it to one of the values in the ImagePrivacy enum. To remove an existing override rule, simply set this property to null.
Text and Input Override¶
To override text and input privacy, use PrivacyOverrideExtensions.setSessionReplayTextAndInputPrivacy(View,TextAndInputPrivacy) on the view instance, setting it to one of the values in the TextAndInputPrivacy enum. To remove an existing override rule, simply set this property to null.
Touch Override¶
To override touch privacy, use PrivacyOverrideExtensions.setSessionReplayTouchPrivacy(View,TouchPrivacy) on the view instance, setting it to one of the values in the TouchPrivacy enum. To remove an existing override rule, simply set this property to null.
Hidden Element Override¶
For sensitive elements that need to be completely hidden, use PrivacyOverrideExtensions.setSessionReplayHidden(View,Boolean) 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 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.
Webview Session Replay¶
Supported in ft-session-replay 0.1.3-alpha11, ft-sdk 1.7.0-alpha36 and above.
For WebView Session Replay, you need to integrate the Web Monitoring SDK into the pages accessed by the WebView, and enable Session Replay within the Webview.
Tencent Webivew X5 Support¶
Jetpack Compose Support¶
ft-session-replay-composemust use the same version number asft-session-replay.
Android Session Replay now supports collection and replay of Jetpack Compose interfaces. When using Compose pages, you need to additionally introduce the Compose extension dependency and add ComposeExtensionSupport to the FTSessionReplayConfig.
Add Dependency¶
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-compose:[session_replay_version]'
Initialization Configuration¶
FTSdk.initSessionReplayConfig(new FTSessionReplayConfig().setSampleRate(1f)
.setTouchPrivacy(TouchPrivacy.SHOW)
.setImagePrivacy(ImagePrivacy.MASK_LARGE_ONLY)
.setTextAndInputPrivacy(TextAndInputPrivacy.MASK_SENSITIVE_INPUTS)
.addExtensionSupport(new ComposeExtensionSupport())
.addExtensionSupport(new MaterialExtensionSupport()), context);
FTSdk.initSessionReplayConfig(FTSessionReplayConfig().setSampleRate(1f)
.setTouchPrivacy(TouchPrivacy.SHOW)
.setImagePrivacy(ImagePrivacy.MASK_LARGE_ONLY)
.setTextAndInputPrivacy(TextAndInputPrivacy.MASK_SENSITIVE_INPUTS)
.addExtensionSupport(ComposeExtensionSupport())
.addExtensionSupport(MaterialExtensionSupport()), context)
Compose Privacy Override¶
Compose pages support overriding Session Replay privacy configurations via 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, pixel-perfect restoration is not guaranteed.
- Currently supports replay of common components like text, input fields, images, buttons, switches, sliders, radio buttons, checkboxes, tabs, and container components.
Brushbackgrounds are not yet supported. For example, linear gradients, radial gradients, etc., will not be restored with their original gradient effects. It is recommended to use solid color backgrounds for key demonstration areas.