From 84a39c6427c0db4d3b161beb3aa6a524189eddf7 Mon Sep 17 00:00:00 2001 From: antoinezaz Date: Fri, 23 Jul 2021 17:20:00 +0200 Subject: [PATCH] oguryBidAdapter: handle cookie syncing on prebid.js (#7207) --- modules/oguryBidAdapter.js | 11 +++++++ test/spec/modules/oguryBidAdapter_spec.js | 35 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/modules/oguryBidAdapter.js b/modules/oguryBidAdapter.js index eb751fb5916..44c9b7a509a 100644 --- a/modules/oguryBidAdapter.js +++ b/modules/oguryBidAdapter.js @@ -7,6 +7,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'ogury'; const DEFAULT_TIMEOUT = 1000; const BID_HOST = 'https://mweb-hb.presage.io/api/header-bidding-request'; +const MS_COOKIE_SYNC_DOMAIN = 'https://ms-cookie-sync.presage.io'; function isBidRequestValid(bid) { const adUnitSizes = getAdUnitSizes(bid); @@ -18,6 +19,15 @@ function isBidRequestValid(bid) { return (isValidSizes && isValidAdUnitId && isValidAssetKey); } +function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { + if (!syncOptions.pixelEnabled) return []; + + return [{ + type: 'image', + url: `${MS_COOKIE_SYNC_DOMAIN}/v1/init-sync/bid-switch?iab_string=${gdprConsent.consentString}&source=prebid` + }] +} + function buildRequests(validBidRequests, bidderRequest) { const openRtbBidRequestBanner = { id: bidderRequest.auctionId, @@ -129,6 +139,7 @@ export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER], isBidRequestValid, + getUserSyncs, buildRequests, interpretResponse, getFloor diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js index 34af8606ea6..57de2162789 100644 --- a/test/spec/modules/oguryBidAdapter_spec.js +++ b/test/spec/modules/oguryBidAdapter_spec.js @@ -107,6 +107,41 @@ describe('OguryBidAdapter', function () { }); }); + describe('getUserSyncs', function() { + let syncOptions, gdprConsent; + + beforeEach(() => { + syncOptions = {pixelEnabled: true}; + gdprConsent = { + gdprApplies: true, + consentString: 'CPJl4C8PJl4C8OoAAAENAwCMAP_AAH_AAAAAAPgAAAAIAPgAAAAIAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g' + }; + }); + + it('should return syncs array with an element of type image', () => { + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + + expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs[0].type).to.equal('image'); + expect(userSyncs[0].url).to.contain('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch'); + }); + + it('should set the source as query param', () => { + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs[0].url).to.contain('source=prebid'); + }); + + it('should set the tcString as query param', () => { + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs[0].url).to.contain(`iab_string=${gdprConsent.consentString}`); + }); + + it('should return an empty array when pixel is disable', () => { + syncOptions.pixelEnabled = false; + expect(spec.getUserSyncs(syncOptions, [], gdprConsent)).to.have.lengthOf(0); + }); + }); + describe('buildRequests', function () { const defaultTimeout = 1000; const expectedRequestObject = {