GithubHelp home page GithubHelp logo

ng-rollbar's Introduction

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.

ng-rollbar's People

Contributors

basjanssen avatar didlich avatar dsappet avatar grzegorzblaszczyk avatar gsgalloway avatar jpike88 avatar menacestudio avatar nikgraf avatar salarali avatar tandibar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ng-rollbar's Issues

Update docs to include minification-safe dependency injection

Please update the docs to make the initialisation example minification-safe by naming RollbarProvider as a dependency.

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

Had me scratching my head why my build was breaking after including the module.

Otherwise great module and a happy camper!

bower.json main pointing to minified file

Getting a warning from bower:

bower ng-rollbar#~1.9.1   invalid-meta The "main" field cannot contain minified files

The main field should point to the non-minified file

disable "captureUncaught" exceptions

I have been able to use this repo (v1.9.2) by implementing the config block as described in the readme:

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

Things are working, but I want to disable logging to Rollbar in my dev environment. So I figured I should just set captureUncaught to false, but errors are still being logged to Rollbar. Am I just misunderstanding captureUncaught?

I do realize captureUncaught is a Rollbar config parameter, but I'll take any help you can offer. Thanks!

Update to rollbar.js 2.2.9

A function was added 2.2.4 of rollbar.js that I would like to use. Specifically the telemetryScrubber function. From what I can see of ng-rollbar's history, it is currently targeting 2.2.3 of rollbar.js.

Are there any blockers preventing ng-rollbar from upgrading to rollbar.js 2.2.9?

Abandon repo or add more contributors

This is getting a little silly... you have an outstanding pull request that is more than 3 months old...

If you don't want to continue to work on this repo that's fine, but you have a responsibility to the community here that uses it... all you have to do is either bring it up to speed (it is really out of date with respect to the Rollbar.js version now), or just add some more contributors who can help get this thing back up to scratch.

r.logger is not a function

Hey there,

Is anyone else getting r.logger is not a function when injecting Rollbar into a service and then invoked via Rollbar.error("My error") ?

