diff --git a/modules/invibesBidAdapter.js b/modules/invibesBidAdapter.js index b2444043c22..0c0d1cdef87 100644 --- a/modules/invibesBidAdapter.js +++ b/modules/invibesBidAdapter.js @@ -1,4 +1,4 @@ -import { logInfo } from '../src/utils.js'; +import {logInfo} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {getStorageManager} from '../src/storageManager.js'; @@ -9,7 +9,7 @@ const CONSTANTS = { SYNC_ENDPOINT: 'https://k.r66net.com/GetUserSync', TIME_TO_LIVE: 300, DEFAULT_CURRENCY: 'EUR', - PREBID_VERSION: 9, + PREBID_VERSION: 10, METHOD: 'GET', INVIBES_VENDOR_ID: 436, USERID_PROVIDERS: ['pubcid', 'pubProvidedId', 'uid2', 'zeotapIdPlus', 'id5id'], @@ -116,7 +116,7 @@ function buildRequest(bidRequests, bidderRequest) { bidParamsJson.userId = userIdModel; } let data = { - location: getDocumentLocation(topWin), + location: getDocumentLocation(bidderRequest), videoAdHtmlId: generateRandomId(), showFallback: currentQueryStringParams['advs'] === '0', ivbsCampIdsLocal: readFromLocalStorage('IvbsCampIdsLocal'), @@ -371,8 +371,8 @@ function generateRandomId() { return (Math.round(Math.random() * 1e12)).toString(36).substring(0, 10); } -function getDocumentLocation(topWin) { - return topWin.location.href.substring(0, 300).split(/[?#]/)[0]; +function getDocumentLocation(bidderRequest) { + return bidderRequest.refererInfo.page.substring(0, 300); } function getUserIds(bidUserId) { diff --git a/test/spec/modules/invibesBidAdapter_spec.js b/test/spec/modules/invibesBidAdapter_spec.js index 2b98a9f8960..7ee6b464996 100644 --- a/test/spec/modules/invibesBidAdapter_spec.js +++ b/test/spec/modules/invibesBidAdapter_spec.js @@ -81,6 +81,13 @@ describe('invibesBidAdapter:', function () { } ]; + let bidderRequestWithPageInfo = { + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' + }, + auctionStart: Date.now() + } + let StubbedPersistence = function (initialValue) { var value = initialValue; return { @@ -174,17 +181,17 @@ describe('invibesBidAdapter:', function () { describe('buildRequests', function () { it('sends preventPageViewEvent as false on first call', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.preventPageViewEvent).to.be.false; }); it('sends preventPageViewEvent as true on 2nd call', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.preventPageViewEvent).to.be.true; }); it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.url).to.equal(ENDPOINT); expect(request.method).to.equal('GET'); }); @@ -198,7 +205,7 @@ describe('invibesBidAdapter:', function () { customEndpoint: 'sub.domain.com/Bid/VideoAdContent' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('sub.domain.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -210,7 +217,7 @@ describe('invibesBidAdapter:', function () { params: { }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal(ENDPOINT); expect(request.method).to.equal('GET'); }); @@ -223,7 +230,7 @@ describe('invibesBidAdapter:', function () { placementId: null }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal(ENDPOINT); expect(request.method).to.equal('GET'); }); @@ -236,7 +243,7 @@ describe('invibesBidAdapter:', function () { placementId: 'placement' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -250,7 +257,7 @@ describe('invibesBidAdapter:', function () { domainId: 1001 }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -264,7 +271,7 @@ describe('invibesBidAdapter:', function () { domainId: 1002 }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid2.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -277,7 +284,7 @@ describe('invibesBidAdapter:', function () { placementId: 'infeed_ivbs1' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -290,7 +297,7 @@ describe('invibesBidAdapter:', function () { placementId: 'infeed_ivbs2' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid2.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -303,18 +310,18 @@ describe('invibesBidAdapter:', function () { placementId: 'infeed_ivbs10' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid10.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); it('sends cookies with the bid request', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.options.withCredentials).to.equal(true); }); it('has location, html id, placement and width/height', function () { - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); const parsedData = request.data; expect(parsedData.location).to.exist; expect(parsedData.videoAdHtmlId).to.exist; @@ -323,13 +330,20 @@ describe('invibesBidAdapter:', function () { expect(parsedData.height).to.exist; }); + it('has location not cut off', function () { + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + const parsedData = request.data; + expect(parsedData.location).to.contain('?'); + expect(parsedData.location).to.equal('https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue'); + }); + it('has capped ids if local storage variable is correctly formatted', function () { top.window.invibes.optIn = 1; top.window.invibes.purposes = [true, false, false, false, false, false, false, false, false, false]; localStorage.ivvcap = '{"9731":[1,1768600800000]}'; SetBidderAccess(); - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.capCounts).to.equal('9731=1'); }); @@ -356,6 +370,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; @@ -366,59 +383,59 @@ describe('invibesBidAdapter:', function () { it('does not have capped ids if local storage variable is incorrectly formatted', function () { localStorage.ivvcap = ':[1,1574334216992]}'; - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.capCounts).to.equal(''); }); it('does not have capped ids if local storage variable is expired', function () { localStorage.ivvcap = '{"9731":[1,1574330064104]}'; - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.capCounts).to.equal(''); }); it('sends query string params from localstorage 1', function () { localStorage.ivbs = JSON.stringify({bvci: 1}); - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.bvci).to.equal(1); }); it('sends query string params from localstorage 2', function () { localStorage.ivbs = JSON.stringify({invibbvlog: true}); - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.invibbvlog).to.equal(true); }); it('does not send query string params from localstorage if unknwon', function () { localStorage.ivbs = JSON.stringify({someparam: true}); - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.someparam).to.be.undefined; }); it('sends all Placement Ids', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(JSON.parse(request.data.bidParamsJson).placementIds).to.contain(bidRequests[0].params.placementId); expect(JSON.parse(request.data.bidParamsJson).placementIds).to.contain(bidRequests[1].params.placementId); }); it('sends all adUnitCodes', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(JSON.parse(request.data.bidParamsJson).adUnitCodes).to.contain(bidRequests[0].adUnitCode); expect(JSON.parse(request.data.bidParamsJson).adUnitCodes).to.contain(bidRequests[1].adUnitCode); }); it('sends all Placement Ids and userId', function () { - const request = spec.buildRequests(bidRequestsWithUserId); + const request = spec.buildRequests(bidRequestsWithUserId, bidderRequestWithPageInfo); expect(JSON.parse(request.data.bidParamsJson).userId).to.exist; }); it('sends undefined lid when no cookie', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.lId).to.be.undefined; }); it('sends pushed cids if they exist', function () { top.window.invibes.pushedCids = { 981: [] }; - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.pcids).to.contain(981); }); @@ -426,7 +443,18 @@ describe('invibesBidAdapter:', function () { top.window.invibes.optIn = 1; top.window.invibes.purposes = [true, false, false, false, false, false, false, false, false, false]; global.document.cookie = 'ivbsdid={"id":"dvdjkams6nkq","cr":' + Date.now() + ',"hc":0}'; - let bidderRequest = {gdprConsent: {vendorData: {vendorConsents: {436: true}}}}; + let bidderRequest = { + gdprConsent: { + vendorData: { + vendorConsents: { + 436: true + } + } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' + } + }; SetBidderAccess(); let request = spec.buildRequests(bidRequests, bidderRequest); @@ -455,6 +483,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -483,6 +514,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -511,6 +545,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -551,6 +588,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -560,6 +600,9 @@ describe('invibesBidAdapter:', function () { let bidderRequest = { gdprConsent: { vendorData: null + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -588,6 +631,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -615,6 +661,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -642,6 +691,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -669,6 +721,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -683,6 +738,9 @@ describe('invibesBidAdapter:', function () { vendor: {consents: {436: false}}, purpose: {} } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -711,6 +769,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -734,6 +795,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -762,6 +826,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -790,6 +857,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -811,6 +881,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -832,6 +905,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -845,6 +921,9 @@ describe('invibesBidAdapter:', function () { gdprApplies: false, hasGlobalConsent: true, } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -866,6 +945,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -887,6 +969,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -906,6 +991,9 @@ describe('invibesBidAdapter:', function () { 3: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -927,6 +1015,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -1214,13 +1305,13 @@ describe('invibesBidAdapter:', function () { describe('getUserSyncs', function () { it('returns undefined if disableUserSyncs not passed as bid request param ', function () { - spec.buildRequests(bidRequestsWithUserId); + spec.buildRequests(bidRequestsWithUserId, bidderRequestWithPageInfo); let response = spec.getUserSyncs({iframeEnabled: true}); expect(response).to.equal(undefined); }); it('returns an iframe if enabled', function () { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); let response = spec.getUserSyncs({iframeEnabled: true}); expect(response.type).to.equal('iframe'); @@ -1229,7 +1320,7 @@ describe('invibesBidAdapter:', function () { it('returns an iframe with params if enabled', function () { top.window.invibes.optIn = 1; - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); let response = spec.getUserSyncs({iframeEnabled: true}); expect(response.type).to.equal('iframe'); @@ -1239,7 +1330,7 @@ describe('invibesBidAdapter:', function () { it('returns an iframe with params including if enabled', function () { top.window.invibes.optIn = 1; - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); global.document.cookie = 'ivbsdid={"id":"dvdjkams6nkq","cr":' + Date.now() + ',"hc":0}'; SetBidderAccess(); @@ -1252,7 +1343,7 @@ describe('invibesBidAdapter:', function () { }); it('returns an iframe with params including if enabled read from LocalStorage', function () { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); top.window.invibes.optIn = 1; localStorage.ivbsdid = 'dvdjkams6nkq'; @@ -1266,7 +1357,7 @@ describe('invibesBidAdapter:', function () { }); it('returns undefined if iframe not enabled ', function () { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); let response = spec.getUserSyncs({iframeEnabled: false}); expect(response).to.equal(undefined);