What Is Session Replay?
Session replay records a user's interaction with your web application and lets you play it back as a video. You see exactly what the user saw: clicks, scrolls, form inputs, page navigations, and errors. It is like looking over the user's shoulder without actually being there.
Unlike screen recording, session replay works by recording DOM mutations and reconstructing the page in a virtual browser. This means the recording files are small (typically 100-500KB per minute) and there is minimal performance impact.
How Session Replay Works
The technical implementation involves three steps:
1. Recording
A JavaScript library observes DOM changes using MutationObserver and records events:
- DOM mutations (element additions, removals, attribute changes)
- Mouse movements and clicks
- Scroll positions
- Form input changes (with sensitive fields masked)
- Network requests and responses
- Console logs and errors
2. Processing
The recorded events are batched and sent to the server, where they are compressed and stored. Most tools send data in batches every few seconds to minimize network impact.
3. Playback
During playback, the tool reconstructs the DOM state at each point in time and replays the events. The result looks like a video but is actually a DOM reconstruction, which means you can inspect elements, view network requests, and see console output alongside the visual replay.
When Session Replay Is Invaluable
Bug Reproduction
The number one use case is reproducing bugs. When a user reports "the checkout button does not work," session replay shows you exactly what happened:
- What browser and device they used
- What they clicked and in what order
- What the page looked like at the time
- What errors appeared in the console
Understanding User Behavior Before Errors
When session replay is integrated with error tracking (like in Bugsly), you can jump directly from an error to the session replay showing the user's actions leading up to the crash. This context is often the difference between a 5-minute fix and a 2-hour investigation.
UX Debugging
Sometimes the "bug" is not a code error but a confusing user interface. Session replay reveals rage clicks (rapid clicking on a non-responsive element), dead clicks, and navigation confusion that you would never see in error logs.
Privacy Considerations
Session replay captures user interactions, which means privacy must be handled carefully.
What to Mask
Always mask sensitive information:
Bugsly.init({
dsn: 'YOUR_DSN',
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
replay: {
maskAllText: false,
maskAllInputs: true,
blockSelector: '.sensitive-data, .credit-card',
},
});- Form inputs: Mask all form inputs by default, especially passwords and payment fields
- Sensitive text: Block elements containing personal health, financial, or legal information
- Images: Block user-uploaded profile photos if privacy is a concern
Compliance
- GDPR: Session replay is considered personal data processing. Include it in your privacy policy and cookie consent.
- HIPAA: Healthcare applications should generally avoid session replay or use very strict masking.
- CCPA: Users should be able to opt out of recording.
Sampling Strategy
Recording every session is expensive and usually unnecessary. Use sampling:
- General sessions: Sample 1-10% of all sessions
- Error sessions: Record 100% of sessions where an error occurs
- Targeted pages: Record higher percentages on checkout or signup flows
Integration with Error Tracking
The real power of session replay comes from integration with error tracking. When an error occurs:
- The error appears in your dashboard with a stack trace and AI analysis
- A "Watch Replay" button takes you to the exact moment the error happened
- You see the user's actions for the 30-60 seconds before the error
- You understand not just what went wrong technically, but what the user was trying to do
This combination of technical error data and visual context is the fastest path to understanding and fixing bugs.
Getting Started
Most error tracking tools with session replay (Bugsly, Sentry, LogRocket, Highlight.io) require adding a single configuration option to enable recording. Start with a low sample rate and increase as needed.
Try Bugsly Free
AI-powered error tracking that explains your bugs. Set up in 2 minutes, free forever for small projects.
Get Started Free