Preview
This page describes how to enable and customize Session Replay for your Android apps.
Session Replay on Android enables you to capture your customers' interactions with your mobile application and replay each tap, swipe, screen rotation in a movie-like experience.
Additionally, you can use it to get additional context for crash analysis in the form of video-like screen recordings that replay the user actions preceding a detected crash
Make sure that your system meets the following requirements:
Session Replay is a video-like reconstrunction of the user interaction with mobile application, that uses captured events and data. Because of this approach replayed session can differ from the actual user experience. Known issues
Jetpack Compose limitations:
If you haven't done so already, complete all steps described in the instrumentation wizard.
For Android Gradle plugin versions 4.0 and 4.1, you need to change the compile option to Java 8. This can be done during the instrumentation wizard step called Apply the Dynatrace plugin and add the plugin configuration. Add the following code to the top-level build file:
compileOptions {sourceCompatibility 1.8targetCompatibility 1.8}
For Android Gradle plugin 4.2+, Java 8 is used by default, so no configuration change is needed.
On gradle.properties
add dynatrace.instrumentSessionReplayCompose=true
property
Session Replay on comes with three predefined masking levels:
By default, OneAgent applies the Safest masking level. To change it to the Safe or Custom level, use the API to configure OneAgent. If you've opted for the Custom level, see Configure custom masking for details on how to set which application components or views should be masked.
Use the following code to set the masking level to Safe.
MaskingConfiguration config = new MaskingConfiguration.Safe();// .Safest or .CustomDynatraceSessionReplay.setConfiguration(Configuration.builder().withMaskingConfiguration(config).build());
Use the following code to set the masking level to Custom. For additional options, see Configure custom masking.
MaskingConfiguration config = new MaskingConfiguration.Custom();// .Safest or .SafeDynatraceSessionReplay.setConfiguration(Configuration.builder().withMaskingConfiguration(config).build());
Use the following code to set the masking level to Custom and remove all masked views (removeAllMaskedViews). For additional options, see Configure custom masking.
MaskingConfiguration config = new MaskingConfiguration.Custom().removeAllMaskedViews();DynatraceSessionReplay.setConfiguration(Configuration.builder().withMaskingConfiguration(config).build());
If you set the data masking level to Custom, you can use additional API methods to decide which application components or views should be masked. You can:
You can enable or disable masking globally or for the selected components, such as text fields, images, labels, web views, and switches.
Set<Class<? extends View>> set = new HashSet<Class<? extends View>>()\\{{add(ImageView.class);add(WebView.class);}};new MaskingConfiguration.Custom().addMaskedView(ImageView.class); // Adds one masked viewnew MaskingConfiguration.Custom().addMaskedViews(set); // Adds all masked viewsnew MaskingConfiguration.Custom().removeMaskedView(ImageView.class); // Removes one masked viewnew MaskingConfiguration.Custom().removeAllMaskedViews(); // Removes all masked views
You need to apply the custom masking configuration for it to take effect. See Change masking level to Custom and remove all masked views for the example code snippet.
android:tag
You can also enable or disable masking of the selected views based on their android:tag
.
Set<Integer> set = new HashSet<Integer>()\\{{add(R.id.view_id1);add(R.id.view_id2);}};new MaskingConfiguration.Custom().addMaskedIds(set);new MaskingConfiguration.Custom().addNonMaskedIds(set);new MaskingConfiguration.Custom().removeMaskedIds(set);new MaskingConfiguration.Custom().removeNonMaskedIds(set);
You need to apply the custom masking configuration for it to take effect. See Change masking level to Custom and remove all masked views for the example code snippet.
You can also mask a view by adding the data-dtrum-mask
masking tag to the view's android:tag
. A view with this masking tag is always masked.
Only Manual masking is supported for Jetpack Compose.
To manually mask composables you can use a custom modifier .dynatraceSessionReplayMasked()
in the composable you want to mask.
Button(modifier = Modifier.dynatraceSessionReplayMasked(),onClick = { ... }) {...}
You can enable Session Replay logs the same way as for OneAgent. See Enable debug logging for Dynatrace Android Gradle plugin or OneAgent SDK for more information.
Session Replay records only certain events. However, you can track an event that is not supported by default.
DynatraceSessionReplay.trackCustomEvent("User logged")
By default, all data—information on captured events and images—is sent over any connection. However, you can opt to transfer images only when the users are connected to Wi-Fi to save their mobile data.
DynatraceSessionReplay.setConfiguration(Configuration.builder().withDataTransmissionMode(DataTransmissionMode.NOT_METERED_NETWORK).build())