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

Yieldmo Adapter: Send GPP data in bid request. #9460

Merged
merged 3 commits into from
Apr 19, 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
20 changes: 15 additions & 5 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,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 @@ -81,7 +82,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