All articles Fundamentals

JavaScript Error Tracking with Replay: See What Broke

Translucent glass panel on a black background with a blue line shifting from jagged to smooth, a developer silhouette watching

JavaScript error tracking with replay links two records that teams usually keep apart: the exception your code threw and the session that produced it. A stack trace tells you which function failed. The session tells you what the person clicked, which step they were on, and whether that same error had already fired twice before they gave up. Together they turn “Cannot read properties of undefined” into a case you can reproduce in minutes.

Most teams already collect one half or the other. Error monitoring catches the throw but loses the context. Session replay shows the frustrated click but not the cause. Joining them is mostly discipline: one identifier shared by both, one payload that travels with every error, and a review loop that ends in a fix.

This guide covers the wiring, the fields worth storing, how to read a session once you have it, and how to keep user input out of your debugging pipeline.

Why a stack trace alone stalls the fix

A production stack trace is a compressed artifact. Frames are minified, the route is often missing, and the report rarely says whether the error broke the page or was swallowed three layers up. Whoever picks up the ticket has to guess the steps, then reproduce them locally with different data, a different build and a different browser.

The expensive part is not the fix. It is the search: asking the person what they did, matching their answer to a release, and discovering the error only happens when a saved draft is reopened on a slow connection. Replay removes most of those round trips.

Fields every error record should carry

  • A stable fingerprint: message plus top stack frame plus route, so one bug groups into one issue.
  • The release or commit hash, to tell whether a deploy introduced it.
  • The route and the last navigation, not just the page where the error surfaced.
  • The session and visitor identifiers used by the replay agent.
  • A timestamp you can line up with Web Vitals, because a slow interaction and a thrown error often share a cause.
  • A first-seen or repeat flag, so you know if the session was already degrading.

How to pair a JavaScript error with its replay

The mechanics are simple: the replay agent runs in the same page as your code and holds a session identifier. Attach that identifier to every error you report and the two records open side by side. Three rules make the difference.

Person at a desk facing layered sheets of dark glass lit by blue light

Start the session before your application code runs. Errors thrown during bootstrap — a missing config, a failed feature flag, an undefined global — are exactly the ones a late initialization misses.

Report errors through one function. If half your errors come from a global handler and half from a framework hook, normalize them into the same shape or you will spend review time reconciling formats.

Do not let the client decide severity. Send what happened and triage on the server; a client-side filter that drops “noise” usually drops the first occurrence of the bug you needed.

// pseudo-code: one session id shared by replay and error reporting
const session = startSession(); // { sessionId, visitorId }

window.addEventListener('error', (event) => {
  reportError({
    message: event.message,
    stack: event.error?.stack,
    route: location.pathname,
    release: APP_VERSION,
    sessionId: session.sessionId,
    occurredAt: new Date().toISOString(),
  });
});

Group by fingerprint before you open anything. Ten reports of the same error on the same route is one investigation, not ten. Our docs cover the session and error APIs in detail: https://pryntid.com/docs.

Read the session, not just the error

Once the error is attached to a session, watch the thirty seconds before it fired. Replay marks error clicks, rage clicks (repeated clicks in the same spot) and dead clicks (clicks on elements that never responded). Those signals usually separate three problems:

  • The element was there but the handler was not bound yet: a hydration or timing bug.
  • The element moved or was covered: a layout or z-index bug.
  • The click never reached anything: a disabled control with no explanation, which people click harder.

Web Vitals next to the error timeline separate “the code is wrong” from “the code was slow”. A checkout that throws after a long main-thread block is a performance fix, not a null check. Py, the Prynt AI, summarizes the steps, the error and the likely cause with the events it used — a first pass for triage, not a replacement for reading the session yourself.

Keep form data out of the debug loop

The fastest way to turn a debugging tool into a compliance problem is to record what people type. Replay masks every form field in the browser and again on the server, with no unmask option, so a reviewer sees the shape of the input and not the content. Build your own error payloads the same way: never attach form values, and never attach URLs that carry tokens in the query string. The platform overview at https://pryntid.com/platform explains what is stored and where.

Two floating dark panels linked by a thin blue thread, one showing a pulse and one a timeline

Turn replays into a triage loop

A replay is only useful if it reaches the person who will fix the bug. Share links with comments turn a session into a discussion on the exact second it went wrong, and segments by route, browser or release show whether an error is one device or a whole cohort. If your product is multi-tenant, you can embed sessions in your own admin per company or user, list them with a secret key and open them in the embedded player, so support reads the same recording engineering does.

FAQ

Hand pressing a glowing blue shape on a dark glass surface with soft ripples

Does replay replace an error monitoring tool?

No. They answer different questions. Error monitoring groups exceptions and tracks release health; replay explains the session around a specific failure. Most teams keep both and join them by session identifier, which is what the setup above does.

Do bots count against my session quota?

No. Bot sessions are excluded. The Free plan includes 1,000 sessions a month with 14-day retention on one site; Pro is $279/month for 10,000 sessions, 30-day retention and three sites, with a 14-day trial.

Can I see errors on mobile apps?

Yes. Native mobile replay covers iOS, Android, React Native and Flutter, and the same session identifier pattern applies, so an error can be opened next to the session that produced it.

Start on the free plan and open one session with an error attached. If it saves you a single reproduction, the setup paid for itself: https://pryntid.com

Try it free

Prynt is device intelligence with a free plan: 5,000 identifications a month, visitor IDs with confidence and bot detection — no credit card. Upgrade to Pro for VPN, proxy, tampering and behavioral signals.

Keep reading