Here are some quick tips to get the most out of Sentry when using it to monitor your frontend.
Log server errors
If you just setup Sentry with a library specific to the framework you are using you get warned of all exceptions that happen in your application. What you might also like to do is to log server errors because it gives you better visibility of problems affecting the frontend. You could get information on these server errors from the backend log manager, but it requires less context switching to just do it all in Sentry if it relates to the frontend.
Here is how you could do it with angular (you can do something similar with other frameworks).
Register an interceptor for HTTP requests:
Manually capture a message on error responses:
Filter sensitive information
Out of the box Sentry filters out sensitive information (e.g. if you send a password to Sentry it will filter it).
When you look at the data in the Sentry dashboard it will be stripped of sensitive information. For example:
Yet raven - the frontend library that sends the logs to Sentry - is still sending this information to Sentry. If you are not comfortable with that you can just filter it also on the client side. It could look something like this:
Add client-side context to your logs
When a user logs in set this information for all requests.
You can also save the webapp version they are using and which environment it is running on.
Filter localhost logs
Usually you won’t want to get emails informing you of exceptions when developing the application or running automated tests. You can configure Sentry to ignore localhost logs on the Sentry dashboard.
Or on the client side config, that would look something like this:
A hacky alternative is to check window.location.hostname and, if it is running locally, initialize raven with an invalid key. This way raven is initialized and available to the rest of the application but the logs do not reach Sentry. You should avoid this option if you can.
Turn on source maps
You’ll need to setup your build system to produce source maps. There is no next step, since Sentry picks up source maps automatically when they are available. As soon as you have source maps Sentry will be able to tell you the exact line in your code where an error occurred.
Sentry provides a way to set alerts based on rules. The example bellow is the simplest, get an email for all events. The rules you set will depend on the kind of application you have and on the number of users.
Extra tip - slack integration
If you are using slack there is an integration for Sentry that improves the visibility of the frontend errors for the entire team.