Skip to content

Commit

Permalink
EX-2549 Reworked the solution
Browse files Browse the repository at this point in the history
  • Loading branch information
egsgordeev committed Dec 8, 2020
1 parent 60e8ccd commit 10a0aa1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const spec = {
let eids;
let tpid = []
let criteoId;
let imp;

utils._each(bidReqs, function (bid) {
if (!eids && bid.userId) {
Expand All @@ -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: {
Expand All @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 10a0aa1

Please sign in to comment.