Kayavak / The Web Frontend / FE·32 Frontend Observability / Deeper
Deeper · The Web Frontend
Frontend Observability
The questions the chapter doesn't stop for: why this exists, the model to keep in your head, what changes when an assumption does, how sure we are of each claim, and what's still open. Read it after the chapter; back to the chapter.
Why does this exist?
Server teams have logs and metrics for every request; frontend teams were long blind, because their code runs on
millions of devices they never see. Early tools hooked window.onerror and sent reports home, but the reports were
nearly useless: minified code reported errors at line 1, column 40,000. Source maps (developed at Google and
Mozilla around 2009–11) mapped compiled code back to the original files, which made client error tracking practical.
Browsers then began exposing timing data: the Navigation Timing API (2012), Resource Timing, and later PerformanceObserver and the APIs behind Core Web Vitals. Real-user monitoring (RUM) grew out of these, collecting what users actually experienced instead of what lab tests predicted. Distributed tracing reached the browser through standards like W3C Trace Context (2020) and OpenTelemetry, so a slow click could be followed into backend services.
The mental model
Try it yourself first: write your own model in the Mental Model Explorer, then compare.
You can't reproduce what you can't see. Frontend observability is deliberately collecting just enough from users' browsers (errors, timings, the path to a failure) to explain problems you'd otherwise never hear about.
| Question | Answer |
|---|---|
| What is it? | Error tracking, performance monitoring (RUM), logs and traces from code running in users' browsers |
| Problem it solves | Bugs and slowness that only happen on devices, networks, extensions and data you don't have |
| Parts | Error handlers and boundaries, fingerprinting, breadcrumbs, source maps per release, web-vitals, beacons, sampling, trace context |
| How it works | Capture events, enrich with context and release, send them reliably when the page hides, group and alert on the server |
| Assumptions | Releases are tagged; source maps match the deployed build |
| When they change | Without release tags you can't tell if a new error came with a deploy; without maps, stack traces are noise |
| Where it fails | Privacy (collecting more than needed), cost (unsampled telemetry), and errors from extensions or bots that aren't yours |
| Related ideas | Performance metrics (ch27); deployments and releases (ch31); observability (Observability and SRE) |
What if?
What if you sent telemetry on the unload event?
Reason it through, then open
On phones it often wouldn't fire at all: switching apps or swiping a tab away usually just hides the page, and the OS
may kill it later without unload. You'd lose exactly the sessions that ended abruptly. visibilitychange (when the page
becomes hidden) with sendBeacon or fetch with keepalive is the reliable moment, and unload handlers also prevent
the back/forward cache from keeping the page.
What if you recorded everything users did?
Reason it through, then open
Debugging would be easier, and you'd be collecting personal data you probably don't need, including what people type, which carries legal duties and real risk if leaked. Good telemetry is designed for questions you need to answer: errors with context, timings, and the steps leading to a failure, with sensitive fields scrubbed by default.
Where the boundary is
| Aspect | Monitoring | Observability |
|---|---|---|
| Answers | Known questions: is the error rate up? | New questions you didn't plan for: why are these users failing? |
| Built from | Dashboards and alerts on chosen metrics | Rich, high-cardinality events and traces you can slice |
| Confused because | Tools offer both under one name |
How sure are we?
| Claim | How it's known | Where from |
|---|---|---|
unload is unreliable on mobile |
Measured | Browser vendors' documentation and data; visibilitychange is the recommended signal |
| Source maps made client error tracking practical | Historical | Their adoption in tools from the early 2010s |
| W3C Trace Context became a Recommendation in 2020 | Historical | W3C |
Still open
How much client telemetry is acceptable under privacy law and user expectation varies by country and keeps tightening. Session replay tools are especially debated. This library itself collects none.
What would change your mind? If users reliably reported the problems they hit, client telemetry would be less necessary. Most users who hit an error just leave.
Recall
What makes minified stack traces readable?
Source maps uploaded per release, matched by release tag.
When should a page send its final telemetry?
On visibilitychange to hidden, with sendBeacon or fetch keepalive; unload often doesn't fire on mobile.
What's the difference between monitoring and observability?
Monitoring answers known questions; observability lets you ask new ones of rich data.
Why scrub and sample client telemetry?
To avoid collecting personal data you don't need, and to control cost.
Reflect
Be honest with yourself; this stays in your browser. Anything you can't tick yet is what to revisit.