How do I add Sentry Javascript error monitoring

  • Page Owner: Not Set
  • Last Reviewed: 2021-07-15

We use sentry error monitoring as default for all our projects. But how do I add error monitoring for Javascript.


Answer

A few steps to add javascript monitoring.

  1. Ensure you are logged into sentry: https://sentry.io/auth/login/

  2. Go to or create the project.

  3. Go to settings of project and select Instrumentation under SDK Setup and select JS (Javascript).

  4. Leave this tab open (This will help sentry figure out which project to select). And open a new tab and go to the Sentry Documentation > Sentry For Javascript > Instalation Methods > Lazy-Loading Sentry https://docs.sentry.io/platforms/javascript/install/lazy-load-sentry/#using-the-loader

  5. If the highlighted text in the Html example says "examplePublicKey" refresh the page until that goes away and you see a hash.

  6. Select the highlighted text and choose the project you are using.

  7. The code will change and then click the copy code symbol.

  8. Paste this after all other javascript is loaded on the page.

  9. Navigate to Sentry For Javascript > Configration > Basic Options

  10. Refresh again if you don't see a hash and then select your project.

  11. Copy the code and paste this right after your sentry script.

  12. After debug: true, add a line and add release: '1.0.0'. (This is required for sentry to track errors. If this is not in there sentry ignores the error.)