npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-cli-airbrake

v0.2.1

Published

An ember-cli addon that integrates airbrake error reporting

Downloads

20

Readme

ember-cli-airbrake

Build Status

ember-cli-airbrake is an Ember CLI addon for integrating the Airbrake JS error notifier into your app.

Installation

  • install the addon: ember install ember-cli-airbrake
  • update your config/environment.js with an airbrake object that includes projectId and projectKey:
// in "production" environment section, e.g.:
ENV.airbrake = {
  projectId:  '123456',
  projectKey: 'your-project-key'
}

Installing the addon will install the NPM component for the airbrake client. This addon uses the airbrake client version 0.5.9.

Configuration

You most likely will want to only configure airbrake for your production environment. The window.onerror and Ember.onerror handlers will only be set if there is an airbrake configuration for a particular environment. In all cases, an airbrake service will be exposed. If airbrake isn't configured the airbrake service uses the Ember.K "no-op" function for its methods. This facilitates the usage of the airbrake service without having to add environment-checking code in your app.

If you are using Errbit, the open-source Airbrake API compatible error catcher, you must also set the host parameter to your errbit installation.

Example configuration for the production environment:

// config/environment.js
module.exports = function(environment) {
  var ENV = {
    /* ... */

  if (environment === 'production') {
    ENV.airbrake = {
      projectId:  'my_project_id',
      projectKey: 'my_project_key'
      // host: 'http://errors.myapp.com/'
    };
  }

  return ENV;
};

Usage

After installing the addon and configuring it properly, errors will be reported to airbrake. If you want to use the airbrake client to explicitly notify errors, you can use the exposed airbrake service.

airbrake service

The airbrake service exposes the following methods:

  • notify(error) -- if you want to explicitly notify errors. Normally this will not be necessary
  • addFilter(filterFn) -- refer to the airbrake client js documentation
  • addReporter(reporter) -- refer to the airbrake client js documentation
  • setSession(sessionData) -- adds a filter to the client that sets the session data to all future error notifications

example: include user data with error reports

The airbrake js client uses "filters" to optionally limit reported notifications or to modify the body of an individual notification. To include user data with your error notices, add a filter that modifies notice.session.

Example:

// in application route, or somewhere else that has determined a user is logged in
airbrake: Ember.inject.service(),

identifyUser: function(userData) {
  let airbrake = this.get('airbrake');
  airbrake.setSession(userData);
  // future notices will have their `notice.session` property set to the value of `userData`
}

example: explicitly notify of an error

Normally the window.onerror or Ember.onerror handlers will do this for you, but if you want to explicitly notify of an error, use the airbrake service's notify method:

// ... some-component.js
airbrake: Ember.inject.service(),

notifyOfError: function() {
  let airbrake = this.get('airbrake');
  airbrake.notify(new Error('this is the error'));
}

Testing

In any environment where config.airbrake is not set (such as your test environment, typically), the error handlers for airbrake notification will not be set up. The airbrake service will still exist, but all its methods will be no-ops. This way your tests will still run happily even if they use, e.g. airbrake.setSession to set user session information.