Comparing version 1.6.1 to 1.6.2
Changelog | ||
========= | ||
1.6.2 | ||
----- | ||
- Expose bugsnag.requestData | ||
1.6.1 | ||
@@ -5,0 +9,0 @@ ----- |
@@ -41,2 +41,15 @@ var domain = require("domain"), | ||
// This allows people to directly play with requestData without knowledge of domains | ||
Object.defineProperty(Bugsnag, 'requestData', { | ||
get: function () { | ||
return process.domain && process.domain._bugsnagOptions; | ||
}, | ||
set: function (requestData) { | ||
if (process.domain) { | ||
process.domain._bugsnagOptions = requestData; | ||
} | ||
} | ||
}); | ||
// Register sets api key and will configure bugsnag based on options | ||
@@ -43,0 +56,0 @@ Bugsnag.register = function(apiKey, options) { |
{ | ||
"name": "bugsnag", | ||
"description": "Bugsnag notifier for node.js scripts", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"main": "./lib/bugsnag.js", | ||
@@ -6,0 +6,0 @@ "homepage": "http://bugsnag.com", |
@@ -399,3 +399,12 @@ Bugsnag Notifier for Node.js | ||
Per-request metaData | ||
-------------------- | ||
If you are using our express middleware, or otherwise using domains, you can set per-request metaData. | ||
This metaData will be sent with any crashes occurring during the current request. | ||
```javascript | ||
bugsnag.requestData.user = {id: 5} | ||
``` | ||
Reporting Bugs or Feature Requests | ||
@@ -402,0 +411,0 @@ ---------------------------------- |
// Generated by CoffeeScript 1.8.0 | ||
(function() { | ||
var Bugsnag, Notification, apiKey, deliverStub, domain, should, sinon; | ||
var domain = require("domain"); | ||
should = require("chai").should(); | ||
sinon = require("sinon"); | ||
Bugsnag = require("../"); | ||
Notification = require("../lib/notification"); | ||
apiKey = null; | ||
deliverStub = null; | ||
domain = require("domain"); | ||
before(function() { | ||
apiKey = "71ab53572c7b45316fb894d496f2e11d"; | ||
return Bugsnag.register(apiKey, { | ||
notifyReleaseStages: ["production", "development"] | ||
}); | ||
}); | ||
should = require("chai").should(); | ||
describe("Bugsnag", function() { | ||
sinon = require("sinon"); | ||
beforeEach(function() { | ||
return deliverStub = sinon.stub(Notification.prototype, "deliver"); | ||
}); | ||
Bugsnag = require("../"); | ||
afterEach(function() { | ||
return Notification.prototype.deliver.restore(); | ||
}); | ||
Notification = require("../lib/notification"); | ||
it("should call deliver when notifying a caught error", function() { | ||
var e; | ||
try { | ||
throw new Error("This is the message"); | ||
} catch (_error) { | ||
e = _error; | ||
Bugsnag.notify(e); | ||
} | ||
return deliverStub.calledOnce.should.equal(true); | ||
}); | ||
apiKey = null; | ||
it("should call deliver when notifying an event emitter error", function() { | ||
var eventEmitter = new (require('events').EventEmitter)(); | ||
eventEmitter.on("error", Bugsnag.notify); | ||
eventEmitter.emit("error", "Something went wrong"); | ||
deliverStub.calledOnce.should.equal(true); | ||
}); | ||
deliverStub = null; | ||
it("should call deliver when notifying with a domain, using event emitter", function() { | ||
var mainDomain; | ||
mainDomain = domain.create(); | ||
mainDomain.on("error", Bugsnag.notify); | ||
mainDomain.run(function() { | ||
var eventEmitter = new (require('events').EventEmitter)(); | ||
eventEmitter.emit("error", new Error("Something went wrong")); | ||
}); | ||
deliverStub.calledOnce.should.equal(true); | ||
}); | ||
before(function() { | ||
apiKey = "71ab53572c7b45316fb894d496f2e11d"; | ||
return Bugsnag.register(apiKey, { | ||
notifyReleaseStages: ["production", "development"] | ||
it("should expose requestData when inside a domain", function () { | ||
var mainDomain; | ||
mainDomain = domain.create(); | ||
mainDomain.on("error", Bugsnag.notify); | ||
mainDomain.run(function() { | ||
Bugsnag.requestData = {user: {id: 5}}; | ||
var eventEmitter = new (require('events').EventEmitter)(); | ||
eventEmitter.emit("error", new Error("Something went wrong")); | ||
}); | ||
deliverStub.calledOnce.should.equal(true); | ||
deliverStub.firstCall.thisValue.events[0].metaData.user.id.should.equal(5); | ||
}); | ||
}); | ||
}); | ||
describe("Bugsnag", function() { | ||
beforeEach(function() { | ||
return deliverStub = sinon.stub(Notification.prototype, "deliver"); | ||
}); | ||
afterEach(function() { | ||
return Notification.prototype.deliver.restore(); | ||
}); | ||
it("should call deliver when notifying a caught error", function() { | ||
var e; | ||
try { | ||
throw new Error("This is the message"); | ||
} catch (_error) { | ||
e = _error; | ||
Bugsnag.notify(e); | ||
} | ||
return deliverStub.calledOnce.should.equal(true); | ||
}); | ||
it("should call deliver when notifying an event emitter error", function() { | ||
var eventEmitter; | ||
eventEmitter = new (require('events').EventEmitter)(); | ||
eventEmitter.on("error", Bugsnag.notify); | ||
eventEmitter.emit("error", "Something went wrong"); | ||
return deliverStub.calledOnce.should.equal(true); | ||
}); | ||
return it("should call deliver when notifying with a domain, using event emitter", function() { | ||
var mainDomain; | ||
mainDomain = domain.create(); | ||
mainDomain.on("error", Bugsnag.notify); | ||
mainDomain.run(function() { | ||
var eventEmitter; | ||
eventEmitter = new (require('events').EventEmitter)(); | ||
return eventEmitter.emit("error", new Error("Something went wrong")); | ||
}); | ||
return deliverStub.calledOnce.should.equal(true); | ||
}); | ||
}); | ||
describe("Bugsnag", function() { | ||
describe("Bugsnag", function() { | ||
return describe("Notification.deliver", function() { | ||
it("should call the callback after notifying bugsnag", function(done) { | ||
return Bugsnag.notify("error message", done); | ||
}); | ||
return it("should call callback when releaseStage isnt configured in notifyReleaseStages", function(done) { | ||
var oldNotifyReleaseStagesValue; | ||
oldNotifyReleaseStagesValue = Bugsnag.notifyReleaseStages; | ||
Bugsnag.notifyReleaseStages = ["production"]; | ||
Bugsnag.notify("This is the message", done); | ||
return Bugsnag.notifyReleaseStages = oldNotifyReleaseStagesValue; | ||
}); | ||
describe("Notification.deliver", function() { | ||
it("should call the callback after notifying bugsnag", function(done) { | ||
Bugsnag.notify("error message", done); | ||
}); | ||
it("should call callback when releaseStage isnt configured in notifyReleaseStages", function(done) { | ||
var oldNotifyReleaseStagesValue; | ||
oldNotifyReleaseStagesValue = Bugsnag.notifyReleaseStages; | ||
Bugsnag.notifyReleaseStages = ["production"]; | ||
Bugsnag.notify("This is the message", done); | ||
Bugsnag.notifyReleaseStages = oldNotifyReleaseStagesValue; | ||
}); | ||
}); | ||
}); | ||
}); | ||
}).call(this); |
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
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
74190
1332
426