diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index d49e4cde480..1550a9e3463 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -63,21 +63,34 @@ export const tripleliftAdapterSpec = { }, getUserSyncs: function(syncOptions) { - let ibCall = '//ib.3lift.com/sync?'; - if (consentString !== null) { - ibCall = utils.tryAppendQueryString(ibCall, 'gdpr', gdprApplies); - ibCall = utils.tryAppendQueryString(ibCall, 'cmp_cs', consentString); + let syncType = _getSyncType(syncOptions); + if (!syncType) return; + + let syncEndpoint = 'https://eb2.3lift.com/sync?'; + + if (syncType === 'image') { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'px', 1); + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'src', 'prebid'); } - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: ibCall - }]; + if (consentString !== null) { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'gdpr', gdprApplies); + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'cmp_cs', consentString); } + + return [{ + type: syncType, + url: syncEndpoint + }]; } } +function _getSyncType(syncOptions) { + if (!syncOptions) return; + if (syncOptions.iframeEnabled) return 'iframe'; + if (syncOptions.pixelEnabled) return 'image'; +} + function _buildPostBody(bidRequests) { let data = {}; let { schain } = bidRequests[0]; diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 12a2f66dde2..aee4c4d2586 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -5,6 +5,7 @@ import { deepClone } from 'src/utils'; import prebid from '../../../package.json'; const ENDPOINT = 'https://tlx.3lift.com/header/auction?'; +const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY'; describe('triplelift adapter', function () { const adapter = newBidder(tripleliftAdapterSpec); @@ -107,7 +108,7 @@ describe('triplelift adapter', function () { referer: 'http://examplereferer.com' }, gdprConsent: { - consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', + consentString: GDPR_CONSENT_STR, gdprApplies: true }, }; @@ -281,7 +282,7 @@ describe('triplelift adapter', function () { referer: 'http://examplereferer.com' }, gdprConsent: { - consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', + consentString: GDPR_CONSENT_STR, gdprApplies: true } }; @@ -355,7 +356,7 @@ describe('triplelift adapter', function () { referer: 'http://examplereferer.com' }, gdprConsent: { - consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', + consentString: GDPR_CONSENT_STR, gdprApplies: true } }; @@ -363,4 +364,42 @@ describe('triplelift adapter', function () { expect(result).to.have.length(2); }); }); + + describe('getUserSyncs', function() { + let expectedIframeSyncUrl = 'https://eb2.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&'; + let expectedImageSyncUrl = 'https://eb2.3lift.com/sync?px=1&src=prebid&gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&'; + + it('returns undefined when syncing is not enabled', function() { + expect(tripleliftAdapterSpec.getUserSyncs({})).to.equal(undefined); + expect(tripleliftAdapterSpec.getUserSyncs()).to.equal(undefined); + }); + + it('returns iframe user sync pixel when iframe syncing is enabled', function() { + let syncOptions = { + iframeEnabled: true + }; + let result = tripleliftAdapterSpec.getUserSyncs(syncOptions); + expect(result[0].type).to.equal('iframe'); + expect(result[0].url).to.equal(expectedIframeSyncUrl); + }); + + it('returns image user sync pixel when iframe syncing is disabled', function() { + let syncOptions = { + pixelEnabled: true + }; + let result = tripleliftAdapterSpec.getUserSyncs(syncOptions); + expect(result[0].type).to.equal('image') + expect(result[0].url).to.equal(expectedImageSyncUrl); + }); + + it('returns iframe user sync pixel when both options are enabled', function() { + let syncOptions = { + pixelEnabled: true, + iframeEnabled: true + }; + let result = tripleliftAdapterSpec.getUserSyncs(syncOptions); + expect(result[0].type).to.equal('iframe'); + expect(result[0].url).to.equal(expectedIframeSyncUrl); + }); + }); });