Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taboola Bid Adapter: Cookie Look Up Logic Fix #10873

Merged
merged 3 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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