Skip to content

Commit

Permalink
appnexusBidAdapter - update segment param logic (prebid#6103)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker authored and stsepelin committed May 28, 2021
1 parent 188cd30 commit 8939e2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,19 @@ export const spec = {
.filter(param => includes(USER_PARAMS, param))
.forEach((param) => {
let uparam = utils.convertCamelToUnderscore(param);
userObj[uparam] = userObjBid.params.user[param]
if (param === 'segments' && utils.isArray(userObjBid.params.user[param])) {
let segs = [];
userObjBid.params.user[param].forEach(val => {
if (utils.isNumber(val)) {
segs.push({'id': val});
} else if (utils.isPlainObject(val)) {
segs.push(val);
}
});
userObj[uparam] = segs;
} else if (param !== 'segments') {
userObj[uparam] = userObjBid.params.user[param];
}
});
}

Expand Down
2 changes: 2 additions & 0 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ describe('AppNexusAdapter', function () {
placementId: '10433394',
user: {
externalUid: '123',
segments: [123, { id: 987, value: 876 }],
foobar: 'invalid'
}
}
Expand All @@ -277,6 +278,7 @@ describe('AppNexusAdapter', function () {
expect(payload.user).to.exist;
expect(payload.user).to.deep.equal({
external_uid: '123',
segments: [{id: 123}, {id: 987, value: 876}]
});
});

Expand Down

0 comments on commit 8939e2f

Please sign in to comment.