diff --git a/lib/configuration.js b/lib/configuration.js index b507121..c0f3f08 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -20,6 +20,7 @@ var Configuration = { apiKey: process.env.BUGSNAG_API_KEY, releaseStage: process.env.NODE_ENV || "production", appVersion: null, + appType: null, metaData: {}, logger: new Logger(), sendCode: true, @@ -56,6 +57,7 @@ var Configuration = { } Configuration.releaseStage = options.releaseStage || Configuration.releaseStage; Configuration.appVersion = options.appVersion || Configuration.appVersion; + Configuration.appType = options.appType || Configuration.appType; Configuration.autoNotifyUncaught = options.autoNotify != null ? options.autoNotify : Configuration.autoNotifyUncaught; Configuration.autoNotifyUnhandledRejection = options.autoNotifyUnhandledRejection === false ? false : (options.autoNotify != null ? options.autoNotify : Configuration.autoNotifyUnhandledRejection); Configuration.useSSL = options.useSSL != null ? options.useSSL : Configuration.useSSL; diff --git a/lib/notification.js b/lib/notification.js index 1e4579e..a343e33 100644 --- a/lib/notification.js +++ b/lib/notification.js @@ -54,6 +54,11 @@ function Notification(bugsnagErrors, options, handledState) { event.app.version = Configuration.appVersion; } + if (Configuration.appType) { + if (!event.app) event.app = {}; + event.app.type = Configuration.appType; + } + if (Configuration.releaseStage) { if (!event.app) event.app = {}; event.app.releaseStage = Configuration.releaseStage; diff --git a/scratch/express.js b/scratch/express.js new file mode 100644 index 0000000..a33af31 --- /dev/null +++ b/scratch/express.js @@ -0,0 +1,12 @@ +var bugsnag = require('../').register('ababababababa') +var app = require('express')() + +app.use(bugsnag.requestHandler) +app.get('/', () => { + setTimeout(() => { throw new Error('flop') }, 0) +}) +app.use(bugsnag.errorHandler) +app.use((err, req, res, next) => { +}) + +app.listen(3010) diff --git a/scratch/sig.js b/scratch/sig.js new file mode 100644 index 0000000..d2989fb --- /dev/null +++ b/scratch/sig.js @@ -0,0 +1,7 @@ +var bugsnag = require('../').register('ababababababa', { + notifyReleaseStages: ['1'], + releaseStage: 'prod' +}) + +//process.on('SIGKILL', function () { console.log('SIGKILL') }) +throw new Error('flop') diff --git a/test/notification.js b/test/notification.js index 0b8690c..ff73abf 100644 --- a/test/notification.js +++ b/test/notification.js @@ -217,6 +217,16 @@ describe("Notification", function() { }); }); + describe("appType", function() { + it("should send an appType when configured on Bugsnag", function() { + Bugsnag.configure({ + appType: "worker" + }); + Bugsnag.notify("This is the message"); + deliverStub.firstCall.thisValue.events[0].app.type.should.equal("worker"); + }); + }); + describe("releaseStage", function() { it("shouldnt send a notification when releaseStage isnt configured in notifyReleaseStages", function() { Bugsnag.configure({