How can I capture all crashes in a web page?

Services like Sentry have JS libraries that capture things that go wrong in your web page. How do they work?

There are many kinds of “things that can go wrong”, and they must be captured in different ways:

Note there is also window.onerror, an old and non-standard API which seems to capture the same errors as window.addEventListener("error"). I don’t see a reason to use it.

Below is a small playground demonstrating these different kinds of crashes.

Tagged #programming, #web.
👋 I'm Jim, a full-stack product engineer. Want to build an amazing product and a profitable business? Read more about me or Get in touch!

More by Jim

This page copyright James Fisher 2024. Content is not associated with my employer. Found an error? Edit this page.