Session Replay
Overview
Session replay captures what a user actually saw and did, so you can watch the sessions behind a failed purchase, an abandoned paywall or a support ticket. Recordings are chunked, uploaded, and played back in Dashboard → Analytics → Session Replay.
Replay is off by default on every platform and is billed per recording. Read the sampling section before you enable it in production.
Web
The recorder is dynamically imported, so apps that don't enable replay never ship the ~70 kB bundle. Customers who do enable it must install rrweb themselves — it is an optional peer dependency, never a hard one.
npm install rrwebimport { startSessionReplay } from '@billdog.io/web';
const stop = await startSessionReplay({
apiKey: 'bd_public_live_...',
customerId: 'cus-uuid', // optional — set once you identify()
mask: true, // default true
maskAllText: false, // default false
sampleRate: 0.1, // record 10% of sessions
onError: (e) => console.warn('replay', e),
});
// ...later
stop();Or let configure() start it: BillDog.configure({ apiKey, enableSessionReplay: true, sessionReplay: { sampleRate: 0.1 } }). Neither needs a project id: recordings are filed under the project your API key belongs to.
Events are batched and flushed on whichever comes first: 500 events, 5 MB, or 10 seconds.
Sampling & billing
Use sampleRate on startSessionReplay — nowhere else. @billdog.io/analytics exposes a sampleRate for its own replay path, but that path never creates a recording. Setting it there has no effect on your bill. The option documented above is the one that does.
A session that is sampled out costs nothing and creates no session_replays row at all. Sampling is therefore the only real lever on replay volume and spend.
The decision is made once per session and is sticky — it is stored in sessionStorage and reused across reloads within the tab. A sampled-in session is never truncated halfway through, and a sampled-out session never starts recording on page 3.
Replay bills on two graduated meters — web and mobile are metered separately, each with its own monthly free allowance. See Pricing.
iOS
iOS records periodic screenshots rather than a DOM stream, so it exposes an interval instead of a flush size. Pass a SessionReplayConfig when you configure the SDK.
import BillDogFull
BillDog.shared.configure(config: .init(
apiKey: "YOUR_API_KEY",
sessionReplay: SessionReplayConfig(
enabled: true,
sampleRate: 0.1, // 0...1, applied once per session
maskAllInputs: true, // default true
maskAllText: false, // default false
intervalSeconds: 1.0 // snapshot cadence, floor 0.2s
)
))sampleRate is clamped to 0...1 and intervalSeconds to a minimum of 0.2, so out-of-range values are corrected rather than rejected.
Android
Android capture lives in the billdog-replay module. Register it after BillDog.configure and start it with a SessionReplayConfig.
import io.billdog.core.BillDog
import io.billdog.replay.BillDogReplay
import io.billdog.replay.SessionReplayConfig
val replay = BillDogReplay()
BillDog.use(replay)
replay.enableSessionReplay(
application,
SessionReplayConfig(
sampleRate = 0.1, // 0..1, decided once per session
maskAllInputs = true, // default true
maskAllText = false, // default false
maskAllImages = false, // default false
)
)
// later: replay.disableSessionReplay()BillDogConfig.sessionReplayEnabled does not start recording: it only overrides the dashboard's Session Replay switch, and any non-null value makes the SDK ignore that switch. Leave it unset to let the dashboard start replay for a registered module.
React Native and Expo
A React Native screen is native views, so @billdog.io/react-native (and @billdog.io/expo, which re-exports it) hands recording to the native iOS and Android recorders. Everything is masked by default; testID="bd-mask" covers a view and its children whatever the options say. Needs a development build (not Expo Go).
import { SessionReplayManager } from '@billdog.io/react-native'; // or '@billdog.io/expo'
const replay = SessionReplayManager.getInstance();
await replay.start({
sampleRate: 0.1, // 0..1, decided once per session
maskAllInputs: true, // default true (secure fields are always covered)
maskAllText: true, // default true
maskAllImages: true, // default true
});
// <Text testID="bd-mask">{backupCode}</Text>
await replay.stop();After optOut() and optIn(), iOS starts a new recording by itself; on Android, call start() again.
Flutter
A Flutter UI is one native view, so the native recorders cannot see or mask its widgets. The Flutter SDK captures the screen in Dart and masks it from the render tree, then hands each frame to the native SDK, which uploads it under the same rules (opt-out, consent, sampling, session, customer). Wrap the app in BillDogReplayRoot once, and wrap anything that must never be recorded in BillDogReplayMask.
runApp(const BillDogReplayRoot(child: MyApp()));
// after BillDog.configure(...)
await BillDogSessionReplay.start(
sampleRate: 0.1, // 0..1, decided once per session
maskAllInputs: true, // default true (obscured fields are always covered)
maskAllText: true, // default true
maskAllImages: true, // default true
);
BillDogReplayMask(child: Text(backupCode));
await BillDogSessionReplay.stop();The dashboard's Session Replay switch does not start recording in a Flutter app (the native recorder it would start cannot mask widgets): call start().
Masking & privacy
Input masking is on by default on every platform — you have to opt out, not opt in.
mask/maskAllInputs— masks input values. Default true.maskAllText— masks every text node, not just inputs. Default false.- On web, elements carrying
[data-billdog-mask]or[data-private]are masked regardless of the other settings. Thebd-maskmarker is read by@billdog.io/session-replay(as a CSS class), by iOS (accessibility identifier) and by Android (view tag or resource id) —startSessionReplaymatches the two attributes above instead.
Sign-in and MFA screens
The two defaults pull in opposite directions on an authentication screen. Inputs are masked, but maskAllText is off, so whatever the screen renders as text is recorded verbatim. That was harmless while sign-in happened on a page you did not instrument. It stops being harmless once it happens inside the app you are recording.
TOTP enrolment is the sharp edge. auth.factors.enrolTotp() returns a secret and a provisioningUri, and auth.factors.confirmTotp() returns backupCodes — ten eight-character strings you must display once, because they are stored hashed and cannot be shown again. All of it is rendered for a person to read or scan, as text or as a QR image, so maskAllInputs never touches any of it. A recording of that screen is a recording of a working second factor. See MFA.
Mask those surfaces explicitly. The marker differs by platform:
- Web —
data-billdog-maskordata-privateon the element. Both are text masks and will not remove an image.startSessionReplayleaves rrweb’s own default block class in place, sorr-blockon a wrapper blocks it outright: only its width and height are recorded, and nothing inside it. - iOS — any view whose
accessibilityIdentifiercontainsbd-maskis covered along with its whole subtree, images included. In SwiftUI, where a view has no identifier the recorder can see, use.billDogReplayMask(). Both iOS recorders honour these (sessionReplayandBillDog.shared.replay). Secure text fields are always covered, even withmaskAllInputsoff. - Android — any view whose tag or resource entry name contains
bd-maskis covered along with its whole subtree. PasswordEditTextfields are always covered.
<!-- Backup codes are text. Input masking does not reach them. -->
<ul data-private>
<li>K7QM-3XZP</li>
</ul>
<!-- The provisioning QR is an image; a text mask leaves it legible. -->
<div class="rr-block">
<img alt="Scan this with your authenticator app" src="..." />
</div>Stopping the recorder around the screen is the blunter option and it has a cost. startSessionReplay returns stop(), and starting again in the same tab resumes the same recording rather than billing a second one — the session token is held in sessionStorage. But the restarted recorder counts chunks from zero, and chunks are written on (recording, chunk index), so the second run’s first chunk overwrites the first run’s. Masking the elements is the safer lever.
The hosted AuthCard is not where the exposure is: its identifier, code and password fields are all inputs, so the default input masking covers them. The risk is on the screens you build around it — enrolment above all.
Replay has its own consent purpose. Consent is not one flag — there are four independent purposes: analytics, replay, messaging and survey. Granting analytics consent does not grant replay consent.
When consent is required, startSessionReplay records nothing until replay specifically is granted. rrweb is not started, no clicks, console errors or failed requests are counted, and no recording token is written. It starts when replay is granted, later in the same page. So you can start the recorder before your consent banner has been answered, provided consent is already required on that page load: call setConsentRequired(true) before startSessionReplay, or before configure() with enableSessionReplay. The recorder does not read the project's consent setting from the dashboard. A recorder started while consent is not required records from its first frame.
Withdrawing replay consent stops the recorder and discards every frame not yet uploaded. It does not flush them. The one exception is a chunk that is already uploading, which cannot be recalled. While consent is required, setConsent('replay', false) and setConsentGiven(false) are withdrawals, and so is setConsentRequired(true) before replay was granted. While consent is not required, every purpose counts as granted, so those two calls on their own stop nothing. Require consent first.
The recorder also honours optOut() from @billdog.io/analytics, including an opt-out saved on an earlier visit. It records nothing while the visitor is opted out, and an opt-out made while it is recording stops it and discards in the same way. To stop from your own code without uploading, call discard() on the function startSessionReplay returned. Calling the function itself uploads what is buffered.
Some browsers block storage outright: Safari's “Block all cookies”, sandboxed or storage-denied iframes, some enterprise policies. There the recorder cannot read a consent or opt-out saved on an earlier page, and other tabs cannot reach it. A decision made on the page itself still applies: consent set with @billdog.io/core, and an optOut() that could not be saved. If consent is not required, the recorder records as usual. If it is required, the recorder records nothing until replay is granted on that page, and calls your onError once to say why.
Granting replay again, or optIn(), starts a new recording: a new session token, a fresh sampling decision and a fresh full snapshot. It is billed as a recording of its own. Nothing captured before the withdrawal is recovered or joined to it. A change made in another tab of your site reaches a recorder that is already running, and so does a change made while a page sat in the back/forward cache.
The $snapshot event that carries replay frames is special-cased to the replay purpose — it has no "replay" substring in its name, so it would otherwise fall through to analytics. See Compliance.
Upload, retries and failure handling
Frames are buffered and uploaded in chunks bounded at 500 events or 5 MB, whichever comes first. Every upload resolves to one of four outcomes, and the difference between them matters operationally:
| Outcome | Triggered by | Behaviour |
|---|---|---|
| success | 2xx | Chunk cleared |
| retry | network error · 408 · 429 · 5xx | Exponential backoff — 2n seconds, capped at 60s, up to 5 attempts |
| drop | 400 · 413 · other permanent 4xx | That chunk is skipped; recording continues |
| halt | 401 · 403 | The recorder stops entirely |
An exhausted replay allowance answers 200 with quota_limited, and the recorder halts. This is deliberate — retrying a rejected account forever meant every open tab re-POSTing its full buffer every 10 seconds. If replay silently stops mid-month, check your allowance before you check your integration.
Buffered events are capped at 5,000 so a sustained upload failure cannot grow memory without bound. Beyond that ceiling the oldest frames are discarded rather than the tab degrading.
Viewing recordings
Open Dashboard → Analytics → Session Replay. Recordings are stored as ordered chunks and streamed on demand through signed URLs, so a long session loads progressively rather than all at once.
AI summary of a recording
On a CortX AI plan, a recording can be summarised in one paragraph so you can decide whether to watch it. Open the recording and choose Generate in its AI summary panel. On the free plan the request is refused, because the feature needs a CortX AI plan.
- The summary is written from the signals the recorder captured: duration, click times and positions, and click and error counts. It never sees the video or the page itself, so it can say that errors happened but not what they said.
- A recording can be summarised again at most once every five minutes.
- The read-only public demo project cannot generate summaries.
Related
Was this page helpful?
Or rate this page: