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

PubmaticBidAdapter: Read and pass gpid from ortb2imp.ext in API call #10577

Merged
merged 7 commits into from
Oct 13, 2023
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/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,9 @@ function _addImpressionFPD(imp, bid) {
deepSetValue(imp, `ext.data.${prop}`, ortb2[prop]);
}
});

const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid');
gpid && deepSetValue(imp, `ext.gpid`, gpid);
}

function _addFloorFromFloorModule(impObj, bid) {
Expand Down
33 changes: 33 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('PubMatic adapter', function () {
ortb2Imp: {
ext: {
tid: '92489f71-1bf2-49a0-adf9-000cea934729',
gpid: '/1111/homepage-leftnav'
}
},
schain: schainConfig
Expand Down Expand Up @@ -1172,6 +1173,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid
expect(data.imp[0].banner.w).to.equal(300); // width
expect(data.imp[0].banner.h).to.equal(250); // height
expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency);
Expand Down Expand Up @@ -1439,6 +1441,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].banner.w).to.equal(728); // width
expect(data.imp[0].banner.h).to.equal(90); // height
expect(data.imp[0].banner.format).to.deep.equal([{w: 160, h: 600}]);
expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency);
Expand Down Expand Up @@ -1663,6 +1666,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid
expect(data.imp[0].banner.w).to.equal(300); // width
expect(data.imp[0].banner.h).to.equal(250); // height
expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
});

Expand Down Expand Up @@ -1711,6 +1715,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].id).to.equal(bidRequests[0].bidId); // Prebid bid id is passed as id
expect(data.imp[0].bidfloor).to.equal(parseFloat(bidRequests[0].params.kadfloor)); // kadfloor
expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid
expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].banner.w).to.equal(300); // width
expect(data.imp[0].banner.h).to.equal(250); // height
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
Expand Down Expand Up @@ -1759,6 +1764,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid
expect(data.imp[0].banner.w).to.equal(300); // width
expect(data.imp[0].banner.h).to.equal(250); // height
expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid

// second request without USP/CCPA
Expand Down Expand Up @@ -1909,6 +1915,33 @@ describe('PubMatic adapter', function () {
});

describe('ortb2Imp', function() {
describe('ortb2Imp.ext.gpid', function() {
beforeEach(function () {
if (bidRequests[0].hasOwnProperty('ortb2Imp')) {
delete bidRequests[0].ortb2Imp;
}
});

it('should send gpid if imp[].ext.gpid is specified', function() {
bidRequests[0].ortb2Imp = {
ext: {
gpid: 'ortb2Imp.ext.gpid'
}
};
const request = spec.buildRequests(bidRequests, {});
let data = JSON.parse(request.data);
expect(data.imp[0].ext).to.have.property('gpid');
expect(data.imp[0].ext.gpid).to.equal('ortb2Imp.ext.gpid');
});

it('should not send if imp[].ext.gpid is not specified', function() {
bidRequests[0].ortb2Imp = { ext: { } };
const request = spec.buildRequests(bidRequests, {});
let data = JSON.parse(request.data);
expect(data.imp[0].ext).to.not.have.property('gpid');
});
});

describe('ortb2Imp.ext.data.pbadslot', function() {
beforeEach(function () {
if (bidRequests[0].hasOwnProperty('ortb2Imp')) {
Expand Down