Skip to content

Commit

Permalink
Yieldmo Adapter: Send GPP data in bid request. (#9460)
Browse files Browse the repository at this point in the history
* Adding gpp and gpp_sid

adding gpp parameters to Banner and Video bids.

* Sending gdpr data if no gpp

* Refactor
  • Loading branch information
desidiver authored Apr 19, 2023
1 parent dcc99b3 commit b8c1c95
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
20 changes: 15 additions & 5 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const spec = {
const videoBidRequests = bidRequests.filter(request => hasVideoMediaType(request));
let serverRequests = [];
const eids = getEids(bidRequests[0]) || [];

if (bannerBidRequests.length > 0) {
let serverRequest = {
pbav: '$prebid.version$',
Expand All @@ -80,7 +81,9 @@ export const spec = {
userConsent: JSON.stringify({
// case of undefined, stringify will remove param
gdprApplies: deepAccess(bidderRequest, 'gdprConsent.gdprApplies') || '',
cmp: deepAccess(bidderRequest, 'gdprConsent.consentString') || ''
cmp: deepAccess(bidderRequest, 'gdprConsent.consentString') || '',
gpp: deepAccess(bidderRequest, 'gppConsent.gppString') || '',
gpp_sid: deepAccess(bidderRequest, 'gppConsent.applicableSections') || ''
}),
us_privacy: deepAccess(bidderRequest, 'uspConsent') || ''
};
Expand Down Expand Up @@ -514,12 +517,19 @@ function openRtbSite(bidRequest, bidderRequest) {
*/
function populateOpenRtbGdpr(openRtbRequest, bidderRequest) {
const gdpr = bidderRequest.gdprConsent;
if (gdpr && 'gdprApplies' in gdpr) {
deepSetValue(openRtbRequest, 'regs.ext.gdpr', gdpr.gdprApplies ? 1 : 0);
deepSetValue(openRtbRequest, 'user.ext.consent', gdpr.consentString);
const gpp = deepAccess(bidderRequest, 'gppConsent.gppString');
const gppsid = deepAccess(bidderRequest, 'gppConsent.applicableSections');
if (gpp) {
deepSetValue(openRtbRequest, 'regs.ext.gpp', gpp);
} else {
deepSetValue(openRtbRequest, 'regs.ext.gdpr', gdpr && gdpr.gdprApplies ? 1 : 0);
deepSetValue(openRtbRequest, 'user.ext.consent', gdpr && gdpr.consentString ? gdpr.consentString : '');
}
if (gppsid) {
deepSetValue(openRtbRequest, 'regs.ext.gpp_sid', gppsid);
}
const uspConsent = deepAccess(bidderRequest, 'uspConsent');
if (uspConsent) {
if (!gpp && uspConsent) {
deepSetValue(openRtbRequest, 'regs.ext.us_privacy', uspConsent);
}
}
Expand Down
20 changes: 19 additions & 1 deletion test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ describe('YieldmoAdapter', function () {
expect(data.hasOwnProperty('h')).to.be.true;
expect(data.hasOwnProperty('w')).to.be.true;
expect(data.hasOwnProperty('pubcid')).to.be.true;
expect(data.userConsent).to.equal('{"gdprApplies":"","cmp":""}');
expect(data.userConsent).to.equal('{"gdprApplies":"","cmp":"","gpp":"","gpp_sid":""}');
expect(data.us_privacy).to.equal('');
});

Expand Down Expand Up @@ -262,6 +262,24 @@ describe('YieldmoAdapter', function () {
JSON.stringify({
gdprApplies: true,
cmp: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
gpp: '',
gpp_sid: '',
})
);
});

it('should add gpp information to request if available', () => {
const gppConsent = {
'gppString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
'applicableSections': [8]
};
const data = buildAndGetData([mockBannerBid()], 0, mockBidderRequest({gppConsent}));
expect(data.userConsent).equal(
JSON.stringify({
gdprApplies: '',
cmp: '',
gpp: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
gpp_sid: [8],
})
);
});
Expand Down

0 comments on commit b8c1c95

Please sign in to comment.