From 00f47686c089146f982ff79fb7284b50da43a42c Mon Sep 17 00:00:00 2001 From: fawke Date: Sun, 4 Oct 2020 17:07:24 +0530 Subject: [PATCH 1/3] basic implementation complete --- modules/appnexusBidAdapter.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index f3ebf9bf4f6..65b6b1df8a0 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -157,6 +157,7 @@ export const spec = { const memberIdBid = find(bidRequests, hasMemberId); const member = memberIdBid ? parseInt(memberIdBid.params.member, 10) : 0; const schain = bidRequests[0].schain; + const omidSupport = find(bidRequests, hasOmidSupport); const payload = { tags: [...tags], @@ -168,6 +169,13 @@ export const spec = { schain: schain }; + if (omidSupport) { + payload['iab_support'] = { + omidpn: 'Appnexus', + omidpv: '$prebid.version$' + } + } + if (member > 0) { payload.member_id = member; } @@ -770,12 +778,20 @@ function bidToTag(bid) { tag.video[param] = bid.params.video[param]; } }); + + if (bid.params.video.frameworks) { + tag['video_frameworks'] = bid.params.video.frameworks; + } } if (bid.renderer) { tag.video = Object.assign({}, tag.video, { custom_renderer_present: true }); } + if (bid.params.frameworks) { + tag['banner_frameworks'] = bid.params.frameworks; + } + let adUnit = find(auctionManager.getAdUnits(), au => bid.transactionId === au.transactionId); if (adUnit && adUnit.mediaTypes && adUnit.mediaTypes.banner) { tag.ad_types.push(BANNER); @@ -844,6 +860,19 @@ function hasAdPod(bid) { ); } +function hasOmidSupport(bid) { + let hasOmid = false; + const bidderParams = bid.params; + const videoParams = bid.params.video; + if (bidderParams.frameworks && utils.isArray(bidderParams.frameworks)) { + hasOmid = includes(bid.params.frameworks, 6); + } + if (!hasOmid && videoParams && videoParams.frameworks && utils.isArray(videoParams.frameworks)) { + hasOmid = includes(bid.params.video.frameworks, 6); + } + return hasOmid; +} + /** * Expand an adpod placement into a set of request objects according to the * total adpod duration and the range of duration seconds. Sets minduration/ From 6a87bee29f6c642b43b7cb1bfea35af8ce7681f5 Mon Sep 17 00:00:00 2001 From: fawke Date: Sun, 4 Oct 2020 18:36:41 +0530 Subject: [PATCH 2/3] add unit tests --- modules/appnexusBidAdapter.js | 4 +- test/spec/modules/appnexusBidAdapter_spec.js | 45 ++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 65b6b1df8a0..ff58d35009b 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -779,7 +779,7 @@ function bidToTag(bid) { } }); - if (bid.params.video.frameworks) { + if (bid.params.video.frameworks && utils.isArray(bid.params.video.frameworks)) { tag['video_frameworks'] = bid.params.video.frameworks; } } @@ -788,7 +788,7 @@ function bidToTag(bid) { tag.video = Object.assign({}, tag.video, { custom_renderer_present: true }); } - if (bid.params.frameworks) { + if (bid.params.frameworks && utils.isArray(bid.params.frameworks)) { tag['banner_frameworks'] = bid.params.frameworks; } diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 7b563c4ec1d..c1be34f871f 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -829,6 +829,51 @@ describe('AppNexusAdapter', function () { user_id: 'sample-criteo-userid', }); }); + + it('should populate iab_support object at the root level if omid support is detected', function () { + // with bid.params.frameworks + let bidRequest_A = Object.assign({}, bidRequests[0], { + params: { + frameworks: [1, 2, 5, 6], + video: { + frameworks: [1, 2, 5, 6] + } + } + }); + let request = spec.buildRequests([bidRequest_A]); + let payload = JSON.parse(request.data); + expect(payload.iab_support).to.be.an('object'); + expect(payload.iab_support).to.deep.equal({ + omidpn: 'Appnexus', + omidpv: '$prebid.version$' + }); + expect(payload.tags[0].banner_frameworks).to.be.an('array'); + expect(payload.tags[0].banner_frameworks).to.deep.equal([1, 2, 5, 6]); + expect(payload.tags[0].video_frameworks).to.be.an('array'); + expect(payload.tags[0].video_frameworks).to.deep.equal([1, 2, 5, 6]); + + // without bid.params.frameworks + const bidRequest_B = Object.assign({}, bidRequests[0]); + request = spec.buildRequests([bidRequest_B]); + payload = JSON.parse(request.data); + expect(payload.iab_support).to.not.exist; + expect(payload.tags[0].banner_frameworks).to.not.exist; + expect(payload.tags[0].video_frameworks).to.not.exist; + + // with video.frameworks but it is not an array + const bidRequest_C = Object.assign({}, bidRequests[0], { + params: { + video: { + frameworks: "'1', '2', '3', '6'" + } + } + }); + request = spec.buildRequests([bidRequest_C]); + payload = JSON.parse(request.data); + expect(payload.iab_support).to.not.exist; + expect(payload.tags[0].banner_frameworks).to.not.exist; + expect(payload.tags[0].video_frameworks).to.not.exist; + }); }) describe('interpretResponse', function () { From 331c27e6e5c993fe2cd55f90044a379c624b6701 Mon Sep 17 00:00:00 2001 From: fawke Date: Wed, 7 Oct 2020 15:18:32 +0530 Subject: [PATCH 3/3] remove redundant field tags[].video.frameworks --- modules/appnexusBidAdapter.js | 3 +++ test/spec/modules/appnexusBidAdapter_spec.js | 1 + 2 files changed, 4 insertions(+) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index ff58d35009b..ff0e3230007 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -774,6 +774,9 @@ function bidToTag(bid) { type = (utils.isArray(type)) ? type[0] : type; tag.video[param] = VIDEO_MAPPING[param][type]; break; + // Deprecating tags[].video.frameworks in favor of tags[].video_frameworks + case 'frameworks': + break; default: tag.video[param] = bid.params.video[param]; } diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index c1be34f871f..4102896ba94 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -851,6 +851,7 @@ describe('AppNexusAdapter', function () { expect(payload.tags[0].banner_frameworks).to.deep.equal([1, 2, 5, 6]); expect(payload.tags[0].video_frameworks).to.be.an('array'); expect(payload.tags[0].video_frameworks).to.deep.equal([1, 2, 5, 6]); + expect(payload.tags[0].video.frameworks).to.not.exist; // without bid.params.frameworks const bidRequest_B = Object.assign({}, bidRequests[0]);