Skip to content

Commit 0ca7e7d

Browse files
egsgordeevstsepelin
authored andcommitted
Sovrn: Pass the imp.ext.deals field (prebid#6098)
* EX-2549 Pass segments parameter as imp.ext.dealids array * EX-2549 Address Jon's feedback * EX-2549 Reworked the solution * EX-2549 Blackbird compatibility * EX-2549 Address Jon's comments * EX-2549 Addressed upstream PR comments
1 parent d8ab59c commit 0ca7e7d

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

modules/sovrnBidAdapter.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const spec = {
5353
bidSizes = ((utils.isArray(bidSizes) && utils.isArray(bidSizes[0])) ? bidSizes : [bidSizes])
5454
bidSizes = bidSizes.filter(size => utils.isArray(size))
5555
const processedSizes = bidSizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)}))
56-
sovrnImps.push({
56+
const imp = {
5757
adunitcode: bid.adUnitCode,
5858
id: bid.bidId,
5959
banner: {
@@ -63,7 +63,17 @@ export const spec = {
6363
},
6464
tagid: String(utils.getBidIdParameter('tagid', bid.params)),
6565
bidfloor: utils.getBidIdParameter('bidfloor', bid.params)
66-
});
66+
}
67+
68+
const segmentsString = utils.getBidIdParameter('segments', bid.params)
69+
70+
if (segmentsString) {
71+
imp.ext = {
72+
deals: segmentsString.split(',').map(deal => deal.trim())
73+
}
74+
}
75+
76+
sovrnImps.push(imp);
6777
});
6878

6979
const page = bidderRequest.refererInfo.referer

test/spec/modules/sovrnBidAdapter_spec.js

+26
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,32 @@ describe('sovrnBidAdapter', function() {
276276
expect(data.user.ext.tpid[0].uid).to.equal('A_CRITEO_ID')
277277
expect(data.user.ext.prebid_criteoid).to.equal('A_CRITEO_ID')
278278
});
279+
280+
it('should ignore empty segments', function() {
281+
const payload = JSON.parse(request.data)
282+
expect(payload.imp[0].ext).to.be.undefined
283+
})
284+
285+
it('should pass the segments param value as trimmed deal ids array', function() {
286+
const segmentsRequests = [{
287+
'bidder': 'sovrn',
288+
'params': {
289+
'segments': ' test1,test2 '
290+
},
291+
'adUnitCode': 'adunit-code',
292+
'sizes': [
293+
[300, 250],
294+
[300, 600]
295+
],
296+
'bidId': '30b31c1838de1e',
297+
'bidderRequestId': '22edbae2733bf6',
298+
'auctionId': '1d1a030790a475'
299+
}];
300+
const request = spec.buildRequests(segmentsRequests, bidderRequest)
301+
const payload = JSON.parse(request.data)
302+
expect(payload.imp[0].ext.deals[0]).to.equal('test1')
303+
expect(payload.imp[0].ext.deals[1]).to.equal('test2')
304+
})
279305
});
280306

281307
describe('interpretResponse', function () {

0 commit comments

Comments
 (0)