Features
- 📱 Cross-Platform Support - Unified API for iOS and Android
- 🎥 Session Recording - Capture user interactions and screen recordings
- 🔒 Privacy-First - Built-in data masking for sensitive information
- ⚡ High Performance - Native implementation with minimal JavaScript bridge overhead
- 🎯 Selective Recording - Configurable sampling rates and recording controls
- 🚀 New Architecture Ready - Built as a Turbo Module with full type safety
- 🛡️ Granular Privacy Controls - Auto-masking and manual masking via wrapper components
Requirements
- React Native >= 0.70
- iOS >= 13.0
- Android API Level >= 21
- New Architecture support (backward compatible with old architecture)
Installation
Platform Setup
iOS
The SDK dependencies are automatically added via CocoaPods. Your project must target iOS 13 or later.Android
Dependencies are automatically added through Gradle. Requirements:- Minimum Android SDK 21+
- Kotlin support enabled
Quick Start
Here’s a minimal example to get started with Session Replay:Data Residency
Available in React Native Session Replay SDK version
1.3.0 and later.serverURL on MPSessionReplayConfig. The SDK exposes a MPDataResidency constant set with the managed region URLs so you don’t have to hardcode them.
| Region | MPDataResidency constant | URL |
|---|---|---|
| US (default) | MPDataResidency.US | https://api.mixpanel.com |
| EU | MPDataResidency.EU | https://api-eu.mixpanel.com |
| India | MPDataResidency.IN | https://api-in.mixpanel.com |
Configuration
TheMPSessionReplayConfig class provides comprehensive control over session replay behavior:
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
wifiOnly | boolean | true | Only transmit recordings over WiFi |
autoStartRecording | boolean | true | Automatically start recording on initialization |
recordingSessionsPercent | number | 100 | Percentage of sessions to record (0-100) |
autoMaskedViews | MPSessionReplayMask[] | All types | View types to automatically mask |
flushInterval | number | 10 | Interval in seconds to flush recordings |
enableLogging | boolean | false | Enable debug logging |
remoteSettingsMode | MPSessionReplayRemoteSettingsMode | Disabled | Setting for handling remote configuration during SDK initialization. Can be Disabled/ Fallback/ Strict. |
Auto-Masked View Types
TheMPSessionReplayMask enum defines view types that can be automatically masked:
API Reference
initialize
Initialize the Session Replay SDK with your configuration.token(required) - Your Mixpanel project tokendistinctId(required) - User identifier for the sessionconfig(required) - Session replay configuration
- Token must be a non-empty string
- distinctId must be a non-empty string
- recordingSessionsPercent must be between 0 and 100
startRecording
Start recording user interactions.stopRecording
Stop recording user interactions.isRecording
Check if session recording is currently active.identify
Update the user identifier for the current recording session.distinctId(required) - New user identifier
Remote Configuration
Available in React Native Session Replay SDK version
1.2.0 and later. Requires a paid Session Replay add-on.remote_settings_mode for your project in Mixpanel under Settings > Organization Settings > Session Replay. Using this, you can quickly set SDK options remotely without needing to update your app. This allows you to adjust recording settings, such as sampling rates, on the fly based on your needs.
Three modes are available:
Disabled: Do not use remote configuration and proceed to use the hardcoded initial options provided by the user during initialization. This is the default behavior.Fallback: Attempt to retrieve remote configuration and proceed with those settings. If there is failure or timeout (500 ms), we will use the previously cached remote settings (if one exists from the last successful fetch). If no existing remote settings are cached, we will use the values from the SDK initialization config.Strict: Requires successful remote configuration fetch for SDK initialization. If there is failure or timeout (500 ms), SDK initialization will fail and the Session Replay features will be unavailable for that app launch.
recordingSessionsPercent
Privacy & Data Masking
Session Replay provides two approaches to protect sensitive data: automatic masking and manual masking.Automatic Masking
Configure which view types are automatically masked during initialization:Manual Masking with MPSessionReplayView
Use theMPSessionReplayView wrapper component for granular control over what gets masked: