Monitoring client-side errors
medium 32 minSome 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
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
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
criticalIts reports fail together with the site.
Wrongcollector = "/api/errors"Rightcollector = "https://collect.example.net/errors"Public source maps
majorAnybody can read your original source.
Wrongdeploy("app.js", "app.js.map")Righttracker.upload("app.js.map", release)deploy("app.js")No limit
majorA fault in a loop sends thousands of reports.
Wrongon_error(send)Rightif seen[key] == 1 and sent < 10: send(event)Filtering chunk errors
majorUsers stay with a dead page and you see nothing.
Wrongif kind == "ChunkLoadError": return NoneRightcount(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.