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.ft-session-replayand related extension dependencies are only required when Session Replay needs to be enabled. -
It is recommended to prioritize using the stable officially released version displayed in the badges at the top of the document. Using pre-release versions like
alphaorbetais no longer recommended. -
If you wish to access advanced capabilities early, follow the latest features, or track changes not yet officially released, you can visit GitHub to follow the Android SDK repository and related changelogs: GuanceCloud/datakit-android
Configuration¶
//Add SDK dependencies
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 to support material components
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-material:[session_replay_version]'
//Required for session replay to support compose components
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-session-replay-compose:[session_replay_version]'
Flutter RUM Context Compatibility¶
ft-session-replay version 0.1.5 and above is compatible with the RUM context fields used when uploading Flutter Session Replay data. When Flutter pages or Flutter SDK collection paths coexist in an Android native project, after upgrading to ft-session-replay:0.1.5 or higher, no additional configuration is needed to correctly map Flutter Replay data to the corresponding Replay Segment.
In hybrid scenarios, it is still recommended to complete RUM initialization first, then initialize Session Replay, to ensure contexts like
app_id,session_id,view_idare established.
Code Sample¶
| Method Name | Type | Required | Description |
|---|---|---|---|
| setSampleRate | Float | No | Sets the sampling rate. Value range [0,1]. 0 means no collection, 1 means full collection. 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 collection, 1 means full collection. 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, 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 using 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 level configuration 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 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 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 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 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 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).
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 from being recorded on that element. 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, the Web Monitoring SDK needs to be integrated into the WebView-accessed page, and Session Replay needs to be enabled in 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 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.