As of May 2024, Rollbar will not be actively updating this repository and plans to archive it in January of 2025. We encourage our community to fork this repo if you wish to continue its development. While Rollbar will no longer be engaging in active development, we remain committed to reviewing and merging pull requests related to security updates. If an actively maintained fork emerges, please reach out to our support team and we will link to it from our documentation.
Flash (ActionScript 3) library for reporting exceptions, errors, and log messages to Rollbar.
flash_rollbar/src directory in your source path or place the Rollbar.swc file in your project's library path.Rollbar.init(this, accessToken, environment); from your top-level DisplayObject.package {
import com.rollbar.notifier.Rollbar;
public class MyApp extends Sprite {
public static const ROLLBAR_ACCESS_TOKEN:String = "POST_CLIENT_ITEM_ACCESS_TOKEN";
public function MyApp() {
var environment:String = isDebug() ? "development" : "production";
var person:Object = {id: getUserId(), email: getEmail(), name: getName()}; // optional
Rollbar.init(this, ROLLBAR_ACCESS_TOKEN, environment, person);
}
}
}Rollbar.init() installed a global error handler, so you don't need to do anything else.
Be sure to replace POST_CLIENT_ITEM_ACCESS_TOKEN with your project's post_client_item access token, which you can find in the Rollbar.com interface.
If you want to instrument specific parts of your code, call Rollbar.handleError(err):
private function onEnterFrame(event:Event) {
try {
gameLoop(event);
} catch (err:Error) {
Rollbar.handleError(err);
}
}Advanced: to override parts of the payload before it is sent to the Rollbar API, pass them in the second argument to handleError(). For example, to control how your data will be grouped, you can pass a custom fingerprint:
Rollbar.handleError(err, {fingerprint: "a string to uniquely identify this error"});The second argument, extraData, should be an object. Each key in extraData will overwrite the previous contents of the payload. For all options, see the API documentation.
At the topmost level of your display list, instantiate the Rollbar singleton.
Rollbar.init(this, accessToken, environment);Here's the full list of constructor parameters (in order):
Default: "production"
Otherwise, set this to the source path relative to your repository's root. e.g. if your source tree looks like this:
/myApp/src/com/myApp
Set this to "src"
Default: "master"
Default: "https://api.rollbar.com/api/1/item/"