thelastapi
Get started free

See the JavaScript errors your visitors actually hit

Track JavaScript errors your users hit by enabling session replay to catch front-end crashes and see exact visual snapshots of what broke.

On this page 8 sections

You can track the JavaScript errors your users hit by enabling the session replay resource on your site tag, which automatically records runtime exceptions alongside the affected sessions. thelastapi captures client-side exceptions without extra logger libraries, links them directly to the user's recorded session, and lets you inspect still frames of the page at the exact millisecond the error occurred. You can review broken sessions through the CLI, inspect them via API, or monitor automated alerts when front-end error rates spike.

When an unhandled exception throws in production, traditional server logs stay silent. Front-end error tracking bridges that gap by capturing browser exceptions where they happen, showing you not just the stack trace, but what the user was doing right before the page broke.

How client-side error recording works

Tracking browser errors usually means adding an error-monitoring library, configuring sourcemaps, and hoping the stack trace gives enough context to reproduce the bug. With thelastapi, client-side error collection is handled directly by the analytics and replay tag.

Every project includes the analytics resource by default. To capture errors and full user sessions, you add the replay resource to your project:

Terminal
vibiz add replay

Once replay is enabled, the script tag placed in your HTML records page interactions and browser runtime errors:

HTML
<script defer src="https://thelastapi.dev/v1/script.js" data-key="vz_pk_..."></script>

When a visitor hits an unhandled JavaScript error, the recorder tags that session. If you set sample_rate below 1 to record only a fraction of normal visits, the client script still uploads sessions that encounter a JavaScript error, a rage click, or a dead click.

Sessions are kept for 30 days by default (configured between 1 and 90 days via retention_days). Sensitive data never leaves the visitor's browser:

  • Passwords, credit card numbers, and one-time verification codes are never recorded.
  • Text matching email addresses, phone numbers, cards, or IBAN strings is masked before upload.
  • Custom areas can be masked with the data-vibiz-mask attribute or excluded entirely using data-vibiz-sensitive.

To understand broader user patterns alongside these errors, see our guide on where your visitors come from: sources, countries and devices.

Finding broken sessions from the terminal

When visitors experience errors, you do not need to sift through thousands of healthy visits. The vibiz CLI lets you filter replay recordings specifically for sessions containing unhandled errors:

Terminal
vibiz replays --errors --period 7d

This command lists sessions from the last seven days where unhandled JavaScript errors were caught. It outputs the session ID, timestamp, the URL path where the error occurred, and the count of errors within that visit.

To inspect a single session and retrieve its details, pass the session ID:

Terminal
vibiz replay rpl_123456789

This returns the session signals (including total errors, dead clicks, and rage clicks), visitor metadata, and a private link to review the recording. Private replay links expire after 1 hour by default (configurable up to 24 hours).

If you are automating error triage using AI agents, you can query replay details programmatically using the tools vibiz_replay_insights and vibiz_replay_detail. For more on managing user recordings cleanly, see session replay for a small site: masked, cheap and useful.

Seeing what the visitor saw: visual error frames

Reading a JavaScript error message in isolation rarely reveals why an interface broke. A TypeError: Cannot read properties of undefined could mean a missing API payload, a broken button state, or an unrendered form modal.

Rather than watching an entire ten-minute video session to find a bug, you can pull still pictures of the exact moments where errors happened using frames:

Terminal
vibiz replays frames rpl_123456789 --moments error --out ./error-snapshots

This downloads static PNG files of the page at the exact moment of each error. The frame is generated by rebuilding the recorded DOM state at that instant against your site's styles and assets, matching the visitor's exact screen dimensions. If the error happened on a mobile device, the snapshot renders at the visitor's phone viewport size.

You can also fetch frames using the HTTP API:

Terminal
curl "https://thelastapi.dev/v1/replays/rpl_123456789/frames?moments=error" \
  -H "Authorization: Bearer $VIBIZ_API_KEY"

The API returns a JSON payload containing signed URLs for the generated frame images:

