Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
angular-error-shipper
Advanced tools
A module for shipping errors, stack traces and other information from within your Angular app to a remote service.
Surfacing the details of when and why your app is breaking is important, this is a tool in assisting in that process. Having these logs indexed in something like LogStash make diagnosing problems significantly easier.
This module instruments Angular's default $exceptionHandler
to invoke a configurable set of clientside shippers.
--
Install the module and expose make it accessible to your app (by adding it to the your index.html
, for example).
bower install angular-error-shipper
or
npm install angular-error-shipper
Declare the module as a dependency in your app:
angular.module('myApp', [
'ngCookies',
'ipCookie',
'ngResource',
'ngSanitize',
'ngRoute',
'ngTouch',
'ngErrorShipper' // <-- the dep
])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'main.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
}]);
Just doing the above will not have any effect (the Angular exception handling will work as normal) you will need to configure at least one shipper. There is a default shipper than easily be configured, like so:
angular.module('myApp', []).service('myService', function (errorShipper) {
errorShipper.configure({
url: 'path/where/it/should/post' // URL is the only required property
});
});
The above is all you need to use the barebones shipper and have a information about clientside exceptions POST
'd to the specified endpoint. The default shipper will not be created unless your explicitly invoke the .configure
method.
url
required - An absolute or relative path to the location where the shipper will POST
exceptions.onSuccess
- A callback to execute when a success POST
of a exception takes place.onError
- A callback to execute when there is an error on POST
'ing to the specified url
.data
- An object that will be merged together with the exception data and be sent to the specified url
, useful for sending app or user specific information. Note: you can also overwrite the properties set internally by the errorLogger.method
- Should you want to use anything other than POST
for sending the exceptions.Note: this options object is the one that is passed to Angular's internal $http
, so you can pass it anything you can use there, like headers
or cache
etc. See more here:
https://docs.angularjs.org/api/ng/service/$http
If the above default shipper isn't flexible enough for you, you can add an arbitrary number of your own custom shippers to be invoked.
angular.module('myApp', []).service('myService', function (errorShipper) {
errorShipper.use(function (payload) {
// do something with payload
});
errorShipper.use(function (payload) {
// do something else with payload
});
});
The function(s) you pass to the use
method will be invoked in the order it was added.
Each shipper will receive the same single argument, an Object
containing all the information the error instrumentation produces. See Data format
below for more details.
You will nots there's no callback passed from the error instrumenter, as these shippers are designed to be fire-and-forget.
Also, if configure
is not called and use
is then ONLY the custom shippers will be used.
The default shipper needs to be explicitly opt'ed into. It can be used with an arbitrary number of customer shippers however. When used with custom shippers the default shipper will always be executed first, even if configure
is invoked AFTER use
.
The data format is the following:
{
exception : exception.toString(), // Generated by Angular
stack : exception.stack.toString(), // Generated by Angular
location : angular.toJson($window.location),
cause : cause || null, // Generated by Angular
performance : angular.toJson(window.performance) // If available
}
--
Run the tests using grunt:
grunt test
Always welcome, please unit test all your code.
--
#####0.1.0 - Initial release
FAQs
An error interceptor and shipper for AngularJS
The npm package angular-error-shipper receives a total of 2 weekly downloads. As such, angular-error-shipper popularity was classified as not popular.
We found that angular-error-shipper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.