Skip to content
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
24 changes: 20 additions & 4 deletions modules/zeta_global_sspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ export const spec = {
}
};
const rInfo = bidderRequest.refererInfo;
// TODO: do the fallbacks make sense here?
payload.site.page = cropPage(rInfo.page || rInfo.topmostLocation);
payload.site.domain = parseDomain(payload.site.page, {noLeadingWww: true});
if (rInfo) {
payload.site.page = cropPage(rInfo.page || rInfo.topmostLocation);
payload.site.domain = parseDomain(payload.site.page, {noLeadingWww: true});
}

payload.device.ua = navigator.userAgent;
payload.device.language = navigator.language;
Expand Down Expand Up @@ -178,6 +179,15 @@ export const spec = {
deepSetValue(payload, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}

// Attaching GPP Consent Params
if (bidderRequest?.gppConsent?.gppString) {
deepSetValue(payload, 'regs.gpp', bidderRequest.gppConsent.gppString);
deepSetValue(payload, 'regs.gpp_sid', bidderRequest.gppConsent.applicableSections);
Comment thread
abermanov-zeta marked this conversation as resolved.
} else if (bidderRequest?.ortb2?.regs?.gpp) {
deepSetValue(payload, 'regs.gpp', bidderRequest.ortb2.regs.gpp);
deepSetValue(payload, 'regs.gpp_sid', bidderRequest.ortb2.regs.gpp_sid);
}

// schain
if (validBidRequests[0].schain) {
payload.source = {
Expand Down Expand Up @@ -256,7 +266,7 @@ export const spec = {
/**
* Register User Sync.
*/
getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => {
getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent, gppConsent) => {
let syncurl = '';

// Attaching GDPR Consent Params in UserSync url
Expand All @@ -270,6 +280,12 @@ export const spec = {
syncurl += '&us_privacy=' + encodeURIComponent(uspConsent);
}

// GPP Consent
if (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
syncurl += '&gpp=' + encodeURIComponent(gppConsent.gppString);
syncurl += '&gpp_sid=' + encodeURIComponent(gppConsent?.applicableSections?.join(','));
}

// coppa compliance
if (config.getConfig('coppa') === true) {
syncurl += '&coppa=1';
Expand Down
178 changes: 159 additions & 19 deletions test/spec/modules/zeta_global_sspBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {spec} from '../../../modules/zeta_global_sspBidAdapter.js'
import {BANNER, VIDEO} from '../../../src/mediaTypes';
import {deepClone} from '../../../src/utils';
import {expect} from 'chai';

describe('Zeta Ssp Bid Adapter', function () {
const eids = [
Expand Down Expand Up @@ -444,28 +445,97 @@ describe('Zeta Ssp Bid Adapter', function () {
expect(bid3.meta.advertiserDomains).to.equal(receivedBid3.adomain);
});

it('Different cases for user syncs', function () {
describe('getUserSyncs', function() {
const USER_SYNC_URL_IFRAME = 'https://ssp.disqus.com/sync?type=iframe';
const USER_SYNC_URL_IMAGE = 'https://ssp.disqus.com/sync?type=image';

const sync1 = spec.getUserSyncs({iframeEnabled: true})[0];
expect(sync1.type).to.equal('iframe');
expect(sync1.url).to.include(USER_SYNC_URL_IFRAME);

const sync2 = spec.getUserSyncs({iframeEnabled: false})[0];
expect(sync2.type).to.equal('image');
expect(sync2.url).to.include(USER_SYNC_URL_IMAGE);

const sync3 = spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: true})[0];
expect(sync3.type).to.equal('iframe');
expect(sync3.url).to.include(USER_SYNC_URL_IFRAME);
expect(sync3.url).to.include('&gdpr=');

const sync4 = spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: true}, 'test')[0];
expect(sync4.type).to.equal('iframe');
expect(sync4.url).to.include(USER_SYNC_URL_IFRAME);
expect(sync4.url).to.include('&gdpr=');
expect(sync4.url).to.include('&us_privacy=');
it('execute as per config', function() {
expect(spec.getUserSyncs({iframeEnabled: true})).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}`
}]);
expect(spec.getUserSyncs({iframeEnabled: false})).to.deep.equal([{
type: 'image', url: `${USER_SYNC_URL_IMAGE}`
}]);
});

it('GDPR', function() {
expect(spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: true, consentString: 'foo'})).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}&gdpr=1&gdpr_consent=foo`
}]);
expect(spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: false, consentString: 'foo'})).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}&gdpr=0&gdpr_consent=foo`
}]);
expect(spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: true, consentString: undefined})).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}&gdpr=1&gdpr_consent=`
}]);
expect(spec.getUserSyncs({iframeEnabled: false}, {}, {gdprApplies: true, consentString: 'foo'})).to.deep.equal([{
type: 'image', url: `${USER_SYNC_URL_IMAGE}&gdpr=1&gdpr_consent=foo`
}]);
expect(spec.getUserSyncs({iframeEnabled: false}, {}, {gdprApplies: false, consentString: 'foo'})).to.deep.equal([{
type: 'image', url: `${USER_SYNC_URL_IMAGE}&gdpr=0&gdpr_consent=foo`
}]);
expect(spec.getUserSyncs({iframeEnabled: false}, {}, {gdprApplies: true, consentString: undefined})).to.deep.equal([{
type: 'image', url: `${USER_SYNC_URL_IMAGE}&gdpr=1&gdpr_consent=`
}]);
});

