Skip to content

Commit

Permalink
Invibes Bid Adapter : reading page referer and cookie handlid (#11477)
Browse files Browse the repository at this point in the history
* InvibesBidAdapter - added cookie and referer read

* InvibesBidAdapter - unit tests

* InvibesBidAdapter - tab fix

* InvibesBidAdapter - null checks

* InvibesBidAdapter - fix { after if
  • Loading branch information
rcheptanariu authored May 15, 2024
1 parent 85cee26 commit 5426945
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/invibesBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down
44 changes: 44 additions & 0 deletions test/spec/modules/invibesBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 5426945

Please sign in to comment.