Skip to content

Commit

Permalink
TripleLift: User sync fallback (prebid#4509)
Browse files Browse the repository at this point in the history
* Add IdentityLink support and fix UnifiedId.

It appears we've been looking for UnifiedId userIds
on the bidderRequest object, when they are found on bidRequests.
This commit fixes that error, and adds support for IdentityLink.

* change maintainer email to group

* TripleLift: Sending schain (#1)

* Sending schain

* null -> undefined

* Hardcode sync endpoint protocol

* Switch to EB2 sync endpoint

* Add support for image based user syncing

* Rename endpoint variable

* Add assertion
  • Loading branch information
davidwoodsandersen authored and sumit116 committed Dec 11, 2019
1 parent 4de8eb7 commit 75036f2
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 12 deletions.
31 changes: 22 additions & 9 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
45 changes: 42 additions & 3 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
},
};
Expand Down Expand Up @@ -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
}
};
Expand Down Expand Up @@ -355,12 +356,50 @@ describe('triplelift adapter', function () {
referer: 'http://examplereferer.com'
},
gdprConsent: {
consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY',
consentString: GDPR_CONSENT_STR,
gdprApplies: true
}
};
let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});
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);
});
});
});

0 comments on commit 75036f2

Please sign in to comment.