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.- 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 for session replay support for material components
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-material:[session_replay_version]'
//Required for session replay support for compose components
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-compose:[session_replay_version]'
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 private 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 for compatibility, but it is recommended to prioritize using setTouchPrivacy, 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 settings.
- 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
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 a value from 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 a value from 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 a value from 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 WebView-accessed page, 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 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 classes.
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.