This article covers the installation of Session Replay using the Session Replay React Native Segment plugin. If your React Native app is already instrumented with Segment using their Analytics React Native library and Amplitude (Actions) destination, use this option.
If you instrument your app with an Amplitude React Native SDK, use the Session Replay React Native SDK Plugin.
If you use Segment using other options, use the standalone implementation.
To report issues with Session Replay for React Native, review Amplitude-TypeScript GitHub repository.
This plugin requires the @segment/analytics-react-native-plugin-amplitude-session
plugin to extract session IDs from Amplitude integration data. Make sure to add this plugin to your Segment client before adding the session replay plugin.
The Amplitude API key used in the session replay plugin configuration must match the API key configured in your Segment Amplitude (Actions) destination.
Use the latest version of the Session Replay React Native Segment Plugin above 0.0.1-beta.2
.
The Session Replay React Native Segment Plugin requires that:
Install the plugin and its dependencies:
npm install @amplitude/segment-session-replay-plugin-react-nativenpm install @amplitude/session-replay-react-native @segment/analytics-react-native
yarn add @amplitude/segment-session-replay-plugin-react-nativeyarn add @amplitude/session-replay-react-native @segment/analytics-react-native
Configure your application code:
import { createSegmentSessionReplayPlugin } from '@amplitude/segment-session-replay-plugin-react-native';import { createClient } from '@segment/analytics-react-native';import { AmplitudeSessionPlugin } from '@segment/analytics-react-native-plugin-amplitude-session'; // Initialize Segment clientconst segmentClient = createClient({ writeKey: 'YOUR_SEGMENT_WRITE_KEY',}); // Configure session replay pluginconst sessionReplayConfig = { apiKey: 'YOUR_AMPLITUDE_API_KEY', deviceId: 'YOUR_DEVICE_ID'}; // Add the Amplitude session plugin first (required for session ID extraction)await segmentClient.add({ plugin: new AmplitudeSessionPlugin() }); // Add the session replay plugin to Segmentawait segmentClient.add(createSegmentSessionReplayPlugin(sessionReplayConfig));
The plugin accepts a SessionReplayConfig
object with the following options:
Name | Type | Required | Default | Description |
---|---|---|---|---|
apiKey |
string |
Yes | - | Your Amplitude API key. This must match the API key used with your Segment Amplitude destination. |
deviceId |
string |
No | - | The device ID to use for session replay. If not provided, the plugin extracts it from Segment event context. |
sampleRate |
number |
No | 0 |
Use this option to control how many sessions to select for replay collection. The number should be a decimal between 0 and 1, for example 0.4 , representing the fraction of sessions to have randomly selected for replay collection. |
enableRemoteConfig |
boolean |
No | true |
Use this option to enable remote configuration. |
logLevel |
LogLevel |
No | LogLevel.Warn |
Use this option to set the log level for the Session Replay plugin. |
autoStart |
boolean |
No | true |
Use this option to control whether Session Replay starts automatically when initialized. If set to false , manually call the start() method to begin capture. |
The Segment Session Replay Plugin automatically:
track
and screen
events before they're sent to Segment.The plugin processes the following Segment event types:
TrackEvent
: Adds session replay properties to track events.ScreenEvent
: Adds session replay properties to screen events.For these events, the plugin:
The plugin extracts session IDs in the following order of priority:
event.integrations['Actions Amplitude'].session_id
.event.properties.session_id
.-1
if no session ID is found.The plugin extracts device IDs in the following order of priority:
event.context.device.id
.event.anonymousId
.null
if no device ID is found.This section provides examples for more advanced use cases.
Manually control the session replay plugin after initialization:
import { createSegmentSessionReplayPlugin } from '@amplitude/segment-session-replay-plugin-react-native'; // Create the pluginconst sessionReplayPlugin = createSegmentSessionReplayPlugin(sessionReplayConfig); // Add to Segmentawait segmentClient.add(sessionReplayPlugin); // Later, manually control recordingawait sessionReplayPlugin.start();await sessionReplayPlugin.stop();
For more advanced configurations, you can pass additional session replay options:
const sessionReplayConfig = { apiKey: 'YOUR_AMPLITUDE_API_KEY', sampleRate: 0.1, // Sample 10% of sessions enableRemoteConfig: true, logLevel: 4, // Debug level autoStart: false, // Don't start automatically}; const sessionReplayPlugin = createSegmentSessionReplayPlugin(sessionReplayConfig);
If session replay properties aren't added to your events:
track
or screen
.If the plugin can't extract session IDs:
If device ID extraction fails:
For additional troubleshooting, review the Session Replay React Native SDK Plugin troubleshooting guide.
July 5th, 2024
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2025 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.