JSON
{
  "frames": [
    {
      "kind": "error",
      "offset_ms": 14200,
      "page": "/checkout",
      "label": "TypeError: Cannot read properties of undefined (reading 'total')",
      "viewport": {
        "width": 390,
        "height": 844
      },
      "status": "ready",
      "image": {
        "url": "https://example.com/frames/snapshot_1.png",
        "expires_at": "2026-11-12T13:00:00.000Z"
      },
      "cached": true,
      "cost_micro_usd": 0
    }
  ],
  "cost_micro_usd": 0,
  "new_frames": 0
}

Image URLs are valid for one hour. Each new visual snapshot is metered at the standard screenshot rate; viewing an already-generated frame is free.

Monitoring error spikes with Mission Control

You do not have to poll the CLI manually to know if a deploy broke your front end. Every project has automatic background checks built into Mission Control.

About once an hour, background workers evaluate the operational health of your application. The Experience step specifically monitors front-end health by looking at session replays and error rates over the trailing 24 hours.

Health StatusTrigger ConditionMeaning
okNormal error ratesBaseline user experience
warn3+ error sessions, 5+ rage clicks, or 10+ dead clicks in 24 hElevated frustration or isolated errors
fail10+ error sessions in 24 h and 3× the usual daily baselineMajor error spike or broken deployment

You can check your account's health status anytime from the CLI:

Terminal
vibiz health --failing

If an error spike hits, vibiz health surfaces it under the Experience step, showing the failure detail, how long it has been failing, and how to resolve it. You can trigger an immediate re-check of all checks across your projects with vibiz health run. Read the Mission Control and health checks documentation to see how health statuses roll up across multiple projects.

Connecting error tracking on external hosts

Analytics and replay run on any website, whether hosted on thelastapi or on another infrastructure provider.

If your web application runs on external hosting, initialize a project with the analytics and replay resources:

Terminal
vibiz init my-external-app --resources analytics,replay

Add your domain to the project so the API accepts events from it:

Terminal
vibiz domains add app.example.com --elsewhere

Grab your tracking script snippet:

Terminal
vibiz analytics snippet

Paste the <script> tag into your site's HTML template before the closing </head> tag. Events and error sessions are accepted only from your configured domains and subdomains.

If your backend also emits transactional operations, you can track those alongside front-end analytics using our guide on server-side event tracking from your backend.

Identifying authenticated users when errors occur

Debugging a JavaScript exception is faster when you know which account encountered it. You can bind a session to a specific user ID after authentication:

JavaScript
// Call after successful login
vibiz('identify', user.id);

// Call upon logout
vibiz('identify', null);

When an error occurs, the recording links to that user ID, unifying previous anonymous browsing actions in that browser with their user record. This allows you to cross-reference customer support tickets directly with visual session recordings. To learn more about querying registered users without running direct database queries, see see who signed up: your users, without a production query.

If your users reside in regions requiring opt-in consent for session recording (such as the EU or the UK), you can set require_consent: true in your replay configuration via:

Terminal
curl -X PATCH "https://thelastapi.dev/v1/projects/prj_123/resources/replay" \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"config": {"require_consent": true}}'

When consent is required, recording will not begin until your cookie or consent banner calls:

JavaScript
vibiz('replay', 'start');

Review the complete configuration options in the Analytics and replay reference.

Next steps

Add replay to your project with vibiz add replay, verify your domain with vibiz domains add, and run vibiz replays --errors --period 7d after your next deployment to review the front-end issues your visitors encounter.

Frequently asked questions

Does the analytics script capture stack traces for every unhandled error?

Yes, unhandled runtime exceptions are captured by the replay recorder and associated with the active session timeline, accessible via the CLI or API.

How much does session replay and error recording cost?

Event ingestion and session capture are recorded at $0, while replay storage costs $0.023 per GB-month plus the standard platform margin.

What happens if a user enters sensitive information on a page with an error?

Passwords and payment fields are never recorded, and emails, phone numbers, and card numbers are masked directly in the visitor's browser before upload.