startRecording function exported ✓ 100.0%
Last updated: 2026-03-05T11:49:57.418Z
Metrics
LOC: 48
Complexity: 3
Params: 0
Coverage: 100.0% (15/15 lines, 0x executed)
Signature
startRecording(): : RecordingSession
Summary
Starts a new recording session. Attaches event listeners and mutation observer to capture user interactions.
Source Code
export function startRecording(): RecordingSession {
// Stop any existing session
if (session) stopRecording();
// Clear any previously stopped session so the new recording starts clean.
// Reset capturedResponses here (not in stopRecording) so that XHR loadend events
// that arrive after stopRecording can still append to the previous session's stoppedResponses.
stoppedSession = null;
stoppedResponses = [];
capturedResponses = [];
lastNetworkActivityTimestamp = 0;
session = {
steps: [
{
type: "navigate",
timestamp: now(),
url: window.location.href,
label: document.title || "Page",
},
],
startUrl: window.location.href,
startTime: now(),
status: "recording",
};
lastActionTimestamp = now();
// Attach event listeners
addListener(document, "input", onInput, { capture: true });
addListener(document, "change", onChange, { capture: true });
addListener(document, "click", onClick, { capture: true });
addListener(document, "submit", onSubmit, { capture: true });
addListener(document, "keydown", onKeyDown as EventListener, {
capture: true,
});
addListener(window, "beforeunload", onBeforeUnload);
addListener(window, "hashchange", onHashChange);
addListener(window, "popstate", onPopState);
// Start mutation observer for auto-wait detection
startMutationObserver();
// Start network monitoring for smart waits
startNetworkMonitoring();
return session;
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| stopRecording | calls |
| now | calls |
| addListener | calls |
| startMutationObserver | calls |
| startNetworkMonitoring | calls |
| document | dynamic_call |
| window | dynamic_call |
Impact (Incoming)
| Source | Type |
|---|---|
| FillableElement | uses |
| renderRecordTab | calls |