Skip to content

Commit

Permalink
Taboola Bid Adapter: implement Iframe user sync (#10789)
Browse files Browse the repository at this point in the history
* iframe-sync

* iframe-sync-add-tests
  • Loading branch information
ahmadlob authored Dec 20, 2023
1 parent a5c2e06 commit 104f53f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const GVLID = 42;
const CURRENCY = 'USD';
export const END_POINT_URL = 'https://display.bidder.taboola.com/OpenRTB/TaboolaHB/auction';
export const USER_SYNC_IMG_URL = 'https://trc.taboola.com/sg/prebidJS/1/cm';
export const USER_SYNC_IFRAME_URL = 'https://cdn.taboola.com/scripts/prebid_iframe_sync.html';
const USER_ID = 'user-id';
const STORAGE_KEY = `taboola global:${USER_ID}`;
const COOKIE_KEY = 'trc_cookie_storage';
Expand Down Expand Up @@ -183,6 +184,13 @@ export const spec = {
queryParams.push('gpp=' + encodeURIComponent(gppConsent));
}

if (syncOptions.iframeEnabled) {
syncs.push({
type: 'iframe',
url: USER_SYNC_IFRAME_URL + (queryParams.length ? '?' + queryParams.join('&') : '')
});
}

if (syncOptions.pixelEnabled) {
syncs.push({
type: 'image',
Expand Down
17 changes: 14 additions & 3 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,17 +835,28 @@ describe('Taboola Adapter', function () {

describe('getUserSyncs', function () {
const usersyncUrl = 'https://trc.taboola.com/sg/prebidJS/1/cm';
const iframeUrl = 'https://cdn.taboola.com/scripts/prebid_iframe_sync.html';

it('should not return user sync if pixelEnabled is false', function () {
const res = spec.getUserSyncs({pixelEnabled: false});
it('should not return user sync if pixelEnabled is false and iframe disabled', function () {
const res = spec.getUserSyncs({pixelEnabled: false, iframeEnabled: false});
expect(res).to.be.an('array').that.is.empty;
});

it('should return user sync if pixelEnabled is true', function () {
const res = spec.getUserSyncs({pixelEnabled: true});
const res = spec.getUserSyncs({pixelEnabled: true, iframeEnabled: false});
expect(res).to.deep.equal([{type: 'image', url: usersyncUrl}]);
});

it('should return user sync if iframeEnabled is true', function () {
const res = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false});
expect(res).to.deep.equal([{type: 'iframe', url: iframeUrl}]);
});

it('should return both user syncs if iframeEnabled is true and pixelEnabled is true', function () {
const res = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true});
expect(res).to.deep.equal([{type: 'iframe', url: iframeUrl}, {type: 'image', url: usersyncUrl}]);
});

it('should pass consent tokens values', function() {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'GDPR_CONSENT'}, 'USP_CONSENT')).to.deep.equal([{
type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=GDPR_CONSENT&us_privacy=USP_CONSENT`
Expand Down

0 comments on commit 104f53f

Please sign in to comment.