diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index 450608a82f4..258478b0886 100644 --- a/modules/zetaSspBidAdapter.js +++ b/modules/zetaSspBidAdapter.js @@ -5,7 +5,8 @@ import {config} from '../src/config.js'; const BIDDER_CODE = 'zeta_global_ssp'; const ENDPOINT_URL = 'https://ssp.disqus.com/bid'; -const USER_SYNC_URL = 'https://ssp.disqus.com/match'; +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 DEFAULT_CUR = 'USD'; const TTL = 200; const NET_REV = true; @@ -58,7 +59,7 @@ export const spec = { app: params.app ? params.app : {}, ext: { tags: params.tags ? params.tags : {}, - sid: params.sid ? params.sid : {} + sid: params.sid ? params.sid : undefined } }; @@ -123,23 +124,38 @@ export const spec = { }, /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @param gdprConsent The GDPR consent parameters - * @param uspConsent The USP consent parameters - * @return {UserSync[]} The user syncs which should be dropped. + * Register User Sync. */ - getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { - const syncs = []; + getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { + let syncurl = ''; + + // Attaching GDPR Consent Params in UserSync url + if (gdprConsent) { + syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); + syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); + } + + // CCPA + if (uspConsent) { + syncurl += '&us_privacy=' + encodeURIComponent(uspConsent); + } + + // coppa compliance + if (config.getConfig('coppa') === true) { + syncurl += '&coppa=1'; + } + if (syncOptions.iframeEnabled) { - syncs.push({ + return [{ type: 'iframe', - url: USER_SYNC_URL - }); + url: USER_SYNC_URL_IFRAME + syncurl + }]; + } else { + return [{ + type: 'image', + url: USER_SYNC_URL_IMAGE + syncurl + }]; } - return syncs; } } diff --git a/test/spec/modules/zetaSspBidAdapter_spec.js b/test/spec/modules/zetaSspBidAdapter_spec.js index bdfc64c3234..2766632f707 100644 --- a/test/spec/modules/zetaSspBidAdapter_spec.js +++ b/test/spec/modules/zetaSspBidAdapter_spec.js @@ -1,6 +1,6 @@ -import { spec } from '../../../modules/zetaSspBidAdapter.js' +import {spec} from '../../../modules/zetaSspBidAdapter.js' -describe('Zeta Ssp Bid Adapter', function() { +describe('Zeta Ssp Bid Adapter', function () { const bannerRequest = [{ bidId: 12345, auctionId: 67890, @@ -26,7 +26,7 @@ describe('Zeta Ssp Bid Adapter', function() { } }]; - it('Test the bid validation function', function() { + it('Test the bid validation function', function () { const validBid = spec.isBidRequestValid(bannerRequest[0]); const invalidBid = spec.isBidRequestValid(null); @@ -82,4 +82,28 @@ describe('Zeta Ssp Bid Adapter', function() { expect(bid.requestId).to.equal(receivedBid.impid); expect(bid.meta.advertiserDomains).to.equal(receivedBid.adomain); }); + + it('Different cases for user syncs', 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='); + }); });