Overview
Session recording captures everything users do on your site—clicks, scrolls, mouse movements, and DOM changes—so you can replay sessions and understand exactly what happened. This is invaluable for debugging issues, improving UX, and understanding user behavior. MentiQ SDK uses rrweb for high-fidelity session recording with built-in privacy controls.Installation
1
Install Dependencies
Install the MentiQ SDK and rrweb:
2
Enable Recording
Set
enableSessionRecording: true in your analytics config:Recording starts automatically when the SDK initializes if
enableSessionRecording is enabled.3
View Recordings
Access session recordings in your MentiQ dashboard. Each session includes:
- Full replay of user interactions
- Timeline scrubbing
- Session metadata (duration, URL, user ID)
- Associated events and errors
Manual Control
Control recording programmatically with theuseAnalytics hook:
Privacy & Data Masking
Automatic Input Masking
By default, all input values are masked. This can be customized:Privacy CSS Classes
Use these CSS classes to control what gets recorded:Block Elements (Default: mentiq-block)
Completely blocks an element from recording:
Mask Text (Default: mentiq-mask)
Masks text content while preserving layout:
Ignore Elements (Default: mentiq-ignore)
Skips recording this section entirely:
Example: Protecting Sensitive Forms
Configuration Options
Customize recording behavior:Configuration Reference
Upload & Storage
Automatic Upload
Recordings are automatically uploaded to your backend:- Upload Frequency: Every 10 seconds
- Endpoint:
POST /api/v1/sessions/:session_id/recordings - Final Upload: When recording stops or max duration is reached
src/session-recording.ts:211-280:
Upload Payload
Use Cases
Debug User-Reported Issues
Record Critical User Flows
Conditional Recording
Only record sessions for specific users or scenarios:Performance Considerations
Session recording is optimized for minimal performance impact:
- Events are batched and compressed
- Mouse movements and scrolls are sampled, not recorded continuously
- DOM mutations are efficiently captured using MutationObserver
- Typical overhead: less than 1% CPU, less than 5MB memory
Reduce Recording Size
For better performance on high-traffic sites:Compliance
User Consent Example
Troubleshooting
Recording Not Starting
- Verify rrweb is installed:
npm list rrweb - Check for console errors with
debug: true - Ensure
enableSessionRecording: trueis set
Missing Styles in Replay
SetinlineStylesheet: true to include CSS in recordings:
High Memory Usage
ReducemaxDuration or increase checkoutEveryNms to limit event accumulation.