Session Replay
Record DOM sessions with rrweb
Session replay records DOM mutations and user interactions using rrweb. Recordings are serialized events, not video.
Enable Replay
Import and add the session replay extension.
import { sessionReplay } from "@faststats/react/replay";
<Analytics siteKey="your_site_key" extensions={[sessionReplay()]} />;faststats: {
siteKey: "your_site_key",
extensions: { sessionReplay: true },
}import { init } from "@faststats/web";
import { sessionReplay } from "@faststats/web/replay";
init({
siteKey: "your_site_key",
extensions: [sessionReplay()],
});In Nuxt, pass an options object instead of true to configure the recorder.
Every option below works in all three packages.
Privacy and Masking
Input values are masked by default. Mask or block more of the page with selectors and classes.
sessionReplay({
maskTextSelector: ".sensitive",
blockSelector: ".no-record",
});| Option | Type | Default | Description |
|---|---|---|---|
maskAllInputs | boolean | true | Masks the value of every input field |
maskInputOptions | object | password, email, and tel | Input types masked when maskAllInputs is false |
maskTextSelector | string | none | Masks text inside elements matching this selector |
maskTextClass | string | none | Masks text inside elements with this class |
blockSelector | string | none | Skips recording elements matching this selector |
blockClass | string | none | Skips recording elements with this class |
Any element you mark as blocked is replaced with a placeholder, so its content never leaves the browser.
Console Recording
Console output is not recorded unless you turn it on.
sessionReplay({
recordConsole: true,
consoleLevel: ["error", "warn"],
});| Option | Type | Default | Description |
|---|---|---|---|
recordConsole | boolean | false | Records console output during the session |
consoleLevel | string[] | ["error", "warn", "info", "log"] | Console methods to record |
consoleLengthThreshold | number | 200 | Maximum number of console entries recorded |
consoleStringLengthLimit | number | 500 | Maximum length of a serialized string value |
Network Recording
Network recording is off by default. Enabling it records resource URLs and
timing data. Headers and bodies are not recorded unless you opt in through
networkOptions.
sessionReplay({
recordNetwork: true,
networkOptions: {
initiatorTypes: ["fetch", "xmlhttprequest"],
transformRequestFn: (request) => {
const url = new URL(request.name);
if (url.pathname.startsWith("/private/")) return;
url.search = "";
request.name = url.toString();
return request;
},
},
});networkOptions is passed to rrweb’s network plugin and has no effect unless
recordNetwork is true. Return nothing from transformRequestFn to drop a
request. recordHeaders, recordBody, and recordInitialRequests can also be
set there; redact sensitive data before enabling headers or bodies.
Requests to FastStats collection endpoints, including a custom baseUrl, are
always excluded.
transformRequestFn is a function, so it cannot be set from nuxt.config.
Batching and Limits
Replay events are buffered in the browser and uploaded in gzip-compressed batches. The recorder also flushes when the page is hidden, when the session rotates, and when a batch reaches its event or byte limit.
| Option | Type | Default | Description |
|---|---|---|---|
flushInterval | number | 15000 | Milliseconds between uploads |
maxEvents | number | 1000 | Events per batch before an early flush |
maxBatchSizeBytes | number | 921600 | Batch size before an early flush |
maxPendingBatches | number | 30 | Batches that may wait for upload |
maxQueueSizeBytes | number | 2097152 | Memory limit for buffered replay data |
minReplayLengthMs | number | 3000 | Recordings shorter than this are discarded |
checkoutEveryNms | number | 300000 | Milliseconds between full DOM snapshots |
compress | boolean | true | Gzips batches when the browser supports CompressionStream |
If the queue limits are reached, capture stops for that recording instead of leaving a gap.
Recording Tuning
sampling and slimDOMOptions are passed to rrweb and default to throttled
mouse movement and scroll events and a DOM snapshot without scripts, comments,
and non-essential <head> metadata.
mutationThrottle limits attribute changes on a single node so an animation
that rewrites the same element many times a second does not bloat the recording.
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Set to false to record every mutation |
bucketSize | number | 100 | Attribute mutations a node may burst |
refillRate | number | 10 | Attribute mutations per second a node regains |
Consent
Replay follows your consent setup. Setting consent to "denied" stops the
recorder and discards buffered events. Switching between "anonymous" and
"granted" drops what is buffered and starts a new recording, so the two modes
never share one. In anonymous and cookieless mode recordings are not linked to
an anonymous visitor. See Consent and Cookieless.