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

TripleLift: User sync fallback #2

Merged
merged 5 commits into from
Nov 27, 2019
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
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 [{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this return consumed by the core prebid logic? just wondering who is actually doing the syncing here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, getUserSyncs is called by the core logic here

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';
davidwoodsandersen marked this conversation as resolved.
Show resolved Hide resolved

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);
davidwoodsandersen marked this conversation as resolved.
Show resolved Hide resolved
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);
});
});
});