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.
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.
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.
Make sure that your system meets the following requirements:
@dynatrace/react-native-plugin version 2.349.1+ with the @dynatrace/react-native-session-replay package addedSession 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:
TextInput components with secureTextEntry set to true are always masked, regardless of the configured masking level.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.
Go to Experience Vitals > Overview.
Select Mobile to view all mobile frontends.
Select the frontend you want to configure.
Switch to the Settings tab.
Under Enablement and cost control:
From the application settings, select Instrumentation wizard, and then select React Native.
Follow the steps in the instrumentation wizard.
Session Replay for React Native comes with three predefined masking levels:
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.
import { SessionReplay, MaskingConfiguration } from '@dynatrace/react-native-session-replay';SessionReplay.setMaskingConfiguration(MaskingConfiguration.Safest());
SessionReplay.setMaskingConfiguration(MaskingConfiguration.Safe());
SessionReplay.setMaskingConfiguration(MaskingConfiguration.Custom());
SessionReplay.setMaskingConfiguration(MaskingConfiguration.Custom().removeAllMaskedViews());
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:
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 WebViewsSessionReplay.setMaskingConfiguration(MaskingConfiguration.Custom().removeMaskedViews([MaskableView.Image, MaskableView.WebView]));// Mask only TextInput fieldsSessionReplay.setMaskingConfiguration(MaskingConfiguration.Custom().removeAllMaskedViews().addMaskedViews([MaskableView.TextInput]));
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} />
Session Replay logs are part of the general Dynatrace React Native plugin logs. For details, see Debug logging.
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');
For setup and configuration issues specific to the Dynatrace React Native plugin, see Troubleshooting.