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

ng-rollbar

v2.4.2

Published

Rollbar integration for angular

Downloads

5,347

Readme

ng-rollbar

Rollbar integration for AngularJS

As rollbar encourages all users to stay up to date, and we can't easily track their versioning with our own, please look at release notes if you need to use an older version, otherwise we always deploy with the latest commit in the rollbar.js master branch.

Installation

You can use bower to install this frontend dependency: bower install ng-rollbar --save

Or you can just clone this repo: git clone https://github.com/tandibar/ng-rollbar.git

Usage

Load

Add the library into your application:

<script type="text/javascript" src="bower_components/ng-rollbar/ng-rollbar.min.js"></script>

Add the module as dependency to your angular app:

angular.module('myApp', ['tandibar/ng-rollbar', ...])

Initialize

Now initialize the rollbar in your application's config:

myApp.config(['RollbarProvider', function(RollbarProvider) {
  RollbarProvider.init({
    accessToken: "<YOUR-APPLICATION-TOKEN>",
    captureUncaught: true,
    payload: {
      environment: '<specify-your-env>'
    }
  });
}]);

What you pass in via this init is exactly what you would do via the _rollbarConfig variable as described in the Rollbar Docs. This call to init will trigger the inclusion of the Rollbar snippet in your application. So if you never trigger the init call, Rollbar will never track anything.

Now every exception will be tracked by Rollbar.

Do not load

If you are developing Apps which sometimes get deployed in an environment without internet access (yes, theses places still exist) than you might want to disable the whole loading process of rollbar:

myApp.config(function(RollbarProvider) {
  RollbarProvider.deinit();
});

Now whenever you call a Rollbar function you will just get a log message and no script will be loaded.

Custom

If you need to manually trigger calls to Rollbar you can inject Rollbar where needed

myApp.controller('MainCtrl', function($scope, Rollbar) {
  $scope.onSomeEvent = function() {
    Rollbar.error('this is an error with special handling');
  };
});

You can enable/disable Rollbar via:

Rollbar.disable();
// ... things that should not be tracked by Rollbar ...
Rollbar.enable();

and you can turn on verbosity:

Rollbar.verbose(); // will log infos to console

Other exposed api calls (see Rollbar Docs for further usage infos)

// Rollbar severities
Rollbar.critical("some critical error");
Rollbar.error("some error");
Rollbar.warning("some warning");
Rollbar.info("some info");
Rollbar.debug("some debug message");

// Rollbar config
Rollbar.configure(<new-config>);

// Rollbar scope
Rollbar.scope();

And if anything is missing you can access the original Rollbar object via

Rollbar.Rollbar // access original Rollbar instance

Eventing & Callbacks

Since Angular 1.x decorators cannot specify order of execution, handling the results of the Rollbar request (such as fetching the UUID to hand-off to Customer Service) relies on the Angular eventing system. Whenever an exception is caught and handled by Rollbar, a rollbar:exception event will be emitted on $rootScope.

This provides easy access to the Rollbar API response:

    angular.service('MyErrorListener', function($rootScope) {
        this.initialize = function() {
            $rootScope.$on('rollbar:exception', function(event, response) {
                // custom logic here...
            });
        }
    });

The event parameter in the listener is the representation of the Angular event. The response object contains the following items:

  • exception - The exception that was caught and logged to Rollbar
  • data - The data sent back from Rollbar
  • err - Error information if the Rollbar request failed

How it works

The library decorates angulars $exceptionHandler with a call to Rollbar.error with the catched exception and the cause.

License

Released under the terms of MIT License:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.