Comparing version 1.6.6 to 1.7.0
Changelog | ||
========= | ||
## 1.7.0 (2016-01-27) | ||
### Bug Fixes | ||
* Relax `request` and `promise` dependency requirements to allow patched updates | ||
[Jakub Pawlowicz](https://github.com/jakubpawlowicz) | ||
[#70](https://github.com/bugsnag/bugsnag-node/pull/70) | ||
[#71](https://github.com/bugsnag/bugsnag-node/issues/71) | ||
### Enhancements | ||
* Added support for sending code snippets | ||
[Jacob Marshall](https://github.com/jacobmarshall) | ||
[#65](https://github.com/bugsnag/bugsnag-node/issues/65) | ||
[#67](https://github.com/bugsnag/bugsnag-node/pull/67) | ||
1.6.6 | ||
@@ -5,0 +21,0 @@ ----- |
@@ -102,3 +102,9 @@ var domain = require("domain"), | ||
notification = new Notification(bugsnagErrors, options); | ||
notification.deliver(cb); | ||
if (Configuration.sendCode === true) { | ||
notification.loadCode(function () { | ||
notification.deliver(cb); | ||
}); | ||
} else { | ||
notification.deliver(cb); | ||
} | ||
}; | ||
@@ -105,0 +111,0 @@ |
@@ -24,2 +24,3 @@ var path = require("path"), | ||
logger: new Logger(), | ||
sendCode: false, | ||
@@ -69,2 +70,3 @@ beforeNotifyCallbacks: [], | ||
} | ||
Configuration.sendCode = options.sendCode || Configuration.sendCode; | ||
} | ||
@@ -71,0 +73,0 @@ } |
var stacktrace = require("stack-trace"), | ||
fs = require('fs'), | ||
Promise = require('promise'), | ||
Utils = require("./utils"), | ||
Configuration = require("./configuration"); | ||
function loadCode (error, callback) { | ||
var padding = 4; // Padding of either side of the frame's line (4 actually means 3...) | ||
Promise.all(error.stacktrace.map(function (frame) { | ||
if (frame.inProject) { | ||
return new Promise(function (resolve) { | ||
fs.readFile(frame.path, function (err, data) { | ||
if ( ! err) { | ||
var fileLines = data.toString().split('\n'); | ||
frame.code = {}; | ||
for (var i = frame.lineNumber - padding; i < (frame.lineNumber - 1) + padding; i++) { | ||
if (typeof fileLines[i] === 'string') { | ||
frame.code[i + 1] = fileLines[i]; | ||
} | ||
} | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
})).then(callback); | ||
} | ||
function processCallSites (callSites) { | ||
@@ -10,2 +38,3 @@ return callSites.map(function(callSite) { | ||
file: callSite.getFileName(), | ||
path: callSite.getFileName(), | ||
method: callSite.getMethodName() || callSite.getFunctionName() || "none", | ||
@@ -46,2 +75,6 @@ lineNumber: callSite.getLineNumber(), | ||
Error.prototype.loadCode = function (callback) { | ||
loadCode(this, callback); | ||
}; | ||
Error.buildErrors = function(error, errorClass) { | ||
@@ -48,0 +81,0 @@ var returnArray; |
var Utils = require("./utils"), | ||
var Promise = require('promise'), | ||
Utils = require("./utils"), | ||
Logger = require("./logger"), | ||
@@ -202,3 +203,13 @@ Configuration = require("./configuration"), | ||
Notification.prototype.loadCode = function (callback) { | ||
return Promise.all(this.events.map(function (event) { | ||
return Promise.all(event.exceptions.map(function (error) { | ||
return new Promise(function (resolve) { | ||
error.loadCode(resolve); | ||
}); | ||
})); | ||
})).then(callback); | ||
}; | ||
module.exports = Notification; | ||
{ | ||
"name": "bugsnag", | ||
"description": "Bugsnag notifier for node.js scripts", | ||
"version": "1.6.6", | ||
"version": "1.7.0", | ||
"main": "./lib/bugsnag.js", | ||
"homepage": "http://bugsnag.com", | ||
"dependencies": { | ||
"promise": "7.x", | ||
"stack-trace": "0.0.9", | ||
"request": "2.53.0" | ||
"request": "2.x" | ||
}, | ||
@@ -11,0 +12,0 @@ "devDependencies": { |
@@ -320,2 +320,15 @@ Bugsnag Notifier for Node.js | ||
### sendCode | ||
If you want to send code snippets for each frame of the stacktrace you can enable `sendCode`. This asynchronously loads | ||
any file from the stacktrace, which is within the scope of the project, and sends 3 lines either side of the erroneous line | ||
of code to Bugsnag. | ||
This works almost the same as how Bugsnag JavaScript projects handle sourcemaps - however loading the code is done on the | ||
local machine and sent over the internet with the error data. | ||
```javascript | ||
bugsnag.register("your-api-key-here", { sendCode: true }); | ||
``` | ||
Notify | ||
@@ -322,0 +335,0 @@ ------ |
@@ -176,3 +176,3 @@ // Generated by CoffeeScript 1.8.0 | ||
deliverStub.firstCall.thisValue.events[0].exceptions[0].stacktrace.should.have.length.of.at.least(2); | ||
deliverStub.firstCall.thisValue.events[0].exceptions[0].stacktrace[0].should.have.keys("file", "lineNumber", "columnNumber", "method"); | ||
deliverStub.firstCall.thisValue.events[0].exceptions[0].stacktrace[0].should.have.keys("file", "lineNumber", "columnNumber", "method", "path"); | ||
deliverStub.firstCall.thisValue.events[0].exceptions[0].stacktrace[0].file.should.contain(path.sep + "error.js"); | ||
@@ -179,0 +179,0 @@ deliverStub.firstCall.thisValue.events[0].exceptions[0].stacktrace[0].lineNumber.should.be.an("number"); |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
78653
1406
442
3
5
2
+ Addedpromise@7.x
+ Addedajv@6.12.6(transitive)
+ Addedasap@2.0.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedpsl@1.13.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasync@0.9.2(transitive)
- Removedaws-sign2@0.5.0(transitive)
- Removedbl@0.9.5(transitive)
- Removedboom@2.10.1(transitive)
- Removedcaseless@0.9.0(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcryptiles@2.0.5(transitive)
- Removedctype@0.5.3(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedforever-agent@0.5.2(transitive)
- Removedform-data@0.2.0(transitive)
- Removedhawk@2.3.1(transitive)
- Removedhoek@2.16.3(transitive)
- Removedhttp-signature@0.10.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedmime-db@1.12.0(transitive)
- Removedmime-types@2.0.14(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.6.0(transitive)
- Removedqs@2.3.3(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedrequest@2.53.0(transitive)
- Removedsntp@1.0.9(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedtldts@6.1.64(transitive)
- Removedtldts-core@6.1.64(transitive)
- Removedtough-cookie@5.0.0(transitive)
- Removedtunnel-agent@0.4.3(transitive)
Updatedrequest@2.x