diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f72b1ac5d..b54a358cdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## TBD + +### Changed + +- (node): Added Node version string to report and session payloads (device.runtimeVersions) [#537](https://github.com/bugsnag/bugsnag-js/pull/537) + ## 6.2.0 (2019-04-23) This release adds [`@bugsnag/expo`](http://docs.bugsnag.com/platforms/react-native/expo), a notifier for use on React Native apps that are built using [Expo](https://expo.io/). diff --git a/packages/plugin-node-device/README.md b/packages/plugin-node-device/README.md index 8a48364907..1b03a70890 100644 --- a/packages/plugin-node-device/README.md +++ b/packages/plugin-node-device/README.md @@ -1,6 +1,6 @@ # @bugsnag/plugin-browser-node -This plugin adds the device time and hostname to the `device` section of each error report, and the hostname to session payloads. It is included in the node notifier. +This plugin adds the device time, hostname and Node version to the `device` section of each error report. It is included in the node notifier. ## License MIT diff --git a/packages/plugin-node-device/device.js b/packages/plugin-node-device/device.js index 6028af4cc5..27dd4a3b92 100644 --- a/packages/plugin-node-device/device.js +++ b/packages/plugin-node-device/device.js @@ -5,7 +5,10 @@ const { isoDate } = require('@bugsnag/core/lib/es-utils') */ module.exports = { init: (client) => { - const device = { hostname: client.config.hostname } + const device = { + hostname: client.config.hostname, + runtimeVersions: { node: process.versions.node } + } // merge with anything already set on the client client.device = { ...device, ...client.device } @@ -13,7 +16,6 @@ module.exports = { // add time just as the report is sent client.config.beforeSend.unshift((report) => { report.device = { ...report.device, time: isoDate() } - report.updateMetaData('device', { runtimeVersions: process.versions }) }) } } diff --git a/packages/plugin-node-device/test/device.test.js b/packages/plugin-node-device/test/device.test.js index 8f73799644..f41c7802f5 100644 --- a/packages/plugin-node-device/test/device.test.js +++ b/packages/plugin-node-device/test/device.test.js @@ -15,7 +15,7 @@ const VALID_NOTIFIER = { name: 't', version: '0', url: 'http://' } const ISO_8601 = /^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i describe('plugin: node device', () => { - it('should set device = { hostname } and add a beforeSend callback which adds device time', done => { + it('should set device = { hostname, runtimeVersions } add a beforeSend callback which adds device time', done => { const client = new Client(VALID_NOTIFIER) client.setOptions({ apiKey: 'API_KEY_YEAH' }) client.configure(schema) @@ -23,6 +23,8 @@ describe('plugin: node device', () => { expect(client.config.beforeSend.length).toBe(1) expect(client.device.hostname).toBe('test-machine.local') + expect(client.device.runtimeVersions).toBeDefined() + expect(client.device.runtimeVersions.node).toEqual(process.versions.node) client.delivery(client => ({ sendReport: (payload) => { @@ -33,19 +35,4 @@ describe('plugin: node device', () => { })) client.notify(new Error('noooo')) }) - - it('should attach the process.versions hash', done => { - const client = new Client(VALID_NOTIFIER) - client.setOptions({ apiKey: 'API_KEY_YEAH' }) - client.configure(schema) - client.use(plugin) - - client.delivery(client => ({ - sendReport: (payload) => { - expect(payload.events[0].metaData.device.runtimeVersions).toEqual(process.versions) - done() - } - })) - client.notify(new Error('noooo')) - }) }) diff --git a/packages/plugin-server-session/test/session.test.js b/packages/plugin-server-session/test/session.test.js index 4bfe76a017..aeb316c8a4 100644 --- a/packages/plugin-server-session/test/session.test.js +++ b/packages/plugin-server-session/test/session.test.js @@ -103,7 +103,7 @@ describe('plugin: server sessions', () => { }) // this is normally set by a plugin - c.device = { hostname: 'test-machine.local' } + c.device = { hostname: 'test-machine.local', runtimeVersions: { node: '0.0.1' } } c.delivery(client => ({ sendReport: () => {}, @@ -111,7 +111,8 @@ describe('plugin: server sessions', () => { expect(session.sessionCounts.length).toBe(1) expect(session.sessionCounts[0].sessionsStarted).toBe(123) expect(session.app).toEqual({ version: '1.2.3', releaseStage: 'qa', type: 'server' }) - expect(session.device).toEqual({ hostname: 'test-machine.local' }) + expect(session.device.hostname).toBe('test-machine.local') + expect(session.device.runtimeVersions.node).toBe('0.0.1') done() } }))