From 542694585269e3796d65205283783915a8cf9f70 Mon Sep 17 00:00:00 2001 From: rcheptanariu <35690143+rcheptanariu@users.noreply.github.com> Date: Wed, 15 May 2024 15:31:45 +0300 Subject: [PATCH] Invibes Bid Adapter : reading page referer and cookie handlid (#11477) * InvibesBidAdapter - added cookie and referer read * InvibesBidAdapter - unit tests * InvibesBidAdapter - tab fix * InvibesBidAdapter - null checks * InvibesBidAdapter - fix { after if --- modules/invibesBidAdapter.js | 16 ++++++-- test/spec/modules/invibesBidAdapter_spec.js | 44 +++++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/modules/invibesBidAdapter.js b/modules/invibesBidAdapter.js index 2c37c0edad9..7ba2b8225b0 100644 --- a/modules/invibesBidAdapter.js +++ b/modules/invibesBidAdapter.js @@ -14,7 +14,7 @@ const CONSTANTS = { SYNC_ENDPOINT: 'https://k.r66net.com/GetUserSync', TIME_TO_LIVE: 300, DEFAULT_CURRENCY: 'EUR', - PREBID_VERSION: 11, + PREBID_VERSION: 12, METHOD: 'GET', INVIBES_VENDOR_ID: 436, USERID_PROVIDERS: ['pubcid', 'pubProvidedId', 'uid2', 'zeotapIdPlus', 'id5id'], @@ -40,7 +40,7 @@ export const spec = { buildRequests: buildRequest, /** * @param {*} responseObj - * @param {requestParams} bidRequests + * @param {*} requestParams * @return {Bid[]} An array of bids which */ interpretResponse: function (responseObj, requestParams) { @@ -131,7 +131,6 @@ function buildRequest(bidRequests, bidderRequest) { window.invibes.placementIds.push(bidRequest.params.placementId); - _placementIds.push(bidRequest.params.placementId); _placementIds.push(bidRequest.params.placementId); _adUnitCodes.push(bidRequest.adUnitCode); _domainId = _domainId || bidRequest.params.domainId; @@ -180,9 +179,18 @@ function buildRequest(bidRequests, bidderRequest) { isLocalStorageEnabled: storage.hasLocalStorage(), preventPageViewEvent: preventPageViewEvent, isPlacementRefresh: isPlacementRefresh, - isInfiniteScrollPage: isInfiniteScrollPage, + isInfiniteScrollPage: isInfiniteScrollPage }; + if (bidderRequest.refererInfo && bidderRequest.refererInfo.ref) { + data.pageReferrer = bidderRequest.refererInfo.ref.substring(0, 300); + } + + let hid = invibes.getCookie('handIid'); + if (hid) { + data.handIid = hid; + } + let lid = readFromLocalStorage('ivbsdid'); if (!lid) { let str = invibes.getCookie('ivbsdid'); diff --git a/test/spec/modules/invibesBidAdapter_spec.js b/test/spec/modules/invibesBidAdapter_spec.js index 056255c7738..ba2d8f5255a 100644 --- a/test/spec/modules/invibesBidAdapter_spec.js +++ b/test/spec/modules/invibesBidAdapter_spec.js @@ -560,6 +560,50 @@ describe('invibesBidAdapter:', function () { expect(request.data.lId).to.exist; }); + it('does not send handIid when it doesnt exist in cookie', function () { + top.window.invibes.optIn = 1; + top.window.invibes.purposes = [true, false, false, false, false, false, false, false, false, false]; + global.document.cookie = ''; + let bidderRequest = { + gdprConsent: { + vendorData: { + vendorConsents: { + 436: true + } + } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' + } + }; + SetBidderAccess(); + + let request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.handIid).to.not.exist; + }); + + it('sends handIid when comes on cookie', function () { + top.window.invibes.optIn = 1; + top.window.invibes.purposes = [true, false, false, false, false, false, false, false, false, false]; + global.document.cookie = 'handIid=abcdefghijkk'; + let bidderRequest = { + gdprConsent: { + vendorData: { + vendorConsents: { + 436: true + } + } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' + } + }; + SetBidderAccess(); + + let request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.handIid).to.equal('abcdefghijkk'); + }); + it('should send purpose 1', function () { let bidderRequest = { gdprConsent: {