Skip to content

Commit

Permalink
Merge pull request #317 from rollbar/fix-payload-server
Browse files Browse the repository at this point in the history
Properly include payload options in final payload on server
  • Loading branch information
rokob authored Jun 20, 2017
2 parents 54c66e3 + dba4e4b commit 54fda38
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sdks/rollbar.js/src/server/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ function scrubPayload(item, options, callback) {
}

function convertToPayload(item, options, callback) {
callback(null, item.data);
var payloadOptions = options.payload || {};
if (payloadOptions.body) {
delete payloadOptions.body;
}

var data = _.extend(true, {}, item.data, payloadOptions);
callback(null, data);
}

/** Helpers **/
Expand Down
33 changes: 33 additions & 0 deletions sdks/rollbar.js/test/server.transforms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,4 +677,37 @@ vows.describe('transforms')
}
}
})
.addBatch({
'convertToPayload': {
'options': {
'with payload data': {
topic: function() {
return {payload: {client: {code_version: 'bork'}, body: 'hello'}};
},
item: {
topic: function(options) {
var item = {
data: {
body: {
message: 'hey'
}
},
other: 'thing'
};
t.convertToPayload(item, options, this.callback);
},
'should not error': function(err, item) {
assert.ifError(err);
},
'should only return data': function(err, item) {
assert.equal(item.body.message, 'hey');
},
'should include payload options': function(err, item) {
assert.equal(item.client.code_version, 'bork');
}
}
}
}
}
})
.export(module, {error: false});

0 comments on commit 54fda38

Please sign in to comment.