Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EX-2549 Dealids custom param #26

Merged
merged 5 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imp is not used outside of the _each scope so it should be defined there.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


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 = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a const

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not actually matter but I would prefer to see the push after the variable is complete.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to the right place, thank you!


const segmentsString = utils.getBidIdParameter('segments', bid.params)

if (segmentsString) {
imp.ext = {
deals: segmentsString.split(',')
}
}
});

const page = bidderRequest.refererInfo.referer
Expand Down
26 changes: 26 additions & 0 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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).to.be.undefined
})

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.deals[0]).to.equal('test1')
expect(payload.imp[0].ext.deals[1]).to.equal('test2')
})
});

describe('interpretResponse', function () {
Expand Down