From 64a171567e3e6327ffce59e5b44eb84bedc71b79 Mon Sep 17 00:00:00 2001 From: Egor Gordeev Date: Mon, 7 Dec 2020 22:46:00 +0400 Subject: [PATCH 1/5] EX-2549 Pass segments parameter as imp.ext.dealids array --- modules/sovrnBidAdapter.js | 8 +++++++ test/spec/modules/sovrnBidAdapter_spec.js | 26 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index 62f5e85779e..bf43cd711aa 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -88,6 +88,14 @@ export const spec = { }; } + let segmentsString = utils.getBidIdParameter('segments', bid.params) + + if (segmentsStr) { + let dealids = segmentsStr.split(','); + utils.deepSetValue(sovrnBidReq, 'imp.ext.dealids', dealids); + } + + if (bidderRequest.gdprConsent) { utils.deepSetValue(sovrnBidReq, 'regs.ext.gdpr', +bidderRequest.gdprConsent.gdprApplies); utils.deepSetValue(sovrnBidReq, 'user.ext.consent', bidderRequest.gdprConsent.consentString) diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index 983ade4dd14..80018ad9647 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -276,6 +276,32 @@ describe('sovrnBidAdapter', function() { expect(data.user.ext.tpid[0].uid).to.equal('A_CRITEO_ID') expect(data.user.ext.prebid_criteoid).to.equal('A_CRITEO_ID') }); + + it('should ignore empty segments', function() { + const payload = JSON.parse(request.data) + expect(payload.imp[0].ext.dealids).to.be.empty + }) + + it('should pass segments param as dealids array', function() { + const segmentsRequests = [{ + 'bidder': 'sovrn', + 'params': { + 'segments': 'test1,test2' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + }]; + const request = spec.buildRequests(segmentsRequests, bidderRequest) + const payload = JSON.parse(request.data) + expect(payload.imp[0].ext.dealids[0]).to.equal('test1') + expect(payload.imp[0].ext.dealids[1]).to.equal('test2') + }) }); describe('interpretResponse', function () { From d8b8d28babe947ee87abe6699cef966b7eeaa058 Mon Sep 17 00:00:00 2001 From: Egor Gordeev Date: Tue, 8 Dec 2020 08:30:56 +0400 Subject: [PATCH 2/5] EX-2549 Address Jon's feedback --- modules/sovrnBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index bf43cd711aa..1d5de65f521 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -88,10 +88,10 @@ export const spec = { }; } - let segmentsString = utils.getBidIdParameter('segments', bid.params) + const segmentsString = utils.getBidIdParameter('segments', bid.params) if (segmentsStr) { - let dealids = segmentsStr.split(','); + const dealids = segmentsStr.split(','); utils.deepSetValue(sovrnBidReq, 'imp.ext.dealids', dealids); } From 21c5ac7ec57abf393a867beca74fed936d21c892 Mon Sep 17 00:00:00 2001 From: Egor Gordeev Date: Tue, 8 Dec 2020 16:09:33 +0400 Subject: [PATCH 3/5] EX-2549 Reworked the solution --- modules/sovrnBidAdapter.js | 23 +++++++++++++---------- test/spec/modules/sovrnBidAdapter_spec.js | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index 1d5de65f521..80d9627ec22 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -30,6 +30,7 @@ export const spec = { let eids; let tpid = [] let criteoId; + let imp; utils._each(bidReqs, function (bid) { if (!eids && bid.userId) { @@ -53,7 +54,7 @@ export const spec = { bidSizes = ((utils.isArray(bidSizes) && utils.isArray(bidSizes[0])) ? bidSizes : [bidSizes]) bidSizes = bidSizes.filter(size => utils.isArray(size)) const processedSizes = bidSizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)})) - sovrnImps.push({ + imp = { adunitcode: bid.adUnitCode, id: bid.bidId, banner: { @@ -63,7 +64,17 @@ export const spec = { }, tagid: String(utils.getBidIdParameter('tagid', bid.params)), bidfloor: utils.getBidIdParameter('bidfloor', bid.params) - }); + } + + sovrnImps.push(imp); + + const segmentsString = utils.getBidIdParameter('segments', bid.params) + + if (segmentsString) { + imp.ext = { + dealids: segmentsString.split(',') + } + } }); const page = bidderRequest.refererInfo.referer @@ -88,14 +99,6 @@ export const spec = { }; } - const segmentsString = utils.getBidIdParameter('segments', bid.params) - - if (segmentsStr) { - const dealids = segmentsStr.split(','); - utils.deepSetValue(sovrnBidReq, 'imp.ext.dealids', dealids); - } - - if (bidderRequest.gdprConsent) { utils.deepSetValue(sovrnBidReq, 'regs.ext.gdpr', +bidderRequest.gdprConsent.gdprApplies); utils.deepSetValue(sovrnBidReq, 'user.ext.consent', bidderRequest.gdprConsent.consentString) diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index 80018ad9647..f3fc11834fa 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -279,7 +279,7 @@ describe('sovrnBidAdapter', function() { it('should ignore empty segments', function() { const payload = JSON.parse(request.data) - expect(payload.imp[0].ext.dealids).to.be.empty + expect(payload.imp[0].ext).to.be.undefined }) it('should pass segments param as dealids array', function() { From 20a3c53928f582e951b01c476bdfa5dccb800dcf Mon Sep 17 00:00:00 2001 From: Egor Gordeev Date: Tue, 8 Dec 2020 18:48:10 +0400 Subject: [PATCH 4/5] EX-2549 Blackbird compatibility --- modules/sovrnBidAdapter.js | 2 +- test/spec/modules/sovrnBidAdapter_spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index 80d9627ec22..ce7874308fb 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -72,7 +72,7 @@ export const spec = { if (segmentsString) { imp.ext = { - dealids: segmentsString.split(',') + deals: segmentsString.split(',') } } }); diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index f3fc11834fa..e14331f9145 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -299,8 +299,8 @@ describe('sovrnBidAdapter', function() { }]; const request = spec.buildRequests(segmentsRequests, bidderRequest) const payload = JSON.parse(request.data) - expect(payload.imp[0].ext.dealids[0]).to.equal('test1') - expect(payload.imp[0].ext.dealids[1]).to.equal('test2') + expect(payload.imp[0].ext.deals[0]).to.equal('test1') + expect(payload.imp[0].ext.deals[1]).to.equal('test2') }) }); From 2b452a021ae880f82c5c9dfa8305cda7bc1aa7b7 Mon Sep 17 00:00:00 2001 From: Egor Gordeev Date: Tue, 8 Dec 2020 20:39:04 +0400 Subject: [PATCH 5/5] EX-2549 Address Jon's comments --- modules/sovrnBidAdapter.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index ce7874308fb..2b70afdb8a7 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -30,7 +30,6 @@ export const spec = { let eids; let tpid = [] let criteoId; - let imp; utils._each(bidReqs, function (bid) { if (!eids && bid.userId) { @@ -54,7 +53,7 @@ export const spec = { bidSizes = ((utils.isArray(bidSizes) && utils.isArray(bidSizes[0])) ? bidSizes : [bidSizes]) bidSizes = bidSizes.filter(size => utils.isArray(size)) const processedSizes = bidSizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)})) - imp = { + const imp = { adunitcode: bid.adUnitCode, id: bid.bidId, banner: { @@ -66,8 +65,6 @@ export const spec = { bidfloor: utils.getBidIdParameter('bidfloor', bid.params) } - sovrnImps.push(imp); - const segmentsString = utils.getBidIdParameter('segments', bid.params) if (segmentsString) { @@ -75,6 +72,8 @@ export const spec = { deals: segmentsString.split(',') } } + + sovrnImps.push(imp); }); const page = bidderRequest.refererInfo.referer