Skip to content

Commit

Permalink
Taboola Bid Adapter: Cookie Look Up Logic Fix (#10873)
Browse files Browse the repository at this point in the history
* cookie-look-up-logic-fix

* cookie-look-up-logic-fix

* cookie-look-up-logic-fix
  • Loading branch information
ahmadlob authored Dec 27, 2023
1 parent ed48e34 commit 9ec2092
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const USER_SYNC_IFRAME_URL = 'https://cdn.taboola.com/scripts/prebid_ifra
const USER_ID = 'user-id';
const STORAGE_KEY = `taboola global:${USER_ID}`;
const COOKIE_KEY = 'trc_cookie_storage';
const TGID_COOKIE_KEY = 't_gid';
const TBLA_ID_COOKIE_KEY = 'tbla_id';
export const EVENT_ENDPOINT = 'https://beacon.bidder.taboola.com';

/**
Expand All @@ -40,10 +42,18 @@ export const userData = {
const {cookiesAreEnabled, getCookie} = userData.storageManager;
if (cookiesAreEnabled()) {
const cookieData = getCookie(COOKIE_KEY);
const userId = userData.getCookieDataByKey(cookieData, USER_ID);
let userId = userData.getCookieDataByKey(cookieData, USER_ID);
if (userId) {
return userId;
}
userId = getCookie(TGID_COOKIE_KEY);
if (userId) {
return userId;
}
const tblaId = getCookie(TBLA_ID_COOKIE_KEY);
if (tblaId) {
return tblaId;
}
}
},
getCookieDataByKey(cookieData, key) {
Expand Down
16 changes: 16 additions & 0 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,22 @@ describe('Taboola Adapter', function () {
expect(resData.user.buyeruid).to.equal('12121212');
});

it('should get user id from tgid cookie if local storage isn`t defined', function () {
getDataFromLocalStorage.returns(51525152);
hasLocalStorage.returns(false);
localStorageIsEnabled.returns(false);
cookiesAreEnabled.returns(true);
getCookie.returns('d966c5be-c49f-4f73-8cd1-37b6b5790653-tuct9f7bf10');

const bidderRequest = {
...commonBidderRequest
};
const res = spec.buildRequests([defaultBidRequest], bidderRequest);
const resData = JSON.parse(res.data);

expect(resData.user.buyeruid).to.equal('d966c5be-c49f-4f73-8cd1-37b6b5790653-tuct9f7bf10');
});

it('should get user id from TRC if local storage and cookie isn`t defined', function () {
hasLocalStorage.returns(false);
cookiesAreEnabled.returns(false);
Expand Down

0 comments on commit 9ec2092

Please sign in to comment.