it('CCPA', function() {
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}&us_privacy=1NYN`
}]);
expect(spec.getUserSyncs({ iframeEnabled: false }, {}, undefined, '1NYN')).to.deep.equal([{
type: 'image', url: `${USER_SYNC_URL_IMAGE}&us_privacy=1NYN`
}]);
});

describe('GPP', function() {
it('should return userSync url without GPP consent if gppConsent is undefined', () => {
const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, undefined);
expect(result).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}`
}]);
});

it('should return userSync url without GPP consent if gppConsent.gppString is undefined', () => {
const gppConsent = { applicableSections: ['5'] };
const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent);
expect(result).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}`
}]);
});

it('should return userSync url without GPP consent if gppConsent.applicableSections is undefined', () => {
const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN' };
const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent);
expect(result).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}`
}]);
});

it('should return userSync url without GPP consent if gppConsent.applicableSections is an empty array', () => {
const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', applicableSections: [] };
const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent);
expect(result).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}`
}]);
});

it('should concatenate gppString and applicableSections values in the returned userSync iframe url', () => {
const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', applicableSections: [5] };
const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent);
expect(result).to.deep.equal([{
type: 'iframe', url: `${USER_SYNC_URL_IFRAME}&gpp=${encodeURIComponent(gppConsent.gppString)}&gpp_sid=${encodeURIComponent(gppConsent.applicableSections)}`
}]);
});

it('should concatenate gppString and applicableSections values in the returned userSync image url', () => {
const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', applicableSections: [5] };
const result = spec.getUserSyncs({iframeEnabled: false}, undefined, undefined, undefined, gppConsent);
expect(result).to.deep.equal([{
type: 'image', url: `${USER_SYNC_URL_IMAGE}&gpp=${encodeURIComponent(gppConsent.gppString)}&gpp_sid=${encodeURIComponent(gppConsent.applicableSections)}`
}]);
});
});
});

it('Test provide gdpr and ccpa values in payload', function () {
Expand All @@ -477,6 +547,76 @@ describe('Zeta Ssp Bid Adapter', function () {
expect(payload.regs.ext.us_privacy).to.eql('someCCPAString');
});

describe('buildRequests: GPP', function() {
it('Request params check with GPP Consent', function () {
let bidRequest = {
gppConsent: {
'gppString': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
'fullGppData': {
'sectionId': 3,
'gppVersion': 1,
'sectionList': [
5,
7
],
'applicableSections': [
5
],
'gppString': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
'pingData': {
'cmpStatus': 'loaded',
'gppVersion': '1.0',
'cmpDisplayStatus': 'visible',
'supportedAPIs': [
'tcfca',
'usnat',
'usca',
'usva',
'usco',
'usut',
'usct'
],
'cmpId': 31
},
'eventName': 'sectionChange'
},
'applicableSections': [
5
],
'apiVersion': 1
}
};
let request = spec.buildRequests(bannerRequest, bidRequest);
let data = JSON.parse(request.data);
expect(data.regs.gpp).to.equal('DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN');
expect(data.regs.gpp_sid[0]).to.equal(5);
});

it('Request params check without GPP Consent', function () {
let bidRequest = {};
let request = spec.buildRequests(bannerRequest, bidRequest);
let data = JSON.parse(request.data);
expect(data.regs).to.equal(undefined);
});

it('Request params check with GPP Consent read from ortb2', function () {
let bidRequest = {
ortb2: {
regs: {
'gpp': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
'gpp_sid': [
5
]
}
}
};
let request = spec.buildRequests(bannerRequest, bidRequest);
let data = JSON.parse(request.data);
expect(data.regs.gpp).to.equal('DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN');
expect(data.regs.gpp_sid[0]).to.equal(5);
});
});

it('Test do not override user object', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);
Expand Down
Loading