AlgoViz

Monitoring client-side errors

medium 32 min

Some errors never reach your servers: a name that does not resolve, a blocked connection, a script that breaks in the browser.

See it run

Follow a broken click to its repair, see what never reaches a server, and judge how the page feels.

Operations

From click to issue

Seven steps after a user clicks a button.

Step 1 of 7

A click

Browser pageclickError handlerCollectorError trackerOn call

Nothing special yet

A user clicks Checkout.

Step 1: A click

on("click", run)on("error", handle)event = add(trail, release, browser, path)event = mask(event)send_beacon(collector, event)place = source_map[event.release][event.frame]issue(place).sessions.add(event.session)
Shows
The exact line
Costs
2 KB per report
Without it
the button does nothing

Mask on the device. What is never sent cannot leak.

In the real world

The same monitoring client-side errors doing real jobs. Pick one and step through it.

A visitor keeps a page open during a release.

Step 1 of 4

9:00

chunk 5Browser pageknows 5.abc.jsFile storage5.abc.js

Nothing wrong

The page knows the file 5.abc.js.

Step 1: 9:00

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • The collector on your own domain

    critical

    Its reports fail together with the site.

    Wrong
    collector = "/api/errors"
    Right
    collector = "https://collect.example.net/errors"
  • Public source maps

    major

    Anybody can read your original source.

    Wrong
    deploy("app.js", "app.js.map")
    Right
    tracker.upload("app.js.map", release)deploy("app.js")
  • No limit

    major

    A fault in a loop sends thousands of reports.

    Wrong
    on_error(send)
    Right
    if seen[key] == 1 and sent < 10:    send(event)
  • Filtering chunk errors

    major

    Users stay with a dead page and you see nothing.

    Wrong
    if kind == "ChunkLoadError": return None
    Right
    count(kind)reload_once()

Interview tips

  • Do

    • Upload source maps privately.
    • Breadcrumbs for actions.
    • Error boundaries around parts.
    • Core Web Vitals of real users.
    • Mask in replays.
  • Do not

    • Publish source maps.
    • Record passwords or personal data.
    • Ignore CORS errors.
    • Send everything without sampling.
    • Forget promise rejections.
  • BROWSER

    • Breadcrumbs, RUM, Onerror.
    • Web vitals: LCP, INP, CLS.
    • Source maps.
    • Error boundary, Replay.
  • Numbers

    • LCP 2.5 s, INP 200 ms, CLS 0.1.
    • 75th percentile.
    • 64 KiB for beacons.
    • Replay 100% on error.