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

Optidigital Bid Adapter: add gpp support #11381

Merged
merged 1 commit into from
Apr 23, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
add gpp suport
  • Loading branch information
dawidww committed Apr 23, 2024
commit 1d50d04ae65abbb2d1da2dddbbe8ca680ad6d203
24 changes: 20 additions & 4 deletions modules/optidigitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,24 @@ export const spec = {
}
}

if (bidderRequest?.gppConsent?.gppString) {
payload.gpp = {
consent: bidderRequest.gppConsent.gppString,
sid: bidderRequest.gppConsent.applicableSections
}
} else if (bidderRequest?.ortb2?.regs?.gpp) {
payload.gpp = {
consent: bidderRequest.ortb2.regs.gpp,
sid: bidderRequest.ortb2.regs.gpp_sid
}
}

if (window.location.href.indexOf('optidigitalTestMode=true') !== -1) {
payload.testMode = true;
}

if (bidderRequest && bidderRequest.uspConsent) {
payload.uspConsent = bidderRequest.uspConsent;
payload.us_privacy = bidderRequest.uspConsent;
}

if (_getEids(validBidRequests[0])) {
Expand Down Expand Up @@ -153,16 +165,20 @@ export const spec = {
* @param {ServerResponse[]} serverResponses List of server's responses.
* @return {UserSync[]} The user syncs which should be dropped.
*/
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) {
let syncurl = '';
if (!isSynced) {
// Attaching GDPR Consent Params in UserSync url
if (gdprConsent) {
syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0);
syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '');
}
if (uspConsent && uspConsent.consentString) {
syncurl += `&ccpa_consent=${uspConsent.consentString}`;
if (uspConsent) {
syncurl += '&us_privacy=' + encodeURIComponent(uspConsent);
}
if (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
syncurl += '&gpp=' + encodeURIComponent(gppConsent.gppString);
syncurl += '&gpp_sid=' + encodeURIComponent(gppConsent?.applicableSections?.join(','));
}

if (syncOptions.iframeEnabled) {
Expand Down
38 changes: 34 additions & 4 deletions test/spec/modules/optidigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,32 @@ describe('optidigitalAdapterTests', function () {
bidderRequest.uspConsent = '1YYY';
const request = spec.buildRequests(validBidRequests, bidderRequest);
const payload = JSON.parse(request.data);
expect(payload.uspConsent).to.exist;
expect(payload.us_privacy).to.exist;
});

it('should send gppConsent to given endpoint where there is gppConsent', function() {
let consentString = 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==';
bidderRequest.gppConsent = {
'gppString': consentString,
'applicableSections': [7]
};
const request = spec.buildRequests(validBidRequests, bidderRequest);
const payload = JSON.parse(request.data);
expect(payload.gpp).to.exist;
});

it('should send gppConsent to given endpoint when there is gpp in ortb2', function() {
let consentString = 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==';
bidderRequest.gppConsent = undefined;
bidderRequest.ortb2 = {
regs: {
gpp: consentString,
gpp_sid: [7]
}
}
const request = spec.buildRequests(validBidRequests, bidderRequest);
const payload = JSON.parse(request.data);
expect(payload.gpp).to.exist;
});

it('should use appropriate mediaTypes banner sizes', function() {
Expand Down Expand Up @@ -546,9 +571,14 @@ describe('optidigitalAdapterTests', function () {
type: 'iframe', url: `${syncurlIframe}&gdpr=1&gdpr_consent=`
}]);
});
it('should return appropriate URL with GDPR equals to 1, GDPR consent and CCPA consent', function() {
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, {consentString: 'fooUsp'})).to.deep.equal([{
type: 'iframe', url: `${syncurlIframe}&gdpr=1&gdpr_consent=foo&ccpa_consent=fooUsp`
it('should return appropriate URL with GDPR equals to 1, GDPR consent and US Privacy consent', function() {
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, 'fooUsp')).to.deep.equal([{
type: 'iframe', url: `${syncurlIframe}&gdpr=1&gdpr_consent=foo&us_privacy=fooUsp`
}]);
});
it('should return appropriate URL with GDPR equals to 1, GDPR consent, US Privacy consent and GPP consent', function() {
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, 'fooUsp', {gppString: 'fooGpp', applicableSections: [7]})).to.deep.equal([{
type: 'iframe', url: `${syncurlIframe}&gdpr=1&gdpr_consent=foo&us_privacy=fooUsp&gpp=fooGpp&gpp_sid=7`
}]);
});
});
Expand Down