Try it free

Configure Session Replay for React Native

  • Latest Dynatrace
  • How-to guide
  • 8-min read
  • Preview

Preview

Preview

Session Replay for React Native is available as a preview. Register for the preview program to add the @dynatrace/react-native-session-replay package and start capturing Session Replay data for your React Native apps.

Session Replay for React Native is not available for RUM Classic or Dynatrace Managed. The preview is available to customers with Latest Dynatrace and DPS licensing.

This page describes how to activate and customize Session Replay for your React Native apps.

Use Session Replay

Session Replay on React Native allows you to capture your customers' interactions with your mobile application and replay each tap, swipe, and screen rotation in a movie-like experience.

Use Session Replay on crashes

You can also use it to get more 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+
  • Registered for the Session Replay for React Native preview program
  • @dynatrace/react-native-plugin version 2.349.1+ with the @dynatrace/react-native-session-replay package added
  • React Native 0.67+ and React 16.11+
  • Real User Monitoring enabled for your application
  • Active Dynatrace Digital Experience Monitoring license
  • The web UI URL has a trusted certificate

Supported technologies and known limitations

  • React Native 0.67+ and React 16.11+ are supported.
  • Android API level 23+ is supported for the Android build target.
  • iOS 15+ is supported for the iOS build target.
  • Session Replay is not available for other cross-platform frameworks such as Cordova, Xamarin, and .NET MAUI.
  • We recommend not using other crash reporting tools together with Dynatrace Session Replay.
  • Image data is always transmitted over any available network connection. There's no option to restrict transmission to Wi-Fi-only connections.
  • 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.

Session Replay is a video-like reconstruction of the user interaction with a mobile application, using captured events and data. Because of this approach, the replayed session can differ from the actual user experience. Known issues:

  • Pure style changes, such as color or opacity changes only, aren't detected as capture triggers, so these transitions might not appear in the replay.
  • TextInput components with secureTextEntry set to true are always masked, regardless of the configured masking level.

Activate Session Replay on React Native

Before you start this procedure, make sure you have completed all steps described in Initial setup for React Native frontends to add the @dynatrace/react-native-plugin and generate your configuration.

  1. Go to Experience Vitals > Overview.

  2. Select Mobile to view all mobile frontends.

  3. Select the frontend you want to configure.

  4. Switch to the Settings tab.

  5. Under Enablement and cost control:

    • Select Session Replay, and then enter the Capture rate of session replay value:
      • 100 percent to capture all sessions.
      • Lower than 100 percent to capture randomly selected sessions.
    • To capture all sessions with a crash regardless of the capture rate, select Session Replay for crashes.
  6. From the application settings, select Instrumentation wizard, and then select React Native.

  7. Follow the steps in the instrumentation wizard.

Mask sensitive data

Data masking levels

Session Replay for React Native comes with three predefined masking levels:

  • Safest: all editable text fields, images, labels, WebViews, and switches are masked.
  • Safe: all editable text fields and WebViews are masked.
  • Custom: by default, masks the same elements as Safest, but you can control exactly which view types are masked. For details, see Configure custom masking.

Change masking level

By default, the native agent applies its own masking defaults. To set the masking level from React Native, call SessionReplay.setMaskingConfiguration() with the desired level.

Example 1: Change masking level to Safest

import { SessionReplay, MaskingConfiguration } from '@dynatrace/react-native-session-replay';
SessionReplay.setMaskingConfiguration(MaskingConfiguration.Safest());

Example 2: Change masking level to Safe

SessionReplay.setMaskingConfiguration(MaskingConfiguration.Safe());

Example 3: Change masking level to Custom

SessionReplay.setMaskingConfiguration(MaskingConfiguration.Custom());

Example 4: Change masking level to Custom with no masked view types

SessionReplay.setMaskingConfiguration(
MaskingConfiguration.Custom().removeAllMaskedViews()
);

Configure custom masking

If you set the data masking level to Custom, you can use additional API methods to control exactly which view types are masked. The Custom level starts with all maskable view types masked. You can then remove or add specific types. You can:

  • Mask or unmask view types.
  • Mask individual components.

Mask view types

You can enable or disable masking for specific React Native view types using the MaskableView enum. The following view types are supported: TextInput, Text, Image, WebView, and Switch.

import { SessionReplay, MaskingConfiguration, MaskableView } from '@dynatrace/react-native-session-replay';
// Mask everything except images and WebViews
SessionReplay.setMaskingConfiguration(
MaskingConfiguration.Custom()
.removeMaskedViews([MaskableView.Image, MaskableView.WebView])
);
// Mask only TextInput fields
SessionReplay.setMaskingConfiguration(
MaskingConfiguration.Custom()
.removeAllMaskedViews()
.addMaskedViews([MaskableView.TextInput])
);

Mask individual components

You can also mask a specific component by wrapping it, regardless of the active masking level.

Use DTMask to force a component to be masked:

import { DTMask } from '@dynatrace/react-native-session-replay';
<DTMask>
<Text>Sensitive data</Text>
</DTMask>

Use DTWithMask as a higher-order component to create a reusable masked version of any component:

import { TextInput } from 'react-native';
import { DTWithMask } from '@dynatrace/react-native-session-replay';
const MaskedTextInput = DTWithMask(TextInput);
<MaskedTextInput value={secret} />

Enable Session Replay logs

Session Replay logs are part of the general Dynatrace React Native plugin logs. For details, see Debug logging.

Capture custom events

Session Replay automatically records navigation events and list reload events (FlatList, SectionList). However, you can also capture any event that isn't recorded by default. This triggers a manual screenshot capture tagged with the given name.

SessionReplay.trackCustomEvent('User logged in');

Troubleshooting

  • User sessions are not recorded at all
  • User sessions are recorded, but Session Replay is not available

For setup and configuration issues specific to the Dynatrace React Native plugin, see Troubleshooting.

Related topics

  • Session Replay
Related tags
Digital Experience