Giter Site home page Giter Site logo

angular-bugsnag's Introduction

angular-bugsnag

Angular wrapper for Bugsnag.

Build Status Coverage Status

Specifically, angular-bugsnag does the following...

  • Provides bugsnagProvider to configure the bugsnag client and also to inject bugsnag as needed
  • Overrides the default angular $exceptionHandler to send uncaught exceptions to Bugsnag

Installation

Download angular-bugsnag.js or install with bower.

$ bower install angular-bugsnag --save

Load the angular-bugsnag module into your app...

angular.module('app', ['angular-bugsnag'])

bugsnagProvider configuration

The bugsnagProvider has pretty much the same configuration options as bugsnag.

The main difference is that bugsnagProvider uses chainable setter methods instead of properties.

noConflict

Call noConflict() before other settings to remove bugsnag from window.

apiKey

releaseStage

notifyReleaseStages

appVersion

user

projectRoot

endpoint

metaData

autoNotify

beforeNotify

Takes an angular providerFunction or service name that should return a beforeNotify callback used by bugsnag.

Examples

Log notifications with $log:

bugsnagProvider
    .beforeNotify(['$log', function ($log) {
       return function (error, metaData) {
           $log.debug(error.name);
           return true;
       };
    }])

beforeNotify can also take a service name defined elsewhere:

module
    .factory('bugsnagNotificationInterceptor', ['$log', function ($log) {
        return function (error, metaData) {
            $log.debug(error.name);
            return true;
        };
    }])

bugsnagProvider
    .beforeNotify('bugsnagNotificationInterceptor')

Example Usage

angular.module('demo-app', ['angular-bugsnag'])
    .config(['bugsnagProvider', function (bugsnagProvider) {
        bugsnagProvider
            .noConflict()
            .apiKey('[replace me]')
            .releaseStage('development')
            .user({
                id: 123,
                name: 'Jon Doe',
                email: '[email protected]'

            })
            .appVersion('0.1.0')
            .beforeNotify(['$log', function ($log) {
                return function (error, metaData) {
                    $log.debug(error.name);
                    return true;
                };
            }]);
    }])
    .controller('MainCtrl', ['$rootScope', 'bugsnag', function ($scope, bugsnag) {

        this.throwError = function (err) {
            throw err;
        };

        this.notifyError = function (err) {
            bugsnag.notify(err);
        };

        this.brokenUndefined = function () {
            $scope.foo.bar();
        };

    }]);

Contributing

PR's are welcome. Just make sure the tests pass.

$ make
$ gulp test

Additionally, use gulp serve or gulp watch to run the test app. Just insert a Bugsnag API Key here. Remember, don't commit your key!

License

MIT

angular-bugsnag's People

Contributors

wmluke avatar timols avatar shaunkatona avatar

Watchers

John FitzGerald avatar James Cloos avatar

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.