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 #150 from bugsnag/bengourley/session-payload-missi…
Browse files Browse the repository at this point in the history
…ng-props

Add missing session payload properties
  • Loading branch information
bengourley authored Jun 22, 2018
2 parents 43cd92a + 1014005 commit f034f24
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/sessions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ module.exports = (Configuration) => {
const payload = {
notifier: notifier,
device: { hostname: Configuration.hostname },
app: { version: Configuration.appVersion || undefined },
app: {
version: Configuration.appVersion || undefined,
type: Configuration.appType || undefined,
releaseStage: Configuration.releaseStage || undefined
},
sessionCounts: sessions
}

Expand Down
38 changes: 38 additions & 0 deletions test/sessions/delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,42 @@ describe('session delegate', () => {
notifyReleaseStages: [ 'production' ]
}).startSession({})
})

it('should include the correct app and device payload properties', done => {
class TrackerMock extends Emitter {
start () {
this.emit('summary', [
{ startedAt: '2017-12-12T13:54:00.000Z', sessionsStarted: 123 }
])
}
stop () {}
track () {}
}
const createSessionDelegate = proxyquire('../../lib/sessions', {
'./tracker': TrackerMock,
'request': (opts) => {
const body = JSON.parse(opts.body)
body.sessionCounts.length.should.equal(1)
body.sessionCounts[0].sessionsStarted.should.equal(123)
body.device.should.eql({
hostname: 'test-machine.local'
})
body.app.should.eql({
version: '1.2.3',
releaseStage: 'qa',
type: 'server'
})
done()
}
})
createSessionDelegate({
logger: { info: () => {}, warn: () => {} },
endpoints: { sessions: 'blah' },
notifyReleaseStages: null,
releaseStage: 'qa',
appType: 'server',
appVersion: '1.2.3',
hostname: 'test-machine.local'
}).startSession({})
})
})

0 comments on commit f034f24

Please sign in to comment.