Configure Session Replay for Android

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

Prerequisites

Make sure that your system meets the following requirements:

  • Dynatrace version 1.303
  • OneAgent for Android version 8.303
  • Real User Monitoring enabled for your application
  • Active Dynatrace Digital Experience Monitoring license
  • The web UI URL has a trusted certificate
  • Jetpack Compose supported since version 8.303.2.1014

Known limitations and issues

Technical limitations

  • Android 5.0+ (API level 21+) is supported.
  • Android Gradle plugin 7.0+ is supported.
  • Kotlin version 1.9+ is supported.
    • Kotlin version 1.8 supported because of Kotlin compatibility
  • Jetpack Compose version 1.4+ is supported.
  • Session Replay is not available for cross-platform frameworks such as Cordova, React Native, Flutter, Xamarin, and more
  • For a hybrid app, Session Replay is supported only for the native part of the app. Session Replay is not supported for the browser part of a hybrid app.
  • Only AndroidX support libraries are supported. Classes such as Activity or Fragment in com.android.support are not supported.
  • We recommend not using other crash reporting tools together with Dynatrace Session Replay.
  • Session Replay can capture only certain events. However, if you need to track a specific view or event that is not supported by default, you can capture a custom event.
  • You can play back the user sessions recorded with Session Replay only in certain browsers.
  • See Technical restrictions for Session Replay for web applications for more information.

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

  • Fragments with in-out animations can cause problems, especially when animations are short.
  • Floating action buttons can cause data masking issues.
  • The inputType attribute within the Button component might result in buttons appearing without text when captured.

Jetpack Compose limitations:

  • UIs mixing Jetpack Compose and Views are not fully supported and replay can miss data.
  • Material3 is not supported

Enable Session Replay on Android

If you haven't done so already, complete all steps described in the instrumentation wizard.

  1. Go to Mobile.
  2. Select the mobile application that you want to configure.
  3. Select More () > Edit in the upper-right corner of the tile with your application name.
  4. From the application settings, select General > Enablement and cost control.
  5. Turn on Enable Full Session Replay or Enable Session Replay on crashes. You have the following options:
    • Enabling Full Mobile Session Replay on 100%, all sessions will be captured
    • Enabling Full Mobile Session Replay on lower than 100%, randomly selected session will be captured
    • Enabling Session Replay on Crashes means guarantees that, regardless of the Enable Full Session Replay setting and its const and traffic control value, all sessions with crash are will be captured.
  6. From the application settings, select Instrumentation wizard, and then select Android or iOS.
  7. Follow the steps 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.8
targetCompatibility 1.8
}

For Android Gradle plugin 4.2+, Java 8 is used by default, so no configuration change is needed.

Enable Jeptack Compose support (on Preview)

On gradle.properties add dynatrace.instrumentSessionReplayCompose=true property

Mask sensitive data

Data masking levels

Session Replay on comes with three predefined masking levels:

  • Safest—all the editable text fields, images, labels, web views, and switches are masked.
  • Safe—all the editable text fields are masked.
  • Custom—by default, masks the same elements as Safest, but you can decide exactly which application components or views should be masked. See Configure custom masking for details.

Change masking level

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.

Example 1: Change masking level to Safe

Use the following code to set the masking level to Safe.

MaskingConfiguration config = new MaskingConfiguration.Safe();
// .Safest or .Custom
DynatraceSessionReplay.setConfiguration(Configuration.builder()
.withMaskingConfiguration(config)
.build());

Example 2: Change masking level to Custom

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 .Safe
DynatraceSessionReplay.setConfiguration(Configuration.builder()
.withMaskingConfiguration(config)
.build());

Example 3: Change masking level to Custom and remove all masked views

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());

Configure custom masking

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:

Mask views

You can enable or disable masking globally or for the selected components, such as text fields, images, labels, web views, and switches.

Set&lt;Class<? extends View&gt;> set = new HashSet&lt;Class<? extends View&gt;>()\\{{
add(ImageView.class);
add(WebView.class);
}};
new MaskingConfiguration.Custom().addMaskedView(ImageView.class); // Adds one masked view
new MaskingConfiguration.Custom().addMaskedViews(set); // Adds all masked views
new MaskingConfiguration.Custom().removeMaskedView(ImageView.class); // Removes one masked view
new 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.

Mask views using android:tag

You can also enable or disable masking of the selected views based on their android:tag.

Set&lt;Integer&gt; set = new HashSet&lt;Integer&gt;()\\{{
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.

Mask views using a masking tag

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.

Mask sensitive data in Jetpack Compose

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 = { ... }
) {
...
}

Enable Session Replay logs

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.

Capture custom events

Session Replay records only certain events. However, you can track an event that is not supported by default.

DynatraceSessionReplay.trackCustomEvent("User logged")

Change transmission mode to Wi-Fi for images

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()
)

Troubleshooting

Frequently asked questions