From 5a6eacb39922aa1bc77cf2ca2fba844da9debdfc Mon Sep 17 00:00:00 2001 From: Krzysztof SIEG Date: Mon, 21 Jul 2025 12:16:57 +0200 Subject: [PATCH 1/2] Add cookie sync for STX adapter. Move cookie sync logic to equativUtils library --- libraries/equativUtils/equativUtils.js | 44 ++++++ modules/equativBidAdapter.js | 46 ++---- modules/sharethroughBidAdapter.js | 30 +++- .../equativUtils/equativUtils_spec.js | 143 ++++++++++++++++++ test/spec/modules/equativBidAdapter_spec.js | 118 ++++----------- .../modules/sharethroughBidAdapter_spec.js | 71 +++++++++ 6 files changed, 319 insertions(+), 133 deletions(-) diff --git a/libraries/equativUtils/equativUtils.js b/libraries/equativUtils/equativUtils.js index ff32e743eb3..be09c64804f 100644 --- a/libraries/equativUtils/equativUtils.js +++ b/libraries/equativUtils/equativUtils.js @@ -1,5 +1,6 @@ import { VIDEO } from '../../src/mediaTypes.js'; import { deepAccess, isFn } from '../../src/utils.js'; +import { tryAppendQueryString } from '../urlUtils/urlUtils.js'; const DEFAULT_FLOOR = 0.0; @@ -152,3 +153,46 @@ export function prepareSplitImps(imps, bid, currency, impIdMap, adapter) { return splitImps; } + +export const COOKIE_SYNC_ORIGIN = 'https://apps.smartadserver.com'; +export const COOKIE_SYNC_URL = `${COOKIE_SYNC_ORIGIN}/diff/templates/asset/csync.html`; +export const PID_STORAGE_NAME = 'eqt_pid'; + +/** + * Handles cookie sync logic + * + * @param syncOptions + * @param serverResponses + * @param gdprConsent + * @param networkId + * @param storage + * @returns {{type: string, url: string}[]} + */ +export function handleCookieSync(syncOptions, serverResponses, gdprConsent, networkId, storage) { + if (syncOptions.iframeEnabled) { + window.addEventListener('message', function handler(event) { + if (event.origin === COOKIE_SYNC_ORIGIN && event.data.action === 'getConsent') { + if (event.source && event.source.postMessage) { + event.source.postMessage({ + action: 'consentResponse', + id: event.data.id, + consents: gdprConsent.vendorData.vendor.consents + }, event.origin); + } + + if (event.data.pid) { + storage.setDataInLocalStorage(PID_STORAGE_NAME, event.data.pid); + } + + this.removeEventListener('message', handler); + } + }); + + let url = tryAppendQueryString(COOKIE_SYNC_URL + '?', 'nwid', networkId); + url = tryAppendQueryString(url, 'gdpr', (gdprConsent?.gdprApplies ? '1' : '0')); + + return [{ type: 'iframe', url }]; + } + + return []; +} diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 267283ee47a..eccc0612bd9 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -1,6 +1,5 @@ import { ortbConverter } from '../libraries/ortbConverter/converter.js'; -import { prepareSplitImps } from '../libraries/equativUtils/equativUtils.js'; -import { tryAppendQueryString } from '../libraries/urlUtils/urlUtils.js'; +import { handleCookieSync, PID_STORAGE_NAME, prepareSplitImps } from '../libraries/equativUtils/equativUtils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; @@ -14,16 +13,13 @@ import { deepAccess, deepSetValue, logError, logWarn, mergeDeep } from '../src/u */ const BIDDER_CODE = 'equativ'; -const COOKIE_SYNC_ORIGIN = 'https://apps.smartadserver.com'; -const COOKIE_SYNC_URL = `${COOKIE_SYNC_ORIGIN}/diff/templates/asset/csync.html`; const DEFAULT_TTL = 300; const LOG_PREFIX = 'Equativ:'; const OUTSTREAM_RENDERER_URL = 'https://apps.sascdn.com/diff/video-outstream/equativ-video-outstream.js'; -const PID_STORAGE_NAME = 'eqt_pid'; let feedbackArray = []; let impIdMap = {}; -let nwid = 0; +let networkId = 0; let tokens = {}; /** @@ -96,7 +92,7 @@ export const spec = { const requests = []; bidRequests.forEach(bid => { - const data = converter.toORTB({bidRequests: [bid], bidderRequest}); + const data = converter.toORTB({ bidRequests: [bid], bidderRequest }); requests.push({ data, method: 'POST', @@ -154,36 +150,12 @@ export const spec = { /** * @param syncOptions + * @param serverResponses + * @param gdprConsent * @returns {{type: string, url: string}[]} */ - getUserSyncs: (syncOptions, serverResponses, gdprConsent) => { - if (syncOptions.iframeEnabled) { - window.addEventListener('message', function handler(event) { - if (event.origin === COOKIE_SYNC_ORIGIN && event.data.action === 'getConsent') { - if (event.source && event.source.postMessage) { - event.source.postMessage({ - action: 'consentResponse', - id: event.data.id, - consents: gdprConsent.vendorData.vendor.consents - }, event.origin); - } - - if (event.data.pid) { - storage.setDataInLocalStorage(PID_STORAGE_NAME, event.data.pid); - } - - this.removeEventListener('message', handler); - } - }); - - let url = tryAppendQueryString(COOKIE_SYNC_URL + '?', 'nwid', nwid); - url = tryAppendQueryString(url, 'gdpr', (gdprConsent?.gdprApplies ? '1' : '0')); - - return [{ type: 'iframe', url }]; - } - - return []; - } + getUserSyncs: (syncOptions, serverResponses, gdprConsent) => + handleCookieSync(syncOptions, serverResponses, gdprConsent, networkId, storage) }; export const converter = ortbConverter({ @@ -247,8 +219,8 @@ export const converter = ortbConverter({ let req = buildRequest(splitImps, bidderRequest, context); let env = ['ortb2.site.publisher', 'ortb2.app.publisher', 'ortb2.dooh.publisher'].find(propPath => deepAccess(bid, propPath)) || 'ortb2.site.publisher'; - nwid = deepAccess(bid, env + '.id') || bid.params.networkId; - deepSetValue(req, env.replace('ortb2.', '') + '.id', nwid); + networkId = deepAccess(bid, env + '.id') || bid.params.networkId; + deepSetValue(req, env.replace('ortb2.', '') + '.id', networkId); [ { path: 'mediaTypes.video', props: ['mimes', 'placement'] }, diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index 3f52d76071a..f5a371bc82f 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -1,9 +1,10 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; import { ortbConverter } from '../libraries/ortbConverter/converter.js'; -import { prepareSplitImps } from '../libraries/equativUtils/equativUtils.js'; +import { handleCookieSync, PID_STORAGE_NAME, prepareSplitImps } from '../libraries/equativUtils/equativUtils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { deepAccess, generateUUID, inIframe, isPlainObject, logWarn, mergeDeep } from '../src/utils.js'; +import { getStorageManager } from '../src/storageManager.js'; const VERSION = '4.3.0'; const BIDDER_CODE = 'sharethrough'; @@ -14,8 +15,11 @@ const STR_ENDPOINT = `https://btlr.sharethrough.com/universal/v1?supply_id=${SUP const IDENTIFIER_PREFIX = 'Sharethrough:'; const impIdMap = {}; +let eqtvNetworkId = 0; let isEqtvTest = null; +const storage = getStorageManager({ bidderCode: BIDDER_CODE }); + /** * Gets value of the local variable impIdMap * @returns {*} Value of impIdMap @@ -94,12 +98,21 @@ export const sharethroughAdapterSpec = { test: 0, }; + req.user = nullish(firstPartyData.user, {}); + if (!req.user.ext) req.user.ext = {}; + req.user.ext.eids = bidRequests[0].userIdAsEids || []; + if (bidRequests[0].params.equativNetworkId) { isEqtvTest = true; + eqtvNetworkId = bidRequests[0].params.equativNetworkId; req.site.publisher = { id: bidRequests[0].params.equativNetworkId, ...req.site.publisher }; + const pid = storage.getDataFromLocalStorage(PID_STORAGE_NAME); + if (pid) { + req.user.buyeruid = pid; + } } if (bidderRequest.ortb2?.device?.ext?.cdep) { @@ -111,9 +124,6 @@ export const sharethroughAdapterSpec = { mergeDeep(req.device, bidderRequest.ortb2.device); } - req.user = nullish(firstPartyData.user, {}); - if (!req.user.ext) req.user.ext = {}; - req.user.ext.eids = bidRequests[0].userIdAsEids || []; if (bidderRequest.gdprConsent) { const gdprApplies = bidderRequest.gdprConsent.gdprApplies === true; @@ -327,11 +337,15 @@ export const sharethroughAdapterSpec = { } }, - getUserSyncs: (syncOptions, serverResponses) => { - const shouldCookieSync = - syncOptions.pixelEnabled && deepAccess(serverResponses, '0.body.cookieSyncUrls') !== undefined; + getUserSyncs: (syncOptions, serverResponses, gdprConsent) => { + if (isEqtvTest) { + return handleCookieSync(syncOptions, serverResponses, gdprConsent, eqtvNetworkId, storage) + } else { + const shouldCookieSync = + syncOptions.pixelEnabled && deepAccess(serverResponses, '0.body.cookieSyncUrls') !== undefined; - return shouldCookieSync ? serverResponses[0].body.cookieSyncUrls.map((url) => ({ type: 'image', url: url })) : []; + return shouldCookieSync ? serverResponses[0].body.cookieSyncUrls.map((url) => ({ type: 'image', url: url })) : []; + } }, // Empty implementation for prebid core to be able to find it diff --git a/test/spec/libraries/equativUtils/equativUtils_spec.js b/test/spec/libraries/equativUtils/equativUtils_spec.js index 3056042b2f3..7c333a63436 100644 --- a/test/spec/libraries/equativUtils/equativUtils_spec.js +++ b/test/spec/libraries/equativUtils/equativUtils_spec.js @@ -1,4 +1,5 @@ import * as equativUtils from "../../../../libraries/equativUtils/equativUtils"; +import { storage } from "../../../../modules/equativBidAdapter"; describe('equativUtils', () => { describe('prepareSplitImps', () => { @@ -40,4 +41,146 @@ describe('equativUtils', () => { expect(result.banner.topframe).to.equal(1); }) }) + + describe('handleCookieSync', () => { + let setDataInLocalStorageStub; + let addEventListenerStub; + let messageHandler; + + const SAMPLE_RESPONSE = { + body: { + id: '12h712u7-k22g-8124-ab7a-h268s22dy271', + seatbid: [ + { + bid: [ + { + id: '1bh7jku7-ko2g-8654-ab72-h268shvwy271', + impid: 'r12gwgf231', + price: 0.6565, + adm: '

AD

', + adomain: ['abc.com'], + cid: '1242512', + crid: '535231', + w: 300, + h: 600, + mtype: 1, + cat: ['IAB19', 'IAB19-1'], + cattax: 1, + }, + ], + seat: '4212', + }, + ], + cur: 'USD', + statuscode: 0, + }, + }; + + beforeEach(() => { + setDataInLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage'); + addEventListenerStub = sinon.stub(window, 'addEventListener').callsFake((type, handler) => { + if (type === 'message') { + messageHandler = handler; + } + return addEventListenerStub.wrappedMethod.call(this, type, handler); + }); + }); + afterEach(() => { + setDataInLocalStorageStub.restore(); + addEventListenerStub.restore(); + }); + + it('should return empty array if iframe sync not enabled', () => { + const syncs = equativUtils.handleCookieSync({}, SAMPLE_RESPONSE, {}, 73, storage); + expect(syncs).to.deep.equal([]); + }); + + it('should retrieve and save user pid', (done) => { + equativUtils.handleCookieSync( + { iframeEnabled: true }, + SAMPLE_RESPONSE, + { gdprApplies: true, vendorData: { vendor: { consents: {} } } }, + 73, + storage + ); + + messageHandler.call(window, { + origin: 'https://apps.smartadserver.com', + data: { action: 'getConsent', pid: '7767825890726' }, + source: { postMessage: sinon.stub() } + }); + + expect(setDataInLocalStorageStub.calledOnce).to.be.true; + expect(setDataInLocalStorageStub.calledWith('eqt_pid', '7767825890726')).to.be.true; + done(); + }); + + it('should not save user pid coming from incorrect origin', (done) => { + equativUtils.handleCookieSync( + { iframeEnabled: true }, + SAMPLE_RESPONSE, + { gdprApplies: true, vendorData: { vendor: { consents: {} } } }, + 73, + storage + ); + + messageHandler.call(window, { + origin: 'https://another-origin.com', + data: { action: 'getConsent', pid: '7767825890726' }, + source: { postMessage: sinon.stub() } + }); + + expect(setDataInLocalStorageStub.notCalled).to.be.true; + done(); + }); + + it('should not save empty pid', (done) => { + equativUtils.handleCookieSync( + { iframeEnabled: true }, + SAMPLE_RESPONSE, + { gdprApplies: true, vendorData: { vendor: { consents: {} } } }, + 73, + storage + ); + + messageHandler.call(window, { + origin: 'https://apps.smartadserver.com', + data: { action: 'getConsent', pid: '' }, + source: { postMessage: sinon.stub() } + }); + + expect(setDataInLocalStorageStub.notCalled).to.be.true; + done(); + }); + + it('should return array including iframe cookie sync object (gdprApplies=true)', () => { + const syncs = equativUtils.handleCookieSync( + { iframeEnabled: true }, + SAMPLE_RESPONSE, + { gdprApplies: true }, + 73, + storage + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0]).to.deep.equal({ + type: 'iframe', + url: 'https://apps.smartadserver.com/diff/templates/asset/csync.html?nwid=73&gdpr=1&' + }); + }); + + it('should return array including iframe cookie sync object (gdprApplies=false)', () => { + const syncs = equativUtils.handleCookieSync( + { iframeEnabled: true }, + SAMPLE_RESPONSE, + { gdprApplies: false }, + 73, + storage + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0]).to.deep.equal({ + type: 'iframe', + url: 'https://apps.smartadserver.com/diff/templates/asset/csync.html?nwid=73&gdpr=0&' + }); + }); + }); }) diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index 86a2c7e7960..d7532cd1db5 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -1,6 +1,7 @@ import { converter, getImpIdMap, spec, storage } from 'modules/equativBidAdapter.js'; import { Renderer } from 'src/Renderer.js'; import * as utils from '../../../src/utils.js'; +import * as equativUtils from '../../../libraries/equativUtils/equativUtils.js' describe('Equativ bid adapter tests', () => { let sandBox; @@ -468,14 +469,14 @@ describe('Equativ bid adapter tests', () => { } } }; - const request = spec.buildRequests([ DEFAULT_BANNER_BID_REQUESTS[0] ], bidRequest)[0]; + const request = spec.buildRequests([DEFAULT_BANNER_BID_REQUESTS[0]], bidRequest)[0]; expect(request.data.user.buyeruid).to.deep.eq(bidRequest.ortb2.user.buyeruid); getDataFromLocalStorageStub.restore(); }); - it('should pass prebid version as ext.equativprebidjsversion param', () => { + it('should pass prebid version as ext.equativprebidjsversion param', () => { const request = spec.buildRequests( DEFAULT_BANNER_BID_REQUESTS, DEFAULT_BANNER_BIDDER_REQUEST @@ -589,7 +590,7 @@ describe('Equativ bid adapter tests', () => { delete missingRequiredVideoRequest.mediaTypes.video.mimes; delete missingRequiredVideoRequest.mediaTypes.video.placement; - const bidRequests = [ missingRequiredVideoRequest ]; + const bidRequests = [missingRequiredVideoRequest]; const bidderRequest = { ...DEFAULT_VIDEO_BIDDER_REQUEST, bids: bidRequests }; // ACT @@ -609,7 +610,7 @@ describe('Equativ bid adapter tests', () => { video: {} } }; - const bidRequests = [ emptyVideoRequest ]; + const bidRequests = [emptyVideoRequest]; const bidderRequest = { ...DEFAULT_VIDEO_BIDDER_REQUEST, bids: bidRequests }; // ACT @@ -651,7 +652,7 @@ describe('Equativ bid adapter tests', () => { native: {} } }; - const bidRequests = [ emptyNativeRequest ]; + const bidRequests = [emptyNativeRequest]; const bidderRequest = { ...DEFAULT_NATIVE_BIDDER_REQUEST, bids: bidRequests }; // ACT @@ -671,7 +672,7 @@ describe('Equativ bid adapter tests', () => { // removing just "assets" for this test delete missingRequiredNativeRequest.nativeOrtbRequest.assets; - const bidRequests = [ missingRequiredNativeRequest ]; + const bidRequests = [missingRequiredNativeRequest]; const bidderRequest = { ...DEFAULT_NATIVE_BIDDER_REQUEST, bids: bidRequests }; // this value comes from native.js, part of the ortbConverter library @@ -696,7 +697,7 @@ describe('Equativ bid adapter tests', () => { delete missingRequiredNativeRequest.mediaTypes.native.ortb.plcmttype; delete missingRequiredNativeRequest.mediaTypes.native.ortb.privacy; - const bidRequests = [ missingRequiredNativeRequest ]; + const bidRequests = [missingRequiredNativeRequest]; const bidderRequest = { ...DEFAULT_NATIVE_BIDDER_REQUEST, bids: bidRequests }; // ACT @@ -897,105 +898,46 @@ describe('Equativ bid adapter tests', () => { }); describe('getUserSyncs', () => { - let setDataInLocalStorageStub; - let addEventListenerStub; - let messageHandler; + let handleCookieSyncStub; beforeEach(() => { - setDataInLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage'); - addEventListenerStub = sinon.stub(window, 'addEventListener').callsFake((type, handler) => { - if (type === 'message') { - messageHandler = handler; - } - return addEventListenerStub.wrappedMethod.call(this, type, handler); - }); + handleCookieSyncStub = sinon.stub(equativUtils, 'handleCookieSync'); }); afterEach(() => { - setDataInLocalStorageStub.restore(); - addEventListenerStub.restore(); - }); - - it('should return empty array if iframe sync not enabled', () => { - const syncs = spec.getUserSyncs({}, SAMPLE_RESPONSE); - expect(syncs).to.deep.equal([]); + handleCookieSyncStub.restore(); }); - it('should retrieve and save user pid', (done) => { - spec.getUserSyncs( - { iframeEnabled: true }, - SAMPLE_RESPONSE, - { gdprApplies: true, vendorData: { vendor: { consents: {} } } } - ); - - messageHandler.call(window, { - origin: 'https://apps.smartadserver.com', - data: { action: 'getConsent', pid: '7767825890726' }, - source: { postMessage: sinon.stub() } - }); + it('should call handleCookieSync with correct parameters and return its result', () => { + const expectedResult = [ + { type: 'iframe', url: 'https://sync.example.com' }, + ]; - expect(setDataInLocalStorageStub.calledOnce).to.be.true; - expect(setDataInLocalStorageStub.calledWith('eqt_pid', '7767825890726')).to.be.true; - done(); - }); + handleCookieSyncStub.returns(expectedResult) - it('should not save user pid coming from incorrect origin', (done) => { - spec.getUserSyncs( - { iframeEnabled: true }, + const result = spec.getUserSyncs({ iframeEnabled: true }, SAMPLE_RESPONSE, - { gdprApplies: true, vendorData: { vendor: { consents: {} } } } - ); - - messageHandler.call(window, { - origin: 'https://another-origin.com', - data: { action: 'getConsent', pid: '7767825890726' }, - source: { postMessage: sinon.stub() } - }); - - expect(setDataInLocalStorageStub.notCalled).to.be.true; - done(); - }); + { gdprApplies: true, vendorData: { vendor: { consents: {} } } }); - it('should not save empty pid', (done) => { - spec.getUserSyncs( + sinon.assert.calledWithMatch( + handleCookieSyncStub, { iframeEnabled: true }, SAMPLE_RESPONSE, - { gdprApplies: true, vendorData: { vendor: { consents: {} } } } + { gdprApplies: true, vendorData: { vendor: { consents: {} } } }, + sinon.match.number, + sinon.match.object ); - messageHandler.call(window, { - origin: 'https://apps.smartadserver.com', - data: { action: 'getConsent', pid: '' }, - source: { postMessage: sinon.stub() } - }); - - expect(setDataInLocalStorageStub.notCalled).to.be.true; - done(); + expect(result).to.deep.equal(expectedResult); }); - it('should return array including iframe cookie sync object (gdprApplies=true)', () => { - const syncs = spec.getUserSyncs( - { iframeEnabled: true }, - SAMPLE_RESPONSE, - { gdprApplies: true } - ); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0]).to.deep.equal({ - type: 'iframe', - url: 'https://apps.smartadserver.com/diff/templates/asset/csync.html?nwid=111&gdpr=1&' - }); - }); + it('should return an empty array if handleCookieSync returns an empty array', () => { + handleCookieSyncStub.returns([]); - it('should return array including iframe cookie sync object (gdprApplies=false)', () => { - const syncs = spec.getUserSyncs( - { iframeEnabled: true }, + const result = spec.getUserSyncs({ iframeEnabled: true }, SAMPLE_RESPONSE, - { gdprApplies: false } - ); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0]).to.deep.equal({ - type: 'iframe', - url: 'https://apps.smartadserver.com/diff/templates/asset/csync.html?nwid=111&gdpr=0&' - }); + { gdprApplies: true, vendorData: { vendor: { consents: {} } } }); + + expect(result).to.deep.equal([]); }); }); diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index e302e2ec6ab..b15ab31e845 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -6,6 +6,7 @@ import { config } from 'src/config'; import * as utils from 'src/utils'; import { deepSetValue } from '../../../src/utils'; import { getImpIdMap, setIsEqtvTest } from '../../../modules/sharethroughBidAdapter'; +import * as equativUtils from '../../../libraries/equativUtils/equativUtils' const spec = newBidder(sharethroughAdapterSpec).getSpec(); @@ -1440,6 +1441,76 @@ describe('sharethrough adapter spec', function () { describe('getUserSyncs', function () { const cookieSyncs = ['cookieUrl1', 'cookieUrl2', 'cookieUrl3']; const serverResponses = [{ body: { cookieSyncUrls: cookieSyncs } }]; + let handleCookieSyncStub; + + const SAMPLE_RESPONSE = { + body: { + id: '12h712u7-k22g-8124-ab7a-h268s22dy271', + seatbid: [ + { + bid: [ + { + id: '1bh7jku7-ko2g-8654-ab72-h268shvwy271', + impid: 'r12gwgf231', + price: 0.6565, + adm: '

AD

', + adomain: ['abc.com'], + cid: '1242512', + crid: '535231', + w: 300, + h: 600, + mtype: 1, + cat: ['IAB19', 'IAB19-1'], + cattax: 1, + }, + ], + seat: '4212', + }, + ], + cur: 'USD', + statuscode: 0, + }, + }; + + beforeEach(() => { + handleCookieSyncStub = sinon.stub(equativUtils, 'handleCookieSync'); + }); + afterEach(() => { + handleCookieSyncStub.restore(); + }); + + it('should call handleCookieSync with correct parameters and return its result', () => { + setIsEqtvTest(true); + + const expectedResult = [ + { type: 'iframe', url: 'https://sync.example.com' }, + ]; + + handleCookieSyncStub.returns(expectedResult) + + const result = spec.getUserSyncs({ iframeEnabled: true }, + SAMPLE_RESPONSE, + { gdprApplies: true, vendorData: { vendor: { consents: {} } } }); + + sinon.assert.calledWithMatch( + handleCookieSyncStub, + { iframeEnabled: true }, + SAMPLE_RESPONSE, + { gdprApplies: true, vendorData: { vendor: { consents: {} } } }, + sinon.match.number, + sinon.match.object + ); + + expect(result).to.deep.equal(expectedResult); + }); + + it('should not call handleCookieSync and return undefined when isEqtvTest is false', () => { + setIsEqtvTest(false); + + spec.getUserSyncs({}, {}, {}); + + sinon.assert.notCalled(handleCookieSyncStub); + }); it('returns an array of correctly formatted user syncs', function () { const syncArray = spec.getUserSyncs({ pixelEnabled: true }, serverResponses); From 74c8a57ba9d2f53fde5359556e96a3259fd612cd Mon Sep 17 00:00:00 2001 From: Krzysztof SIEG Date: Mon, 21 Jul 2025 12:32:21 +0200 Subject: [PATCH 2/2] Lint --- libraries/equativUtils/equativUtils.js | 2 +- modules/sharethroughBidAdapter.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/equativUtils/equativUtils.js b/libraries/equativUtils/equativUtils.js index be09c64804f..fe68713429c 100644 --- a/libraries/equativUtils/equativUtils.js +++ b/libraries/equativUtils/equativUtils.js @@ -160,7 +160,7 @@ export const PID_STORAGE_NAME = 'eqt_pid'; /** * Handles cookie sync logic - * + * * @param syncOptions * @param serverResponses * @param gdprConsent diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index f5a371bc82f..ba75fae6dec 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -124,7 +124,6 @@ export const sharethroughAdapterSpec = { mergeDeep(req.device, bidderRequest.ortb2.device); } - if (bidderRequest.gdprConsent) { const gdprApplies = bidderRequest.gdprConsent.gdprApplies === true; req.regs.ext.gdpr = gdprApplies ? 1 : 0;