NOTE: This is a work in progress. This document isn't ready for production deployment.
This is the javascript source code for notifying Airbrake when your javascript has an exception.
When an uncaught exception occurs, Airbrake Javascript notifier will POST the relevant data to the Airbrake server specified in your environment.
For help with using Airbrake and this notifier visit our support site.
Include the Javascript notifier in your header.
<script src="http://jscdn.airbrake.io/notifier.min.js"></script>
For SSL use this URL.
<script src="https://ssljscdn.airbrake.io/notifier.min.js"></script>
After this, setup the notifier. You need an Airbrake API key, sign up for a plan on Airbrake
<script type="text/javascript">
Airbrake.setKey('<your-api-key>');
Airbrake.setHost('api.airbrake.io');
Airbrake.setEnvironment('dev');
Airbrake.setGuessFunctionName(true);
Airbrake.setErrorDefaults({
url: document.URL,
component: "hello",
action: "world",
});
</script>
That's it! The header of your HTML document should look like this.
<script src="http://cdn.airbrake.io/notifier.min.js"></script>
<script type="text/javascript">
Airbrake.setKey('<your-api-key>');
Airbrake.setHost('api.airbrake.io');
Airbrake.setEnvironment('dev');
Airbrake.setGuessFunctionName(true);
</script>
The generator creates a file under config/initializers/airbrake.rb
configuring Airbrake with your API key. This file should be checked into your version control system so that it is deployed to your staging and production environments.
We include stacktrace.js into the Airbrake notifier. To use it to guess the function name and get the stacktrace add Airbrake.setGuessFunctionName(true); to the settings.
Airbrake.setGuessFunctionName(true);
-- Work in Progress --
Airbrake.captureException (new Error("hello error world."));
We handle the Error (exception) manually with "Airbrake.captureException (err);", we only get the "message" field of this exception. Field "lineNumber" and "url" will obtained, since not all browsers fill these Error fields. Thus, exception handling so "Airbrake.captureException (err);" and thus "window.onerror = function (message, file, line) {" will be different.
-- Work in Progress --
-- Work in Progress --
Airbrake.trackJQ(true)
Run Ant to compile the source. We don't have a testing framework in place, but we welcome full requests.
- New configuration parameter:
outputFormat
. Supported formats are XML and JSON. - Numerous improvements in logic of XML notification generator:
Util.substituteArr
was implemented; views were separated from logic (REQUEST_VARIABLE_GROUP_XML
,REQUEST_VARIABLE_XML
,BACKTRACE_LINE_XML
). - Stacktrace.js updated to avoid issues in Opera 11+.
- New tests, more comments, unused code removed.
- Public API improvement: getters and setters are generated automatically from inner JSON. e.g.
key
value can be set withAirbrake.setKey(<key value>);
and the current value is available asAirbrake.getKey();
. - New configuration parameter:
requestType
. Set it to 'GET' (Airbrake.setRequestType('GET');
) to send <iframe> notification request; 'POST' is for XMLHttpRequest POST. - Basic Jasmine test are available in
tests/
directory.
Airbrake is maintained and funded by airbrake.io
Thank you to all the contributors.
The names and logos for Airbrake are trademarks of Exceptional Software Inc.
Airbrake is Copyright © 2008-2012 Airbrake. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.