sentry-api
Advanced tools
Comparing version 0.1.1 to 0.2.0
var fs = require('fs'); | ||
var util = require('util'); | ||
var winston = require('winston'); | ||
var lodash = require('lodash'); | ||
var debug = require('debug'); | ||
var request = require('request'); | ||
var Promise = require('promise'); | ||
@@ -38,3 +36,3 @@ var DSN = require('./dsn').DSN; | ||
// If no DSN is provided, use the default. | ||
if (lodash.isObject(dsn)) { | ||
if (typeof dsn === 'object') { | ||
config = dsn; | ||
@@ -46,16 +44,10 @@ dsn = 'https://app.getsentry.com'; | ||
this.config = lodash.defaults(config || {}, { | ||
this.config = { | ||
version: 0, | ||
logging: false, | ||
token: null, | ||
}); | ||
...(config || {}), | ||
}; | ||
this.logger = new(winston.Logger)({ | ||
transports: this.config.logging ? [ | ||
new (winston.transports.Console)({ | ||
colorize: true, | ||
label: 'SentryAPI' | ||
}) | ||
] : [] | ||
}); | ||
this.debug = debug('SentryAPI'); | ||
@@ -116,13 +108,10 @@ this.projects = new Projects(this); | ||
this.logger.info(options.method, uri); | ||
this.debug(options.method, uri); | ||
if (lodash.isUndefined(callback)) { | ||
callback = function() {}; | ||
} | ||
return new Promise(function (resolve, reject) { | ||
var requestOptions = lodash.extend({ | ||
var p = new Promise(function (resolve, reject) { | ||
var requestOptions = { | ||
uri: uri, | ||
json: true, | ||
}, options); | ||
...options, | ||
}; | ||
@@ -142,13 +131,11 @@ if (this.config.token) { | ||
if (error) { | ||
this.logger.error(error); | ||
callback(error, null); | ||
this.debug(error); | ||
reject(error); | ||
} | ||
else if (response.statusCode >= 200 && response.statusCode < 300) { | ||
this.logger.info(response.statusCode, response.statusMessage); | ||
callback(null, body); | ||
this.debug(response.statusCode, response.statusMessage); | ||
resolve(body); | ||
} | ||
else { | ||
this.logger.warn(response.statusCode, response.statusMessage); | ||
this.debug(response.statusCode, response.statusMessage); | ||
if (body && body.detail) { | ||
@@ -163,3 +150,2 @@ error = new Error(body.detail); | ||
} | ||
callback(error); | ||
reject(error) | ||
@@ -169,2 +155,8 @@ } | ||
}.bind(this)); | ||
if (callback) { | ||
p.then(body => callback(null, body), err => callback(err)); | ||
} else { | ||
return p; | ||
} | ||
}; | ||
@@ -171,0 +163,0 @@ |
{ | ||
"name": "sentry-api", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "A client for the Sentry API", | ||
@@ -15,10 +15,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"lodash": "^3.10.1", | ||
"promise": "^7.0.4", | ||
"request": "^2.65.0", | ||
"winston": "^2.1.0" | ||
"debug": "^4.1.1", | ||
"request": "^2.65.0" | ||
}, | ||
"devDependencies": { | ||
"nock": "^2.17.0", | ||
"nodeunit": "^0.9.1", | ||
"nock": "^13.0.2", | ||
"nodeunit": "^0.11.3", | ||
"yuidoc-lucid-theme": "^0.1.1", | ||
@@ -25,0 +23,0 @@ "yuidocjs": "^0.9.0" |
# sentry-api | ||
![Build Status](https://travis-ci.org/pifantastic/node-sentry-api.svg?branch=master) | ||
![Dependency Status](https://david-dm.org/pifantastic/node-sentry-api.svg) | ||
A node client for the [Sentry API](https://docs.sentry.io/api/). This is distinct from the reporting API, for which Sentry itself publishes useful libraries. | ||
A node client for the [Sentry](https://getsentry.com/welcome/) web API. | ||
This library is in *maintenance mode*: bug-fixes and version-bumps will be applied, but new functionality will not be developed. | ||
More information about the Sentry web API can be found [here](https://docs.getsentry.com/hosted/api/). | ||
## Installation | ||
@@ -18,3 +15,3 @@ | ||
[http://pifantastic.github.io/node-sentry-api/](http://pifantastic.github.io/node-sentry-api/) | ||
[http://taskcluster.github.io/node-sentry-api/](http://taskcluster.github.io/node-sentry-api/) | ||
@@ -21,0 +18,0 @@ ## Example |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49017
2
15
777
118
1
+ Addeddebug@^4.1.1
+ Addeddebug@4.3.7(transitive)
+ Addedms@2.1.3(transitive)
- Removedlodash@^3.10.1
- Removedpromise@^7.0.4
- Removedwinston@^2.1.0
- Removedasap@2.0.6(transitive)
- Removedasync@2.6.4(transitive)
- Removedcolors@1.0.3(transitive)
- Removedcycle@1.0.3(transitive)
- Removedeyes@0.1.8(transitive)
- Removedlodash@3.10.14.17.21(transitive)
- Removedpromise@7.3.1(transitive)
- Removedstack-trace@0.0.10(transitive)
- Removedwinston@2.4.7(transitive)