Comparing version 2.0.1 to 2.1.0-0
@@ -60,3 +60,3 @@ Contributing | ||
1. Update version in package.json. | ||
1. Update the version in `lib/notification.js` | ||
1. Update the version in `lib/notifier.js` | ||
1. Update the CHANGELOG.md | ||
@@ -63,0 +63,0 @@ 1. Update the README if required |
@@ -10,3 +10,4 @@ "use strict"; | ||
Notification = require("./notification"), | ||
requestInfo = require("./request_info"); | ||
requestInfo = require("./request_info"), | ||
createSessionDelegate = require('./sessions'); | ||
@@ -156,2 +157,6 @@ // Ensure we get all stack frames from thrown errors. | ||
} | ||
if (Configuration.sessionTrackingEnabled) { | ||
Bugsnag._sessionDelegate = createSessionDelegate(Configuration); | ||
} | ||
}; | ||
@@ -200,2 +205,3 @@ | ||
}; | ||
dom._bugsnagSession = Bugsnag.startSession(); | ||
dom.on('error', next); | ||
@@ -209,2 +215,6 @@ return dom.run(next); | ||
Bugsnag.restifySessionHandler = function(req, res, next) { | ||
process.domain._bugsnagSession = Bugsnag.startSession(); | ||
}; | ||
Bugsnag.restifyHandler = function(req, res, route, err) { | ||
@@ -220,2 +230,6 @@ notify(err, { | ||
Bugsnag.koaSessionHandler = function(ctx) { | ||
ctx._bugsnagSession = Bugsnag.startSession(); | ||
}; | ||
Bugsnag.koaHandler = function(err, ctx) { | ||
@@ -228,4 +242,5 @@ var request; | ||
return notify(err, Object.assign({ | ||
req: request | ||
}, ctx.bugsnag), { | ||
req: request, | ||
session: ctx._bugsnagSession | ||
}, ctx.bugsnag), { | ||
originalSeverity: "error", | ||
@@ -303,2 +318,7 @@ unhandled: true, | ||
Bugsnag.startSession = function () { | ||
if (!Configuration.sessionTrackingEnabled) return null; | ||
return Bugsnag._sessionDelegate.startSession(); | ||
}; | ||
module.exports = Bugsnag; |
@@ -7,4 +7,2 @@ "use strict"; | ||
var PAYLOAD_VERSION = "2"; | ||
var Configuration = { | ||
@@ -29,2 +27,4 @@ filters: ["password"], | ||
sendCode: true, | ||
sessionTrackingEnabled: false, | ||
sessionEndpoint: "https://sessions.bugsnag.com", | ||
@@ -54,3 +54,2 @@ beforeNotifyCallbacks: [], | ||
} | ||
Configuration.payloadVersion = PAYLOAD_VERSION; | ||
Configuration.releaseStage = options.releaseStage || Configuration.releaseStage; | ||
@@ -78,2 +77,4 @@ Configuration.appVersion = options.appVersion || Configuration.appVersion; | ||
Configuration.sendCode = options.sendCode || Configuration.sendCode; | ||
Configuration.sessionTrackingEnabled = options.sessionTrackingEnabled || Configuration.sessionTrackingEnabled; | ||
Configuration.sessionEndpoint = options.sessionEndpoint || Configuration.sessionEndpoint; | ||
} | ||
@@ -80,0 +81,0 @@ } |
@@ -10,8 +10,7 @@ "use strict"; | ||
request = require("request"), | ||
stringify = require("json-stringify-safe"); | ||
stringify = require("json-stringify-safe"), | ||
notifier = require("./notifier"), | ||
Session = require("./sessions/session"); | ||
var NOTIFIER_NAME = "Bugsnag Node Notifier", | ||
NOTIFIER_VERSION = "2.0.1", | ||
NOTIFIER_URL = "https://github.com/bugsnag/bugsnag-node", | ||
SUPPORTED_SEVERITIES = ["error", "warning", "info"]; | ||
var SUPPORTED_SEVERITIES = ["error", "warning", "info"]; | ||
@@ -55,13 +54,11 @@ function Notification(bugsnagErrors, options, handledState) { | ||
if (Configuration.appVersion) { | ||
event.appVersion = Configuration.appVersion; | ||
if (!event.app) event.app = {}; | ||
event.app.version = Configuration.appVersion; | ||
} | ||
if (Configuration.releaseStage) { | ||
event.releaseStage = Configuration.releaseStage; | ||
if (!event.app) event.app = {}; | ||
event.app.releaseStage = Configuration.releaseStage; | ||
} | ||
if (Configuration.payloadVersion) { | ||
event.payloadVersion = Configuration.payloadVersion; | ||
} | ||
// severity and handledState | ||
@@ -96,2 +93,7 @@ if (options.severity) event.severity = options.severity; | ||
if (process.domain && process.domain._bugsnagSession) { | ||
process.domain._bugsnagSession.trackError({ _handledState: handledState }); | ||
event.session = process.domain._bugsnagSession.toJSON(); | ||
} | ||
if (Object.keys(domainOptions).length > 0) { | ||
@@ -105,10 +107,6 @@ Utils.mergeObjects(event.metaData, domainOptions); | ||
this.notifier = { | ||
name: NOTIFIER_NAME, | ||
version: NOTIFIER_VERSION, | ||
url: NOTIFIER_URL | ||
}; | ||
this.notifier = notifier; | ||
this.events = [event]; | ||
} | ||
}; | ||
@@ -185,3 +183,6 @@ Notification.prototype.deliver = function(cb, originalError) { | ||
headers["Content-Type"] = "application/json"; | ||
headers["Content-Length"] = Buffer.byteLength(payload, "utf8") | ||
headers["Content-Length"] = Buffer.byteLength(payload, "utf8"); | ||
headers["Bugsnag-Api-Key"] = this.apiKey; | ||
headers["Bugsnag-Sent-At"] = new Date().toISOString(); | ||
headers["Bugsnag-Payload-Version"] = "4.0"; | ||
@@ -217,5 +218,12 @@ var options = { | ||
Notification.prototype.serializePayload = function() { | ||
return stringify(this, null, null, function() { | ||
var apiKey = this.apiKey; | ||
var handledState = this.handledState; | ||
delete this.apiKey; | ||
delete this.handledState; | ||
var payload = stringify(this, null, null, function() { | ||
return "[RECURSIVE]"; | ||
}); | ||
this.apiKey = apiKey; | ||
this.handledState = handledState; | ||
return payload; | ||
} | ||
@@ -231,9 +239,16 @@ | ||
} | ||
if (!event.userId) { | ||
if (!event.user || !event.user.id) { | ||
event.user = event.user || {} | ||
if (cleanRequest.headers && cleanRequest.headers['x-forwarded-for']) { | ||
event.userId = cleanRequest.headers['x-forwarded-for']; | ||
event.user.id = cleanRequest.headers['x-forwarded-for']; | ||
} else if (cleanRequest.connection && cleanRequest.connection.remoteAddress) { | ||
event.userId = cleanRequest.connection.remoteAddress; | ||
event.user.id = cleanRequest.connection.remoteAddress; | ||
} | ||
} | ||
// migrate sanctioned request properties to event.request | ||
event.request = {}; | ||
[ "clientIp", "headers", "httpMethod", "url", "referer" ].forEach(function (key) { | ||
event.request[key] = event.metaData.request[key] | ||
delete event.metaData.request[key] | ||
}); | ||
}; | ||
@@ -240,0 +255,0 @@ |
@@ -12,3 +12,3 @@ "use strict"; | ||
path: req.path || req.url, | ||
method: req.method, | ||
httpMethod: req.method, | ||
headers: req.headers, | ||
@@ -15,0 +15,0 @@ httpVersion: req.httpVersion |
{ | ||
"name": "bugsnag", | ||
"description": "Bugsnag notifier for node.js scripts", | ||
"version": "2.0.1", | ||
"main": "./lib/bugsnag.js", | ||
"typings": "./lib/bugsnag.d.ts", | ||
"homepage": "http://bugsnag.com", | ||
"dependencies": { | ||
"promise": "7.x", | ||
"stack-trace": "~0.0.9", | ||
"request": "^2.81.0", | ||
"json-stringify-safe": "~5.0.1" | ||
}, | ||
"devDependencies": { | ||
"chai": "~1.5.0", | ||
"coveralls": "^2.13.1", | ||
"express": "~3.4.2", | ||
"grunt": "^0.4.5", | ||
"grunt-bumpx": "^0.2.1", | ||
"mocha": "^3.5.3", | ||
"nyc": "^3.2.2", | ||
"sinon": "^4.0.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:bugsnag/bugsnag-node.git" | ||
}, | ||
"keywords": [ | ||
"error", | ||
"bugsnag", | ||
"exception" | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "nyc --reporter=lcov --reporter=text mocha && (if [ -n \"$TRAVIS\" ]; then cat ./coverage/lcov.info && cat ./coverage/lcov.info | coveralls -v; fi)", | ||
"test:quick": "mocha" | ||
}, | ||
"engine": { | ||
"node": ">=4" | ||
} | ||
"name": "bugsnag", | ||
"description": "Bugsnag notifier for node.js scripts", | ||
"version": "2.1.0-0", | ||
"main": "./lib/bugsnag.js", | ||
"typings": "./lib/bugsnag.d.ts", | ||
"homepage": "http://bugsnag.com", | ||
"dependencies": { | ||
"cuid": "^1.3.8", | ||
"json-stringify-safe": "~5.0.1", | ||
"promise": "7.x", | ||
"request": "^2.81.0", | ||
"stack-trace": "~0.0.9" | ||
}, | ||
"devDependencies": { | ||
"backo": "^1.1.0", | ||
"chai": "~1.5.0", | ||
"coveralls": "^2.13.1", | ||
"cuid": "^1.3.8", | ||
"express": "~3.4.2", | ||
"grunt": "^0.4.5", | ||
"grunt-bumpx": "^0.2.1", | ||
"mocha": "^3.5.3", | ||
"nyc": "^3.2.2", | ||
"proxyquire": "^1.8.0", | ||
"sinon": "^4.0.1", | ||
"timekeeper": "^2.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:bugsnag/bugsnag-node.git" | ||
}, | ||
"keywords": [ | ||
"error", | ||
"bugsnag", | ||
"exception" | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "nyc --reporter=lcov --reporter=text mocha && (if [ -n \"$TRAVIS\" ]; then cat ./coverage/lcov.info && cat ./coverage/lcov.info | coveralls -v; fi)", | ||
"test:quick": "mocha" | ||
}, | ||
"engine": { | ||
"node": ">=4" | ||
} | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
106269
32
1275
0
5
12
1
+ Addedcuid@^1.3.8
+ Addedbrowser-fingerprint@0.0.1(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedcuid@1.3.8(transitive)
+ Addednode-fingerprint@0.0.2(transitive)