Skip to content
Dart plugin for Rollbar.com
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.gitignore
LICENSE
README.md
pubspec.yaml

README.md

rollbar.dart

A Dart package for logging application errors and messages to Rollbar.

Quick Start

Import rollbar.dart.

import 'package:rollbar/rollbar.dart';

Initialize an instance of Rollbar with your access token and environment.

var rollbar = new Rollbar(token, environment);

Log errors to Rollbar with the Rollbar.trace() method.

try {
  throw "Some error";
} catch (error, stackTrace) {
  rollbar.trace(error, stackTrace);
}

Log messages to Rollbar with the Rollbar.message() method.

rollbar.message("User clicked Checkout");

Use Rollbar.traceErrorsInZone() to run a block of a code in a new zone, and log any of the its uncaught errors to Rollbar. The method will catch both synchronous and asynchronous errors. This method is useful for logging all the uncaught errors in your application. See this guide for more information about zones in Dart.

rollbar.traceErrorsInZone(() {
  new Future.error("oh noes");
});

Advanced features

Configuration

The Rollbar constructor allows you to define data to be sent on each request to Rollbar. Use the constructor's config parameter to set this data.

var rollbar = new Rollbar(token, environment, config: {
  "person": {
    "id": 1,
    "username": "jimmyp",
    "email": "jimmyp@mixbook.com"
  }
})

Customizing Payload Data

Methods that send data to Rollbar, Rollbar.message(), Rollbar.trace() and Rollbar.traceErrorsInZone() all allow you to define additional data to send to Rollbar.

rollbar.trace(error, stackTrace, otherData: {
  "custom": {
    "project_id": 5
  }
})

The data will be merged into the default payload. Check the API docs for all the options that Rollbar supports (section "Data Format").

Logger

You also can provide your own logger. The plugin will write debug info to it in the 'finer' level. If no logger is provided, a default one will be used.

var logger = new Logger("mylogger");
var rollbar = new Rollbar(token, environment, logger: logger);

Source Maps

Rollbar supports source maps for your JavaScript stack traces.

By default, source maps are disabled, but you can enable them by setting the appropriate flags in the Rollbar constructor.

var rollbar = new Rollbar(token, environment, config: {
  "client": {
    "javascript": {
      "source_map_enabled": true, // required
      "code_version": "1.0", // required
      "guess_uncaught_frames": true // optional value
    }
  }
});

The source maps will need to be available to Rollbar. Check their documentation for how to do this.

You can’t perform that action at this time.