Skip to content

Commit

Permalink
Prebid Server Adapter: add native asset id parameter (#8317)
Browse files Browse the repository at this point in the history
* add missing native asset id param for PBS requests

* use id if it exists

* update id counter logic
  • Loading branch information
jsnellbaker authored May 2, 2022
1 parent 506b070 commit 880b089
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,16 @@ Object.assign(ORTB2.prototype, {
const nativeParams = adUnit.nativeParams;
let nativeAssets;
if (nativeParams) {
let idCounter = -1;
try {
nativeAssets = nativeAssetCache[impressionId] = Object.keys(nativeParams).reduce((assets, type) => {
let params = nativeParams[type];

function newAsset(obj) {
idCounter++;
return Object.assign({
required: params.required ? 1 : 0
required: params.required ? 1 : 0,
id: (isNumber(params.id)) ? idCounter = params.id : idCounter
}, obj ? cleanObj(obj) : {});
}

Expand Down
4 changes: 4 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1279,12 +1279,14 @@ describe('S2S Adapter', function () {
'assets': [
{
'required': 1,
'id': 0,
'title': {
'len': 800
}
},
{
'required': 1,
'id': 1,
'img': {
'type': 3,
'w': 989,
Expand All @@ -1293,6 +1295,7 @@ describe('S2S Adapter', function () {
},
{
'required': 1,
'id': 2,
'img': {
'type': 1,
'wmin': 10,
Expand All @@ -1304,6 +1307,7 @@ describe('S2S Adapter', function () {
},
{
'required': 1,
'id': 3,
'data': {
'type': 1
}
Expand Down

0 comments on commit 880b089

Please sign in to comment.