Shipping great products goes hand in hand with a lot of things. One of them is to be aware when things go wrong.
With more and more business logic moving to the browser this becomes a huge issue. Fortunately we can set up error tracking for the frontend without much effort.
Sign up on getsentry.com and create a project. (Disclaimer: this is an affiliate link. Your sign up will get me some additional free events)
Add your domains to “Allowed Domains” in project settings.
Get your public URL for error tracking. You can find it in “Client Configuration” under “All Platforms”. The URL should look something like this
Add these lines to your html files and replace the config URL with the one you got in Step 3.
Good Job. You are all set :)
Test your setup by sending a message from your browsers console.
To capture meaningful stack traces the documentation recommends wrapping your application code with a try-catch block. Thanks to Matt Robenolt for this tip.
When the script captures an error it sends the exception data to the Sentry backend.
The error log will help you to find bugs you might not have been aware of. It’s way easier to track them down using the meta data which gets collected:
- First Seen
- Last Seen
This is really useful already but you can even add custom meta data like which customer was affected: