Mobile Session Replay expands visibility into your mobile applications by visually replaying each user interaction, such as taps, swipes, and scrolls. Visually replaying user interactions on your applications makes it easier to reproduce crashes and errors, as well as understand the user journey for making UI improvements.
Note: Make sure you’ve setup and initialized the Datadog React Native SDK with views instrumentation enabled.
To install with NPM, run:
npm install @datadog/mobile-react-native-session-replay
To install with Yarn, run:
yarn add @datadog/mobile-react-native-session-replay
To enable Session Replay, import and call the enable
method with your configuration. Below is an example setup:
import { SessionReplay } from "@datadog/mobile-react-native-session-replay";
SessionReplay.enable({
replaySampleRate: sampleRate, // The percentage of sampled replays, in the range 0.0 - 100.0 (Default: 100.0).
textAndInputPrivacyLevel: TextAndInputPrivacyLevel.MASK_ALL, // Defines the way text and input (e.g text fields, checkboxes) should be masked (Default: `MASK_ALL`).
imagePrivacyLevel: ImagePrivacyLevel.MASK_ALL, // Defines the way images should be masked (Default: `MASK_ALL`).
touchPrivacyLevel: TouchPrivacyLevel.HIDE // Defines the way user touches (e.g tap) should be masked (Default: `HIDE`).
});
Note: All configuration properties are optional and should be adjusted based on your application's needs.
By default, Session Replay starts recording automatically. However, if you prefer to manually start recording at a specific point in your application, you can use the optional startRecordingImmediately
parameter as shown below, and later call SessionReplay.startRecording()
. You can also use SessionReplay.stopRecording()
to stop the recording anytime.
import { SessionReplay } from "@datadog/mobile-react-native-session-replay";
SessionReplay.enable({
replaySampleRate: sampleRate,
startRecordingImmediately: false
});
// Do something
SessionReplay.startRecording();
SessionReplay.stopRecording();