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

Teads adapter: global placement id support #7588

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions modules/teadsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ function buildRequestObject(bid) {
const reqObj = {};
let placementId = getValue(bid.params, 'placementId');
let pageId = getValue(bid.params, 'pageId');
const impressionData = deepAccess(bid, 'ortb2Imp.ext.data');
const gpid = deepAccess(impressionData, 'pbadslot') || deepAccess(impressionData, 'adserver.adslot');

reqObj.sizes = getSizes(bid);
reqObj.bidId = getBidIdParameter('bidId', bid);
Expand All @@ -199,6 +201,7 @@ function buildRequestObject(bid) {
reqObj.adUnitCode = getBidIdParameter('adUnitCode', bid);
reqObj.auctionId = getBidIdParameter('auctionId', bid);
reqObj.transactionId = getBidIdParameter('transactionId', bid);
if (gpid) { reqObj.gpid = gpid; }
return reqObj;
}

Expand Down
132 changes: 132 additions & 0 deletions test/spec/modules/teadsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,138 @@ describe('teadsBidAdapter', () => {
});
});

describe('Global Placement Id', function () {
let bidRequests = [
{
'bidder': 'teads',
'params': {
'placementId': 10433394,
'pageId': 1234
},
'adUnitCode': 'adunit-code-1',
'sizes': [[300, 250], [300, 600]],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'creativeId': 'er2ee',
'deviceWidth': 1680
},
{
'bidder': 'teads',
'params': {
'placementId': 10433395,
'pageId': 1234
},
'adUnitCode': 'adunit-code-2',
'sizes': [[300, 250], [300, 600]],
'bidId': '30b31c1838de1f',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'creativeId': 'er2ef',
'deviceWidth': 1680
}
];

it('should add gpid if ortb2Imp.ext.data.pbadslot is present and is non empty (and ortb2Imp.ext.data.adserver.adslot is not present)', function () {
const updatedBidRequests = bidRequests.map(function(bidRequest, index) {
return {
...bidRequest,
ortb2Imp: {
ext: {
data: {
pbadslot: '1111/home-left-' + index
}
}
}
};
}
);
const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

expect(payload.data[0].gpid).to.equal('1111/home-left-0');
expect(payload.data[1].gpid).to.equal('1111/home-left-1');
});

it('should add gpid if ortb2Imp.ext.data.pbadslot is present and is non empty (even if ortb2Imp.ext.data.adserver.adslot is present and is non empty too)', function () {
const updatedBidRequests = bidRequests.map(function(bidRequest, index) {
return {
...bidRequest,
ortb2Imp: {
ext: {
data: {
pbadslot: '1111/home-left-' + index,
adserver: {
adslot: '1111/home-left/div-' + index
}
}
}
}
};
}
);
const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

expect(payload.data[0].gpid).to.equal('1111/home-left-0');
expect(payload.data[1].gpid).to.equal('1111/home-left-1');
});

it('should not add gpid if both ortb2Imp.ext.data.pbadslot and ortb2Imp.ext.data.adserver.adslot are present but empty', function () {
const updatedBidRequests = bidRequests.map(bidRequest => ({
...bidRequest,
ortb2Imp: {
ext: {
data: {
pbadslot: '',
adserver: {
adslot: ''
}
}
}
}
}));

const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

return payload.data.forEach(bid => {
expect(bid).not.to.have.property('gpid');
});
});

it('should not add gpid if both ortb2Imp.ext.data.pbadslot and ortb2Imp.ext.data.adserver.adslot are not present', function () {
const request = spec.buildRequests(bidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

return payload.data.forEach(bid => {
expect(bid).not.to.have.property('gpid');
});
});

it('should add gpid if ortb2Imp.ext.data.pbadslot is not present but ortb2Imp.ext.data.adserver.adslot is present and is non empty', function () {
const updatedBidRequests = bidRequests.map(function(bidRequest, index) {
return {
...bidRequest,
ortb2Imp: {
ext: {
data: {
adserver: {
adslot: '1111/home-left-' + index
}
}
}
}
};
});
const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

expect(payload.data[0].gpid).to.equal('1111/home-left-0');
expect(payload.data[1].gpid).to.equal('1111/home-left-1');
});
});

function checkMediaTypesSizes(mediaTypes, expectedSizes) {
const bidRequestWithBannerSizes = Object.assign(bidRequests[0], mediaTypes);
const requestWithBannerSizes = spec.buildRequests([bidRequestWithBannerSizes], bidderResquestDefault);
Expand Down