Skip to main content

Overview

The SessionRecorder class provides session recording capabilities using rrweb. It captures DOM events, user interactions, and network activity for later playback.
Session recording requires the rrweb package to be installed: npm install rrweb

Constructor

Creates a new SessionRecorder instance.
AnalyticsConfig
required
Analytics configuration object
string
required
Current session ID
RecordingConfig
Recording-specific configuration

Example

Methods

start

Start recording the session.

Behavior

  • Initializes rrweb and begins capturing events
  • Sets up automatic upload every 10 seconds
  • Automatically stops after maxDuration is reached
  • Does nothing if recording is already active
  • Only works in browser environments

Example

Starting a recording will dynamically import the rrweb library. Make sure it’s installed in your project.

stop

Stop recording and upload remaining events.

Behavior

  • Stops the rrweb recording
  • Clears the upload interval
  • Uploads any remaining events with is_final: true
  • Resets recording state

Example

pause

Pause the recording without stopping it completely.

Behavior

  • Stops capturing events temporarily
  • Clears the upload interval
  • Does not upload remaining events
  • Does nothing if not currently recording

Example

resume

Resume a paused recording.

Behavior

  • Restarts recording from where it was paused
  • Calls start() internally
  • Does nothing if already recording

Example

isActive

Check if recording is currently active.
boolean
True if recording is active, false otherwise

Example

getEventCount

Get the number of events currently queued for upload.
number
Number of events in the upload queue

Example

clearEvents

Clear all queued events without uploading them.
This will discard events permanently. Use with caution.

Example

Privacy & Security

Masking Sensitive Data

By default, SessionRecorder masks all input values to protect user privacy. You can control this behavior:

Example HTML

PCI Compliance

For PCI compliance, ensure sensitive payment information is blocked:

Automatic Upload

Recordings are automatically uploaded to the MentiQ API:
  • Upload Interval: Every 10 seconds during recording
  • Endpoint: POST /api/v1/sessions/:sessionId/recordings
  • Final Upload: When stop() is called, remaining events are uploaded with is_final: true

Upload Payload

Performance Optimization

Sampling

Reduce performance impact by sampling events:

Maximum Duration

Limit recording length to control data volume:

Checkpoints

Take full DOM snapshots periodically:

Complete Example

Types

RecordingConfig

RRWebEvent

Browser Compatibility

SessionRecorder requires:
  • Modern browsers with MutationObserver support
  • localStorage for state management
  • Fetch API for uploads
Session recording only works in browser environments. Server-side rendering environments will log a warning if debug mode is enabled.