TypeError: r.logger is not a function
    at Object.error (https://d37gvrvc0wt4s1.cloudfront.net/js/v1.7/rollbar.min.js:1:2168)
    at Object.validPickups (http://localhost:8100/app/app.js:13595:17)
    at Object.Job.post (http://localhost:8100/app/app.js:11543:15)
    at CurrentJobService.post (http://localhost:8100/app/app.js:11782:18)
    at http://localhost:8100/app/app.js:15371:27
    at processQueue (http://localhost:8100/lib/ionic/js/ionic.bundle.js:22016:27)
    at http://localhost:8100/lib/ionic/js/ionic.bundle.js:22032:27
    at Scope.$eval (http://localhost:8100/lib/ionic/js/ionic.bundle.js:23228:28)
    at Scope.$digest (http://localhost:8100/lib/ionic/js/ionic.bundle.js:23044:31)
    at Scope.$apply (http://localhost:8100/lib/ionic/js/ionic.bundle.js:23333:24) undefined

Dynamically set environment in RollbarProvider.init()

In my anuglar 1 app, I have injected RollbarProvider into the config block. Since this has to happen in the config block, I can't see a way to pass in a variable for the environment so that it can be set dynamically.

a.loadFull is not a function

Hello.

I am wondering what could be causing this error:

Error: [$injector:modulerr] Failed to instantiate module my_module_name due to:
    TypeError: a.loadFull is not a function
        at Object.<anonymous> (bower_components/ng-rollbar/ng-rollbar.js:32:444)

It only appears when I'm running unit tests. Otherwise, rollbarProvider seems to init correctly, and error reporting works fine as well.

I've done some digging around, and the only case I found where this error was reported was within the rollbar repo itself. Unsure if they are related.

https://github.com/rollbar/rollbar.js/issues/98

I should add that if I don't use ng-rollbar, and just add the rollBar config as part of a script tag on my index page. then I don't encounter the issue. But I'd prefer to use your wrapper.

Namespace Rollbar instance

We are in a bit of a bind. We have a telephony application that is written with Angular 1.5. The app is designed to be integrated into the client's CRM product. Usually running in an iframe. We implemented Rollbar into our app some time ago and as yet we have not been able to get any data coming back when the app is integrated into Zendesk. (Salesforce and ServiceNow both work fine.)

Looking through the network data, etc when in Zendesk I can see that they are also loading Rollbar and this has been confirmed by the guys at Rollbar as well.

Could it be that our issue is down to a conflict with the version being run in the parent window? If so, is there any way we might be able to namespace or isolate our own Rollbar instance?

Thanks in advance. We would really appreciate any assistance with this.

Plz update

rollbar.js version 1.5.0 is now available, so please update

Thanks!

Support for Angular 2+?

Thanks for creating and maintaining this project!

I was wondering if you were planning on creating a branch or new project to move this functionality to Angular 2+?

The ng-rollbar package isn't up to date with rollbar

Hi everyone !

Since some weekes when I go on my project on the admin panel of Rollbar, I see that the version of the script I use ins't up to date :
image

But I'm using the latest version of this repo, throught a CDN.

Is there any way to contribute easily and update the library here, then the CDN, then no more warning on rollbar admin ?

I would do it if someone can explain me how to do this.

Thank you

Cutted "rollbar.snippet.js" content

The content of the file "rollbar.snippet.js" is wrong at:

lit(",");for(n=0;n<a.length;++n)t=a[n],r[t]&&r[t].prototype&&l(o,r[t].prototype,e)}}function l(r,o,e){if(o.hasOwnProperty&&o.hasOwnProperty("addEventListener")){for(var n=o.addEventListener;n._rollbarOldAdd&&n.belongsToShim;)n=n._rollbarOldAdd;var t=function(o,e,t){n.call(this,o,r.wrap(e),t)};t._rollbarOldAdd=n,t.belongsToShim=e,o.addEventListener=t;for(var a=o.removeEventListener;a._rollbarOldRemove&&a.belongsToShim;)a=a._rollbarOldRemove;var l=function(r,o,e){a.call(this,r,o&&o._rollbar_wrapped||o,e)};l._rollbarOldRemove=a,l.belongsToShim=e,o.removeEventListener=l}}r.exports={captureUncaughtExceptions:e,captureUnhandledRejections:t,wrapGlobals:a}},function(r,o){"use strict";function e(r,o){this.impl=r(o,this),this.options=o,n(e.prototype)}function n(r){for(var o=function(r){return function(){var o=Array.prototype.slice.call(arguments,0);if(this.impl[r])return this.impl[r].apply(this.impl,o)}},e="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureDomContentLoaded,captureLoad".split(","),n=0;n<e.length;n++)r[e[n]]=o(e[n])}e.prototype._swapAndProcessMessages=function(r,o){this.impl=r(this.options);for(var e,n,t;e=o.shift();)n=e.method,t=e.args,this[n]&&"function"==typeof this[n]&&("captureDomContentLoaded"===n||"captureLoad"===n?this[n].apply(this,[t[0],e.ts]):this[n].apply(this,t));return this},r.exports=e},function(r,o){"use strict";r.exports=function(r){return function(o){if(!o&&!window._rollbarInitialized){r=r||{};for(var e,n,t=r.globalAlias||"Rollbar",a=window.rollbar,l=function(r){return new a(r)},i=0;e=window._rollbarShims[i++];)n||(n=e.handler),e.handler._swapAndProcessMessages(l,e.messages);window[t]=n,window._rollbarInitialized=!0}}}}]);

RoR + AngularJS injector module failed to instantiate module

I am trying to add ng-rollbar to my RoR+AngularJS project. The stack is:ruby 2.3.1p112, Rails 4.2.6 and angularJS 1.4.12. Following the instructions I runned the command:

bower install ng-rollbar --save
Here is my bower.json after that:

{
 "name": "dsl-generated dependencies",
 "dependencies": {
 "foundation-sites": "~6.2.3",
 "jquery-ujs": "~1.2.1",
 "angular": "~1.4.12",
 "angular-sanitize": "~1.4.12",
 "angular-cookies": "~1.4.12",
 "angular-route": "~1.4.12",
 "angular-resource": "~1.4.12",
 "angular-local-storage": "~0.2.7",
 "angular-scroll-glue": "~2.0.7",
 "components-font-awesome": "~4.6.3",
 "pusher": "~3.1.0",
 "pusher-angular": "~0.1.9",
 "angular-payments": "git://github.com/laurihy/angular-payments#9643191f23",
 "angular-moment": "~0.10.3",
 "angular-xeditable": "~0.2.0",
 "zInfiniteScroll": "~1.1.4",
 "motion-ui": "~1.2.2",
 "angular-toastr": "~1.7.0",
 "angular-elastic": "~2.5.1",
 "angular-material": "~1.0.9",
 "angular-google-analytics": "~1.1.7",
 "angular-animate": "~1.4.12",
 "angular-aria": "~1.4.12",
 "angular-messages": "~1.4.12",
 "ng-rollbar": "^1.9.2"
},
"resolutions": {
  "angular": "~1.4.12"
}

Then I created a file named app/assets/javascripts/config/ngrollbar.js where the rollbar gets initiallize:

app.config(function(ngRollbarProvider) {
  RollbarProvider.init({
   accessToken: "<MY-APPLICATION-TOKEN>",
   captureUncaught: true,
   payload: {
    environment: 'production'
   }
 });
});

And added ngrollbar to app/assets/javascripts/config/app.js:

var app = angular.module('chat',
  [
   'pusher-angular',`enter code here`
   'luegg.directives',
   'ngRoute',
   'templates',
   'angularPayments',
   'angularMoment',
   'xeditable',
   'zInfiniteScroll',
   'toastr',
   'monospaced.elastic',
   'ngMaterial',
   'angular-google-analytics',
   'tandibar/ng-rollbar',
  ]).run(  ["$rootScope","$http","amMoment","editableOptions","editableThemes","$mdSidenav",'Analytics','ngrollbar', function($rootScope , $http , amMoment , editableOptions , editableThemes , $mdSidenav , Analytics , ngrollbar) { ... }]);

In app/assets/javascripts/controllers/chat.js:

app.controller("ChatController", [$scope","$rootScope","$http",'$pusher','$location','$routeParams','userProfile','toastr','flash','ngrollbar', function($scope , $rootScope , $http , $pusher , $location , $routeParams , userProfile , toastr , flash , ngrollbar ) {...}]);

And in app/assets/javascripts/application.js I have added: //= require ng-rollbar

When I try to run my app I get this message in the browser console:

Error: [$injector:modulerr] Failed to instantiate module chat due to:
[$injector:unpr] Unknown provider: ngRollbarProvider

I am not sure if it is a specific problem of ng-rollbar or I am missing some step in the process of adding a new module to my RoR+AngularJS app but I can't figure out what I am doing wrong.

$window.Rollbar.error is not a function

Hey guys,
I'm trying to integrate Rollbar with IONIC, I've added ng-rollbar but skipped adding the native errors plugin for rollbar (https://github.com/emilyemorehouse/cordova-plugins-rollbar)

I was following this tutorial here: https://rollbar.com/blog/rollbar-integration-for-ionic/

The thing is, from time to time I receive a error report with the following details:

TypeError: c.Rollbar.error is not a function. (In 'c.Rollbar.error(d,{cause:e},function(a,c){var e=b.get("$rootScope");e.$emit("rollbar:exception",{exception:d,err:a,data:c.result})})', 'c.Rollbar.error' is undefined)

I already tried searching in and nothing seems to point me to the proper direction to fix this error, I've looked at the source code and figured out that c.Rollbar.error is actually $window.Rollbar.error, but I could't figure out why it is throwing that (and why on earth it is even report that erro through Rollbar since it says it is not loaded!!)

Glad if anyone can help!

Type error when calling Rollbar.info()

Hi there,

when I use any of the severity api calls to throw an error, I get the following type error in the console:
[Rollbar]: TypeError: this._getLogArgs is not a function

Using Rollbar.Rollbar.info() works however.

Would be great if this could be fixed! Many thanks in advance.

Internal error TypeError: a.apply is not a function

Hello,

I get this error both with both ng-rollbar 2.2.3 and 2.2.4, in the RollbarProvider.init() call, with pre-existing working code. I get this error only using ng-rollbar.min.js , no errors with ng-rollbar.js

Maybe there's an error in the minified version?

Thanks

F.

Rollbar.error not sending through extra parameters

When I use Rollbar.error (possibly also affecting info, warning, etc) and pass through a second parameter it doesn't send through e.g. Rollbar.error('login_error', {user_id: 123}). I would expect that to send through the user_id as an extra parameter. It works if I use the original Rollbar instance like ``Rollbar.Rollbar.error('login_error', {user_id: 123})`.

Change versioning style

Instead of incrementing the version and putting a note in the readme, can we just whack an a, b, c on the end for releasing patches/fixes (e.g. 2.1.3a)? Seems a bit cleaner to me...

Error while doing Rollbar.configure

While trying to do the following:

Rollbar.configure({
  payload: {
    person: {
      id: 456,
      username: "foo",
      email: "[email protected]"
    }
  }
});

I am calling this from the first controller that loads after the user has signed in.
I get this error

4     364202   error    Error: undefined is not a function (evaluating 't.logger(n)')
https://d37gvrvc0wt4s1.cloudfront.net/js/v1.4/rollbar.min.js:1:4812
http://192.168.1.179:8100/js/controllers.js:69:20
e@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:70:161
http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:111:128
S@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:92:200
g@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:85:385
http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:84:445
appendViewElement@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:444:4842
render@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:443:49466
init@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:443:32129
render@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:444:3727
register@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:444:3460
a@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:446:6013
http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:446:6164
Y@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:104:90
S@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:93:53
g@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:85:385
http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:84:445
p@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:446:18257
$digest@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:163:261
$apply@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:166:276
l@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:118:158
F@http://192.168.1.179:8100/lib/ionic/js/ionic.bundle.min.js:122:290

can't use listener rollbar:exception or maybe im doing wrong

hello and thanks a lot for the work but
`var app = angular.module('app', ['tandibar/ng-rollbar']);

  app.service('MyErrorListener', function($rootScope) {
    this.initialize = function() {
        $rootScope.$on('rollbar:exception', function(event, response) {
            // custom logic here...
            console.log("i log on error");
        });
    }
});

app.constant('ENV', 'production');

app.config(['RollbarProvider', 'ENV', function(RollbarProvider, ENV) {
    if(ENV == "production"){
        console.log("rollbar init");
        RollbarProvider.init({
            accessToken: "35f0dff586954e4f8f25dc94fdbabbb1",
            captureUncaught: true,
            payload: {
                environment: ENV
            }
        });
    }else{
        console.log("rollbar non init");
        RollbarProvider.deinit();
    }
}]);

`
when i simulate an error its never go in the service... dont understand why can you explain a bit or maybe its an issue?

Uncaught TypeError: Illegal invocation error when RollbarProvider is configured with verbose: true

When RollbarProvider.init is configured with verbose true and the code invokes Rollbar.error Uncaught TypeError: Illegal invocation occurs.

The problem is experienced in ionic/cordova application with the latest crosswalk:

Cordova CLI: 6.4.0
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Version: 1.3.0
Ionic CLI Version: 1.7.6
Ionic App Lib Version: 0.6.2
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: Mac OS X El Capitan
Node Version: v4.7.0
Xcode version: Xcode 8.3.2 Build version 8E2002

Changing verbose: to false fixes the problem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.