This is an AirBrake URLRequest generator that uses either the XML or JSON interface to V3 of the Airbrake API
It is based around the IAirBrake interface so that you are not dependent on one API implementation or the other. They are all apart of the com.cleversoap.airbrake
namespace and should be used in the following fashion:
var notifier:IAirBrake = new AirBrakeXML("your-api-key", "production");
or
var notifier:IAirBrake = new AirBrakeJSON("your-api-key", "production", #project-id);
After that all that's left to do is pass an Error object of any type to createErrorNotice like so:
var req:URLRequest = notifier.createErrorNotice(new Error());
Obviously you can put a caught Error there or any Error object aquired in any other fashion, try to get it as close to the actual issue though as its stack trace will be parsed for reporting and the accuracy of that data can be crucial. Once you have your URLRequest you can treat like it any other - load it with a URLLoader, for example. I made no assumptions about how you wanted to actually send the data once you have the URLRequest object so it can be inserted into any system.
In addition to handling Error objects each call to createErrorNotice can handle two additional (optional) arguments. The first is an object that contains keyed values, these are additional parameters that you feel are relevant to the error, eg. user id or browser type.
var req:URLRequest = notifier.createErrorNotice(new Error(), {"user-id": 12345, "browser": "Mozilla Something"};
The second optional parameter is the URL at which the error occurred. This value can usually be retrieved by doing the following (if you've embedded it in the browser):
ExternalInterface.call("eval", "window.location.href");
You can then use this value like so - note that the optional params here are null but obviously can be any value as I described before:
var req:URLRequest = notifier.createErrorNotice(new Error(), null, "http://example.com/error-maker");
A Makefile has been included that, as long as you have the FlexSDK (compc specifically) accessible from the command line, you can run directly with make
- it will output the swc to the bin directory. This is the same way that I build the swc for downloading.
I've included a compiled SWC for ease of use here that can be easily included into your project.