Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Merge pull request #139 from bugsnag/app-type
Browse files Browse the repository at this point in the history
feat(config): Support configuration of appType
  • Loading branch information
bengourley authored Mar 15, 2018
2 parents ac3b195 + 40415c7 commit 2ab9589
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions lib/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions test/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 2ab9589

Please sign in to comment.