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()]} />;
nuxt.config.ts
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",
});
OptionTypeDefaultDescription
maskAllInputsbooleantrueMasks the value of every input field
maskInputOptionsobjectpassword, email, and telInput types masked when maskAllInputs is false
maskTextSelectorstringnoneMasks text inside elements matching this selector
maskTextClassstringnoneMasks text inside elements with this class
blockSelectorstringnoneSkips recording elements matching this selector
blockClassstringnoneSkips 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"],
});
OptionTypeDefaultDescription
recordConsolebooleanfalseRecords console output during the session
consoleLevelstring[]["error", "warn", "info", "log"]Console methods to record
consoleLengthThresholdnumber200Maximum number of console entries recorded
consoleStringLengthLimitnumber500Maximum 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.

OptionTypeDefaultDescription
flushIntervalnumber15000Milliseconds between uploads
maxEventsnumber1000Events per batch before an early flush
maxBatchSizeBytesnumber921600Batch size before an early flush
maxPendingBatchesnumber30Batches that may wait for upload
maxQueueSizeBytesnumber2097152Memory limit for buffered replay data
minReplayLengthMsnumber3000Recordings shorter than this are discarded
checkoutEveryNmsnumber300000Milliseconds between full DOM snapshots
compressbooleantrueGzips 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.

OptionTypeDefaultDescription
enabledbooleantrueSet to false to record every mutation
bucketSizenumber100Attribute mutations a node may burst
refillRatenumber10Attribute mutations per second a node regains

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.