Skip to content

Commit 5426945

Browse files
authored
Invibes Bid Adapter : reading page referer and cookie handlid (prebid#11477)
* InvibesBidAdapter - added cookie and referer read * InvibesBidAdapter - unit tests * InvibesBidAdapter - tab fix * InvibesBidAdapter - null checks * InvibesBidAdapter - fix { after if
1 parent 85cee26 commit 5426945

2 files changed

Lines changed: 56 additions & 4 deletions

File tree

modules/invibesBidAdapter.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const CONSTANTS = {
1414
SYNC_ENDPOINT: 'https://k.r66net.com/GetUserSync',
1515
TIME_TO_LIVE: 300,
1616
DEFAULT_CURRENCY: 'EUR',
17-
PREBID_VERSION: 11,
17+
PREBID_VERSION: 12,
1818
METHOD: 'GET',
1919
INVIBES_VENDOR_ID: 436,
2020
USERID_PROVIDERS: ['pubcid', 'pubProvidedId', 'uid2', 'zeotapIdPlus', 'id5id'],
@@ -40,7 +40,7 @@ export const spec = {
4040
buildRequests: buildRequest,
4141
/**
4242
* @param {*} responseObj
43-
* @param {requestParams} bidRequests
43+
* @param {*} requestParams
4444
* @return {Bid[]} An array of bids which
4545
*/
4646
interpretResponse: function (responseObj, requestParams) {
@@ -131,7 +131,6 @@ function buildRequest(bidRequests, bidderRequest) {
131131

132132
window.invibes.placementIds.push(bidRequest.params.placementId);
133133

134-
_placementIds.push(bidRequest.params.placementId);
135134
_placementIds.push(bidRequest.params.placementId);
136135
_adUnitCodes.push(bidRequest.adUnitCode);
137136
_domainId = _domainId || bidRequest.params.domainId;
@@ -180,9 +179,18 @@ function buildRequest(bidRequests, bidderRequest) {
180179
isLocalStorageEnabled: storage.hasLocalStorage(),
181180
preventPageViewEvent: preventPageViewEvent,
182181
isPlacementRefresh: isPlacementRefresh,
183-
isInfiniteScrollPage: isInfiniteScrollPage,
182+
isInfiniteScrollPage: isInfiniteScrollPage
184183
};
185184

185+
if (bidderRequest.refererInfo && bidderRequest.refererInfo.ref) {
186+
data.pageReferrer = bidderRequest.refererInfo.ref.substring(0, 300);
187+
}
188+
189+
let hid = invibes.getCookie('handIid');
190+
if (hid) {
191+
data.handIid = hid;
192+
}
193+
186194
let lid = readFromLocalStorage('ivbsdid');
187195
if (!lid) {
188196
let str = invibes.getCookie('ivbsdid');

test/spec/modules/invibesBidAdapter_spec.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,50 @@ describe('invibesBidAdapter:', function () {
560560
expect(request.data.lId).to.exist;
561561
});
562562

563+
it('does not send handIid when it doesnt exist in cookie', function () {
564+
top.window.invibes.optIn = 1;
565+
top.window.invibes.purposes = [true, false, false, false, false, false, false, false, false, false];
566+
global.document.cookie = '';
567+
let bidderRequest = {
568+
gdprConsent: {
569+
vendorData: {
570+
vendorConsents: {
571+
436: true
572+
}
573+
}
574+
},
575+
refererInfo: {
576+
page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue'
577+
}
578+
};
579+
SetBidderAccess();
580+
581+
let request = spec.buildRequests(bidRequests, bidderRequest);
582+
expect(request.data.handIid).to.not.exist;
583+
});
584+
585+
it('sends handIid when comes on cookie', function () {
586+
top.window.invibes.optIn = 1;
587+
top.window.invibes.purposes = [true, false, false, false, false, false, false, false, false, false];
588+
global.document.cookie = 'handIid=abcdefghijkk';
589+
let bidderRequest = {
590+
gdprConsent: {
591+
vendorData: {
592+
vendorConsents: {
593+
436: true
594+
}
595+
}
596+
},
597+
refererInfo: {
598+
page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue'
599+
}
600+
};
601+
SetBidderAccess();
602+
603+
let request = spec.buildRequests(bidRequests, bidderRequest);
604+
expect(request.data.handIid).to.equal('abcdefghijkk');
605+
});
606+
563607
it('should send purpose 1', function () {
564608
let bidderRequest = {
565609
gdprConsent: {

0 commit comments

Comments
 (0)