Socket
Socket
Sign inDemoInstall

sentry-node

Package Overview
Dependencies
4
Maintainers
6
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.1.0

64

lib-js/sentry.js
// Generated by CoffeeScript 1.6.3
var Sentry, events, nodeurl, os, parseDSN, quest, util, _, _handle_http_429,
var Sentry, events, nodeurl, os, parseDSN, quest, scrub, util, with_timeout, _, _handle_http_429,
__slice = [].slice,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },

@@ -19,2 +20,4 @@ __hasProp = {}.hasOwnProperty,

scrub = require('loofah')["default"]();
parseDSN = function(dsn) {

@@ -41,2 +44,18 @@ var auth, err, key, pathname, project_id, secret, _ref, _ref1;

with_timeout = function(msecs, fn) {
return function() {
var args, cb, _i;
args = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
cb = _.once(cb);
setTimeout((function() {
return cb(new Error('Sentry timed out'));
}), msecs);
return fn.apply(null, __slice.call(args).concat([function() {
var results;
results = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return cb.apply(null, results);
}]));
};
};
module.exports = Sentry = (function(_super) {

@@ -46,2 +65,3 @@ __extends(Sentry, _super);

function Sentry(credentials) {
this.wrapper = __bind(this.wrapper, this);
this._send = __bind(this._send, this);

@@ -151,2 +171,44 @@ this.message = __bind(this.message, this);

Sentry.prototype.wrapper = function(logger, timeout) {
var log_to_sentry,
_this = this;
if (timeout == null) {
timeout = 5000;
}
log_to_sentry = with_timeout(timeout, function(err, extra, cb) {
_this.once('logged', function() {
return cb();
});
_this.once('error', function(sentry_err) {
return cb(sentry_err);
});
return _this.error(scrub(err), logger, null, scrub(extra));
});
return {
wrap: this.enabled ? function(fn) {
return function() {
var args, cb, _i;
args = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
return fn.apply(null, __slice.call(args).concat([function() {
var err, results;
err = arguments[0], results = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (err != null) {
return log_to_sentry(err, {
args: args
}, function(sentry_err) {
return cb(sentry_err != null ? _.extend(sentry_err, {
original_error: err
}) : err);
});
} else {
return cb.apply(null, [null].concat(__slice.call(results)));
}
}]));
};
} : function(fn) {
return fn;
}
};
};
return Sentry;

@@ -153,0 +215,0 @@

5

package.json
{
"name": "sentry-node",
"version": "2.0.1",
"version": "2.1.0",
"description": "simple Node wrapper around Sentry API",

@@ -32,3 +32,4 @@ "engines": {

"quest": "~0.2.4",
"debug": "~0.7.4"
"debug": "~0.7.4",
"loofah": "0.0.6"
},

@@ -35,0 +36,0 @@ "devDependencies": {

@@ -95,2 +95,23 @@ ## Sentry-node

### Wrapper
Wrapper can be used to wrap an async function, which will attempt to log any error's passed to the async function's callback with sentry.
```javascript
sentry.wrapper(logger, timeout).wrap(some_async_func);
```
### sample
```javascript
wrapped = sentry.wrapper('logger', 1000).wrap(function(callback){
callback(new Error('error to be logged'));
});
wrapped();
```
### arguments
* **logger:** value used as the logger argument to sentry.error
* **timeout:** (optional) the timeout (in ms) to wait for sentry to log error. If timeout is exceeded, wrapped async function's callback will return a sentry timeout error.
## Events

@@ -97,0 +118,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc