Javascript Notifier

Airbrake has the ability to catch javascript errors that occur in browsers viewing HTML pages from your web application.

Enable from rails

If you are using rails, you can enable the JS notifier with this line in your page layout, within the 'head' section

<%= airbrake_javascript_notifier %>

This will insert something similar to the following javascript into your page:

<script type="text/javascript"> 
//<![CDATA[
var notifierJsScheme = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + notifierJsScheme + "airbrake.io/javascripts/notifier.js' type='text/javascript'%3E%3C/script%3E"));
//]]>
</script> 

<script type="text/javascript">
  Hoptoad.setKey('XXXXXXXXXXXXX');
  Hoptoad.setHost('api.airbrake.io');
  Hoptoad.setEnvironment('production');
    Hoptoad.setErrorDefaults({
      url: "http://example.com/pages/home",
      component: "pages",
      action: "show"
  });
</script>

The XXXXXXXXXXXX value will be your actual API key, and the other values will be replaced with values appropriate to the page.

Manually inserting the JS

If you are using another framework, you can manually assemble this javascript to enable JS error tracking. It's important to insert it right after the opening "head" tag of the HTML (ie, within the head section), so that any errors that occur on the page are caught by the HT JS notifier.