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 above. ft-session-replayandft-session-replay-materialmust use the same version number.ft-sdk1.7.2 and above no longer strongly depends onft-session-replay; only when Session Replay needs to be enabled, you need to additionally addft-session-replayand related extension dependencies.-
It is recommended to prioritize using the officially released stable version displayed in the badge at the top of the document, and it is no longer recommended to use pre-release versions such as
alphaandbeta. -
If you want to inherit advanced capabilities early, follow the latest features, or track changes that have not been officially released, you can go to GitHub to follow the Android SDK repository and related update logs: GuanceCloud/datakit-android
Android Heatmap (Experimental Feature)
Android Heatmap requires using ft-sdk >= 1.7.4 and ft-session-replay >= 0.1.7 simultaneously, and enabling RUM user action collection and Session Replay.
ft-sdk >= 1.7.0 is still the minimum version requirement for normal Android Session Replay; the above version combination only applies to Android Heatmap.
Configuration¶
// Add SDK dependencies
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-sdk:[latest_version]'
// Need to enable session replay feature
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay:[session_replay_version]'
// Need session replay support for material components
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-material:[session_replay_version]'
// Need session replay support for compose components
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-compose:[session_replay_version]'
Flutter RUM Context Compatibility¶
ft-session-replay 0.1.5 and above supports the RUM context fields used when uploading Flutter Session Replay. When both Flutter pages or Flutter SDK collection traces exist in the Android native project, after upgrading to ft-session-replay:0.1.5 or above, no additional configuration is needed to correctly map Flutter Replay data to the corresponding Replay Segment.
In hybrid scenarios, it is still recommended to initialize RUM first, then initialize Session Replay, to ensure that contexts such as
app_id,session_id,view_idare established.
Code Sample¶
| Method Name | Type | Required | Description |
|---|---|---|---|
| setSampleRate | Float | No | Set the sampling rate, range [0,1], 0 means no collection, 1 means full collection, default value is 1. |
| setSessionReplayOnErrorSampleRate | Float | No | Set the error sampling rate. When a session is not sampled by setSampleRate, if an error occurs during the session, data within the 1 minute range before the error can be collected, range [0,1], 0 means no collection, 1 means full collection, default value is 0. Supported from 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 boxes, CheckBox, RadioButton, Switch. Default is SessionReplayPrivacy.MASK. Will be deprecated soon, can be used for compatibility, 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 user input data, including text in input boxes, CheckBox, RadioButton, Switch, TextAndInputPrivacy.MASK_ALL masks all data, including text, CheckBox, RadioButton, Switch. Default is TextAndInputPrivacy.MASK_ALL. After setting, it overrides the configuration of setPrivacy. Supported from 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. After setting, it overrides the configuration of setPrivacy. Supported from 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 setting, it overrides the configuration of setPrivacy. Supported from ft-session-replay 0.1.1-alpha01 and above. |
| addExtensionSupport | ExtensionSupport | No | Add additional custom support. Using ft-session-replay-material can use MaterialExtensionSupport to provide additional Material component collection support. |
Privacy Override¶
Supported from ft-session-replay 0.1.1-alpha01 and above.
The SDK supports configuring the global mask level through FTSessionReplayConfig, and also supports overriding these settings at the view level.
View-level privacy overrides:
- Supports overriding image mask level
- Supports overriding text and input mask level and touch mask level
- Supports setting completely hidden specific views
Note:
- To ensure correct identification of override settings, they should be applied as early as possible in the view lifecycle. This prevents the case where Session Replay processes the view before the applied overrides.
- Privacy overrides affect the view and its child views. This means that even if an override is applied to a view that may not take effect immediately (for example, applying an image override to a text input), the override will still be applied to all child views.
- Privacy override priority: Child view > Parent view > Global settings
Image Override¶
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, directly set the property to null.
Text and Input Override¶
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, directly set the property to null.
Touch Override¶
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, directly set the property to null.
Hide Element Override¶
For sensitive elements that need to be completely hidden, use PrivacyOverrideExtensions.setSessionReplayHidden(View,Boolean) to set.
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 recording touch interactions on that element. To hide touch interactions, in addition to marking the element as hidden, also use Touch Override.
Webview Session Replay¶
Supported from ft-session-replay 0.1.3-alpha11, ft-sdk 1.7.0-alpha36 and above.
WebView Session Replay requires integrating the Web Monitoring SDK on the page accessed by the WebView, and enabling Session Replay in the Webview.
Tencent Webview X5 Support¶
Jetpack Compose Support¶
ft-session-replay-composeandft-session-replayuse the same version number.
Android Session Replay now supports collecting and replaying Jetpack Compose interfaces. When using Compose pages, you need to additionally import the Compose extension dependency and add ComposeExtensionSupport in 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 through Modifier:
sessionReplayHide(Boolean): Hide the specified Compose nodesessionReplayImagePrivacy(ImagePrivacy): Override image privacy levelsessionReplayTextAndInputPrivacy(TextAndInputPrivacy): Override text and input privacy levelsessionReplayTouchPrivacy(TouchPrivacy): Override touch privacy level
Current Limitations¶
- Compose replay relies on semantic nodes and component mappings, and does not guarantee pixel-level restoration.
- Currently supports replay of common 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 the original gradient effect; it is recommended to use solid colors for key demonstration areas.