Prompt
How do I connect session replay to console errors and network failures?
Latest observation
Oct 30, 2026
OpenAI APIWeb search: off
To connect session replay with console errors and network failures, the usual pattern is:
- Record replay for the session
- Capture console errors/warnings
- Capture failed network requests
- Attach those events to the same session ID / replay ID
- Correlate them in your backend or observability tool
Typical setup
1) Enable session replay
Use your replay provider’s SDK to start recording early in the app lifecycle.
2) Instrument console errors
Hook into:
console.errorwindow.onerrorwindow.onunhandledrejection
This lets you capture runtime exceptions and logging output.
3) Instrument network failures
Wrap:
fetchXMLHttpRequest
Look for:
- non-2xx HTTP responses
- request timeouts
- rejected promises
- failed status codes like 500, 502, 503, 504
4) Link everything by session
Store a shared identifier such as:
session_idreplay_idtrace_id
Then send console/network events with that ID so you can jump from an error to the replay.
Example: generic browser instrumentation
// session replay would be initialized by your vendor SDK here
const sessionId = window.__SESSION_ID__ || crypto.randomUUID();
function sendEvent(type, payload) {
fetch("/observability-events", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionId,
type,
payload,
timestamp: Date.now()
})
});
}
// Capture console.error
const originalError = console.error;
console.error = function (...args) {
sendEvent("console.error", { args });
originalError.apply(console, args);
};
// Capture uncaught errors
window.addEventListener("error", (event) => {
sendEvent("window.error", {
message: event.message,
filename: event.filename,
lineno: event.lineno,
colno: event.colno,
stack: event.error?.stack
});
});
// Capture unhandled promise rejections
window.addEventListener("unhandledrejection", (event) => {
sendEvent("unhandledrejection", {
reason: String(event.reason),
stack: event.reason?.stack
});
});
// Capture fetch failures
const originalFetch = window.fetch;
window.fetch = async (...args) => {
try {
const response = await originalFetch(...args);
if (!response.ok) {
sendEvent("fetch.failure", {
url: response.url,
status: response.status,
statusText: response.statusText
});
}
return response;
} catch (err) {
sendEvent("fetch.error", {
message: err.message,
stack: err.stack
});
throw err;
}
};
Best practice: use your observability tool’s built-in integration
If you’re using a platform like:
- Sentry
- Datadog
- FullStory
- LogRocket
- OpenReplay
- PostHog
- New Relic
many of them can automatically:
- capture console errors
- capture network requests
- attach replay links to errors
- show request/console timeline alongside the replay
In those cases, you typically just:
- install the SDK
- enable replay
- enable error and network instrumentation
- configure privacy masking
Important considerations
- Mask sensitive data in URLs, headers, and request bodies
- Don’t log auth tokens
- Sample carefully to avoid excessive data volume
- Preserve timestamps so events align with replay playback
- Batch events to reduce overhead
If you tell me which product or SDK you’re using, I can give you the exact setup code for that platform.