From 86546e9a51375bf6be11d28fef9bfde11f6a550c Mon Sep 17 00:00:00 2001 From: Will Chapin Date: Mon, 16 Sep 2019 13:31:01 -0400 Subject: [PATCH 01/27] 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. --- modules/tripleliftBidAdapter.js | 56 +++--- .../spec/modules/tripleliftBidAdapter_spec.js | 164 ++++++++++++++---- 2 files changed, 162 insertions(+), 58 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 2d6b2dce8de..5ed88384b11 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -17,7 +17,7 @@ export const tripleliftAdapterSpec = { buildRequests: function(bidRequests, bidderRequest) { let tlCall = STR_ENDPOINT; - let data = _buildPostBody(bidRequests, bidderRequest); + let data = _buildPostBody(bidRequests); tlCall = utils.tryAppendQueryString(tlCall, 'lib', 'prebid'); tlCall = utils.tryAppendQueryString(tlCall, 'v', '$prebid.version$'); @@ -78,7 +78,7 @@ export const tripleliftAdapterSpec = { } } -function _buildPostBody(bidRequests, bidderRequest) { +function _buildPostBody(bidRequests) { let data = {}; data.imp = bidRequests.map(function(bid, index) { return { @@ -91,7 +91,11 @@ function _buildPostBody(bidRequests, bidderRequest) { }; }); - let eids = handleConsortiaUserIds(bidderRequest); + let eids = [ + ...getUnifiedIdEids(bidRequests), + ...getIdentityLinkEids(bidRequests) + ]; + if (eids.length > 0) { data.user = { ext: {eids} @@ -101,6 +105,35 @@ function _buildPostBody(bidRequests, bidderRequest) { return data; } +function getUnifiedIdEids(bidRequests) { + return getEids(bidRequests, 'tdid', 'adserver.org', 'TDID'); +} + +function getIdentityLinkEids(bidRequests) { + return getEids(bidRequests, 'idl_env', 'liveramp.com', 'idl'); +} + +function getEids(bidRequests, type, source, rtiPartner) { + return bidRequests + .map(getUserId(type)) // bids -> userIds of a certain type + .filter((x) => !!x) // filter out null userIds + .map(formatEid(source, rtiPartner)); // userIds -> eid objects +} + +function getUserId(type) { + return (bid) => (bid && bid.userId && bid.userId[type]); +} + +function formatEid(source, rtiPartner) { + return (id) => ({ + source, + uids: [{ + id, + ext: { rtiPartner } + }] + }); +} + function _sizes(sizeArray) { let sizes = sizeArray.filter(_isValidSize); return sizes.map(function(size) { @@ -115,23 +148,6 @@ function _isValidSize(size) { return (size.length === 2 && typeof size[0] === 'number' && typeof size[1] === 'number'); } -function handleConsortiaUserIds(bidderRequest) { - let eids = []; - if (bidderRequest.userId && bidderRequest.userId.tdid) { - eids.push({ - source: 'adserver.org', - uids: [{ - id: bidderRequest.userId.tdid, - ext: { - rtiPartner: 'TDID' - } - }] - }); - } - - return eids; -} - function _buildResponseObject(bidderRequest, bid) { let bidResponse = {}; let width = bid.width || 1; diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 52a7be3020c..190f463f7a5 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -54,46 +54,49 @@ describe('triplelift adapter', function () { }); describe('buildRequests', function () { - let bidRequests = [ - { - bidder: 'triplelift', - params: { - inventoryCode: '12345', - floor: 1.0, - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - } - ]; + let bidRequests; + let bidderRequest; - let bidderRequest = { - bidderCode: 'triplelift', - auctionId: 'a7ebcd1d-66ff-4b5c-a82c-6a21a6ee5a18', - bidderRequestId: '5c55612f99bc11', - bids: [ + this.beforeEach(() => { + bidRequests = [ { - imp_id: 0, - cpm: 1.062, - width: 300, - height: 250, - ad: 'ad-markup', - iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg' + bidder: 'triplelift', + params: { + inventoryCode: '12345', + floor: 1.0, + }, + adUnitCode: 'adunit-code', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, } - ], - refererInfo: { - referer: 'http://examplereferer.com' - }, - gdprConsent: { - consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', - gdprApplies: true - }, - userId: { - tdid: '6bca7f6b-a98a-46c0-be05-6020f7604598' - } - }; + ]; + + bidderRequest = { + bidderCode: 'triplelift', + auctionId: 'a7ebcd1d-66ff-4b5c-a82c-6a21a6ee5a18', + bidderRequestId: '5c55612f99bc11', + bids: [ + { + imp_id: 0, + cpm: 1.062, + width: 300, + height: 250, + ad: 'ad-markup', + iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg' + } + ], + refererInfo: { + referer: 'http://examplereferer.com' + }, + gdprConsent: { + consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', + gdprApplies: true + }, + }; + }); it('exists and is an object', function () { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); @@ -116,10 +119,95 @@ describe('triplelift adapter', function () { }); it('should add tdid to the payload if included', function () { + const id = '6bca7f6b-a98a-46c0-be05-6020f7604598'; + bidRequests[0].userId.tdid = id; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const payload = request.data; + expect(payload).to.exist; + expect(payload.user).to.deep.equal({ext: {eids: [{source: 'adserver.org', uids: [{id, ext: {rtiPartner: 'TDID'}}]}]}}); + }); + + it('should add idl_env to the payload if included', function () { + const id = 'XY6104gr0njcH9UDIR7ysFFJcm2XNpqeJTYslleJ_cMlsFOfZI'; + bidRequests[0].userId.idl_env = id; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const payload = request.data; + expect(payload).to.exist; + expect(payload.user).to.deep.equal({ext: {eids: [{source: 'liveramp.com', uids: [{id, ext: {rtiPartner: 'idl'}}]}]}}); + }); + + it('should add both tdid and idl_env to the payload if both are included', function () { + const tdidId = '6bca7f6b-a98a-46c0-be05-6020f7604598'; + const idlEnvId = 'XY6104gr0njcH9UDIR7ysFFJcm2XNpqeJTYslleJ_cMlsFOfZI'; + bidRequests[0].userId.tdid = tdidId; + bidRequests[0].userId.idl_env = idlEnvId; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const payload = request.data; + expect(payload).to.exist; - expect(payload.user).to.deep.equal({ext: {eids: [{source: 'adserver.org', uids: [{id: '6bca7f6b-a98a-46c0-be05-6020f7604598', ext: {rtiPartner: 'TDID'}}]}]}}); + expect(payload.user).to.deep.equal({ + ext: { + eids: [ + { + source: 'adserver.org', + uids: [ + { + id: tdidId, + ext: { rtiPartner: 'TDID' } + } + ], + }, + { + source: 'liveramp.com', + uids: [ + { + id: idlEnvId, + ext: { rtiPartner: 'idl' } + } + ] + } + ] + } + }); + }); + + it('should add user ids from multiple bid requests', function () { + const tdidId = '6bca7f6b-a98a-46c0-be05-6020f7604598'; + const idlEnvId = 'XY6104gr0njcH9UDIR7ysFFJcm2XNpqeJTYslleJ_cMlsFOfZI'; + + const bidRequestsMultiple = [ + { ...bidRequests[0], userId: { tdid: tdidId } }, + { ...bidRequests[0], userId: { idl_env: idlEnvId } }, + ]; + + const request = tripleliftAdapterSpec.buildRequests(bidRequestsMultiple, bidderRequest); + const payload = request.data; + + expect(payload.user).to.deep.equal({ + ext: { + eids: [ + { + source: 'adserver.org', + uids: [ + { + id: tdidId, + ext: { rtiPartner: 'TDID' } + } + ], + }, + { + source: 'liveramp.com', + uids: [ + { + id: idlEnvId, + ext: { rtiPartner: 'idl' } + } + ] + } + ] + } + }); }); it('should return a query string for TL call', function () { From a98d3a4e3ed51bcd61860b327c9b7bead400c429 Mon Sep 17 00:00:00 2001 From: Will Chapin Date: Mon, 16 Sep 2019 15:27:01 -0400 Subject: [PATCH 02/27] change maintainer email to group --- modules/tripleliftBidAdapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.md b/modules/tripleliftBidAdapter.md index c10ea3675d4..d5f88a2bece 100644 --- a/modules/tripleliftBidAdapter.md +++ b/modules/tripleliftBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: Triplelift Bid Adapter Module Type: Bidder Adapter -Maintainer: csmith+s2s@triplelift.com +Maintainer: prebid@triplelift.com ``` # Description From 0f5ea8b1fa06f5b5c8b6738b47ab77e1eb2e0d9a Mon Sep 17 00:00:00 2001 From: colbertk <50499465+colbertk@users.noreply.github.com> Date: Thu, 24 Oct 2019 13:55:57 -0400 Subject: [PATCH 03/27] TripleLift: Sending schain (#1) * Sending schain * null -> undefined --- modules/tripleliftBidAdapter.js | 6 ++++ .../spec/modules/tripleliftBidAdapter_spec.js | 28 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 5ed88384b11..d49e4cde480 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -80,6 +80,7 @@ export const tripleliftAdapterSpec = { function _buildPostBody(bidRequests) { let data = {}; + let { schain } = bidRequests[0]; data.imp = bidRequests.map(function(bid, index) { return { id: index, @@ -102,6 +103,11 @@ function _buildPostBody(bidRequests) { }; } + if (schain) { + data.ext = { + schain + } + } return data; } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 190f463f7a5..12a2f66dde2 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -56,6 +56,20 @@ describe('triplelift adapter', function () { describe('buildRequests', function () { let bidRequests; let bidderRequest; + const schain = { + validation: 'strict', + config: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'indirectseller.com', + sid: '00001', + hp: 1, + } + ] + } + }; this.beforeEach(() => { bidRequests = [ @@ -71,6 +85,7 @@ describe('triplelift adapter', function () { bidderRequestId: '22edbae2733bf6', auctionId: '1d1a030790a475', userId: {}, + schain, } ]; @@ -220,6 +235,17 @@ describe('triplelift adapter', function () { expect(url).to.match(new RegExp('(?:' + prebid.version + ')')) expect(url).to.match(/(?:referrer)/); }); + it('should return schain when present', function() { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const { data: payload } = request; + expect(payload.ext.schain).to.deep.equal(schain); + }); + it('should not create root level ext when schain is not present', function() { + bidRequests[0].schain = undefined; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const { data: payload } = request; + expect(payload.ext).to.deep.equal(undefined); + }); }); describe('interpretResponse', function () { @@ -280,7 +306,7 @@ describe('triplelift adapter', function () { expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); }); - it('should return multile responses to support SRA', function () { + it('should return multiple responses to support SRA', function () { let response = { body: { bids: [ From 44993e15dce9a79ebda9e8a9e9f51bbd21dfa805 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Mon, 25 Nov 2019 14:11:58 -0500 Subject: [PATCH 04/27] Hardcode sync endpoint protocol --- modules/tripleliftBidAdapter.js | 2 +- .../spec/modules/tripleliftBidAdapter_spec.js | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index d49e4cde480..1f045367669 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -63,7 +63,7 @@ export const tripleliftAdapterSpec = { }, getUserSyncs: function(syncOptions) { - let ibCall = '//ib.3lift.com/sync?'; + let ibCall = 'https://ib.3lift.com/sync?'; if (consentString !== null) { ibCall = utils.tryAppendQueryString(ibCall, 'gdpr', gdprApplies); ibCall = utils.tryAppendQueryString(ibCall, 'cmp_cs', consentString); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 12a2f66dde2..afa427ef7ae 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,21 @@ describe('triplelift adapter', function () { expect(result).to.have.length(2); }); }); + + describe('getUserSyncs', function() { + let expectedSyncUrl = 'https://ib.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&'; + + it('returns undefined when syncing is not enabled', function() { + 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(expectedSyncUrl); + }); + }); }); From b0adb54ad8beab0014b7e427d94a8f34a1b09af5 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Mon, 25 Nov 2019 14:28:41 -0500 Subject: [PATCH 05/27] Switch to EB2 sync endpoint --- modules/tripleliftBidAdapter.js | 2 +- test/spec/modules/tripleliftBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 1f045367669..071f12046de 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -63,7 +63,7 @@ export const tripleliftAdapterSpec = { }, getUserSyncs: function(syncOptions) { - let ibCall = 'https://ib.3lift.com/sync?'; + let ibCall = 'https://eb2.3lift.com/sync?'; if (consentString !== null) { ibCall = utils.tryAppendQueryString(ibCall, 'gdpr', gdprApplies); ibCall = utils.tryAppendQueryString(ibCall, 'cmp_cs', consentString); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index afa427ef7ae..0179b211517 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -366,7 +366,7 @@ describe('triplelift adapter', function () { }); describe('getUserSyncs', function() { - let expectedSyncUrl = 'https://ib.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&'; + let expectedSyncUrl = 'https://eb2.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&'; it('returns undefined when syncing is not enabled', function() { expect(tripleliftAdapterSpec.getUserSyncs({})).to.equal(undefined); From 0c6c2952dca494cc3bb9bee35e10d6df26e4d503 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Mon, 25 Nov 2019 17:01:32 -0500 Subject: [PATCH 06/27] Add support for image based user syncing --- modules/tripleliftBidAdapter.js | 25 ++++++++++++++----- .../spec/modules/tripleliftBidAdapter_spec.js | 24 ++++++++++++++++-- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 071f12046de..1ebaaa1c440 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -63,21 +63,34 @@ export const tripleliftAdapterSpec = { }, getUserSyncs: function(syncOptions) { + let syncType = _getSyncType(syncOptions); + if (!syncType) return; + let ibCall = 'https://eb2.3lift.com/sync?'; + + if (syncType === 'image') { + ibCall = utils.tryAppendQueryString(ibCall, 'px', 1); + ibCall = utils.tryAppendQueryString(ibCall, 'src', 'prebid'); + } + if (consentString !== null) { ibCall = utils.tryAppendQueryString(ibCall, 'gdpr', gdprApplies); ibCall = utils.tryAppendQueryString(ibCall, 'cmp_cs', consentString); } - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: ibCall - }]; - } + return [{ + type: syncType, + url: ibCall + }]; } } +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 0179b211517..aa312c4621e 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -366,7 +366,8 @@ describe('triplelift adapter', function () { }); describe('getUserSyncs', function() { - let expectedSyncUrl = 'https://eb2.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&'; + 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); @@ -378,7 +379,26 @@ describe('triplelift adapter', function () { }; let result = tripleliftAdapterSpec.getUserSyncs(syncOptions); expect(result[0].type).to.equal('iframe'); - expect(result[0].url).to.equal(expectedSyncUrl); + 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); }); }); }); From 3f55f3239a9b83f139f9a20bd23c92db119d0c02 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 26 Nov 2019 17:11:43 -0500 Subject: [PATCH 07/27] Rename endpoint variable --- modules/tripleliftBidAdapter.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 1ebaaa1c440..1550a9e3463 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -66,21 +66,21 @@ export const tripleliftAdapterSpec = { let syncType = _getSyncType(syncOptions); if (!syncType) return; - let ibCall = 'https://eb2.3lift.com/sync?'; + let syncEndpoint = 'https://eb2.3lift.com/sync?'; if (syncType === 'image') { - ibCall = utils.tryAppendQueryString(ibCall, 'px', 1); - ibCall = utils.tryAppendQueryString(ibCall, 'src', 'prebid'); + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'px', 1); + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'src', 'prebid'); } if (consentString !== null) { - ibCall = utils.tryAppendQueryString(ibCall, 'gdpr', gdprApplies); - ibCall = utils.tryAppendQueryString(ibCall, 'cmp_cs', consentString); + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'gdpr', gdprApplies); + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'cmp_cs', consentString); } return [{ type: syncType, - url: ibCall + url: syncEndpoint }]; } } From 280404f4609883a08cda3cd5fe05915b0c0a38f3 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 26 Nov 2019 17:14:15 -0500 Subject: [PATCH 08/27] Add assertion --- test/spec/modules/tripleliftBidAdapter_spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index aa312c4621e..aee4c4d2586 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -371,6 +371,7 @@ describe('triplelift adapter', function () { 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() { From cad32b7a083670fecb366c4399858818757cbfb6 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 17 Dec 2019 16:05:55 -0500 Subject: [PATCH 09/27] Add CCPA query param --- modules/tripleliftBidAdapter.js | 10 +++++++++- test/spec/modules/tripleliftBidAdapter_spec.js | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 1550a9e3463..30f1f147364 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -42,6 +42,10 @@ export const tripleliftAdapterSpec = { } } + if (bidderRequest && bidderRequest.uspConsent) { + tlCall = utils.tryAppendQueryString(tlCall, 'us_privacy', bidderRequest.uspConsent); + } + if (tlCall.lastIndexOf('&') === tlCall.length - 1) { tlCall = tlCall.substring(0, tlCall.length - 1); } @@ -62,7 +66,7 @@ export const tripleliftAdapterSpec = { }); }, - getUserSyncs: function(syncOptions) { + getUserSyncs: function(syncOptions, responses, gdprConsent, usPrivacy) { let syncType = _getSyncType(syncOptions); if (!syncType) return; @@ -78,6 +82,10 @@ export const tripleliftAdapterSpec = { syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'cmp_cs', consentString); } + if (typeof usPrivacy === 'string' && usPrivacy.length > 0) { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'us_privacy', usPrivacy); + } + return [{ type: syncType, url: syncEndpoint diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 76c549c98ab..17dd64b8deb 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -236,6 +236,12 @@ describe('triplelift adapter', function () { expect(url).to.match(new RegExp('(?:' + prebid.version + ')')) expect(url).to.match(/(?:referrer)/); }); + it('should return us_privacy param when CCPA info is available', function() { + bidderRequest.uspConsent = '1YYY'; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const url = request.url; + expect(url).to.match(/(\?|&)us_privacy=1YYY/); + }); it('should return schain when present', function() { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; @@ -401,5 +407,12 @@ describe('triplelift adapter', function () { expect(result[0].type).to.equal('iframe'); expect(result[0].url).to.equal(expectedIframeSyncUrl); }); + it('sends us_privacy param when info is available', function() { + let syncOptions = { + iframeEnabled: true + }; + let result = tripleliftAdapterSpec.getUserSyncs(syncOptions, null, null, '1YYY'); + expect(result[0].url).to.match(/(\?|&)us_privacy=1YYY/); + }); }); }); From 941e262eda0398c7a26893ac3e7261cb6979ea9d Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 17 Dec 2019 18:13:22 -0500 Subject: [PATCH 10/27] Simplify check for usPrivacy argument --- modules/tripleliftBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 30f1f147364..7120929059d 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -82,7 +82,7 @@ export const tripleliftAdapterSpec = { syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'cmp_cs', consentString); } - if (typeof usPrivacy === 'string' && usPrivacy.length > 0) { + if (usPrivacy) { syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'us_privacy', usPrivacy); } From 176460c264dba694ff1bc69ccc1679e2b7856d1c Mon Sep 17 00:00:00 2001 From: Kevin Zhou Date: Fri, 4 Sep 2020 12:33:05 -0400 Subject: [PATCH 11/27] put advertiser name in the bid.meta field if it exists --- modules/tripleliftBidAdapter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 967fa9fe596..9fe1bbfa1c4 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -235,13 +235,18 @@ function _buildResponseObject(bidderRequest, bid) { dealId: dealId, currency: 'USD', ttl: 300, - tl_source: bid.tl_source + tl_source: bid.tl_source, + meta: {} }; if (breq.mediaTypes.video) { bidResponse.vastXml = bid.ad; bidResponse.mediaType = 'video'; }; + + if (bid.advertiser_name) { + bidResponse.meta.advertiserName = bid.advertiser_name; + } }; return bidResponse; } From 61ebc4bdd1ef0b6d9a7b2a27c9193e26671386a7 Mon Sep 17 00:00:00 2001 From: Kevin Zhou Date: Fri, 4 Sep 2020 12:33:48 -0400 Subject: [PATCH 12/27] update unit tests with meta.advertiserName field --- test/spec/modules/tripleliftBidAdapter_spec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 218b504eb5e..5ab3bd45977 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -399,6 +399,7 @@ describe('triplelift adapter', function () { ad: 'ad-markup', iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg', tl_source: 'tlx', + advertiser_name: 'fake advertiser name' }, { imp_id: 1, @@ -472,6 +473,7 @@ describe('triplelift adapter', function () { currency: 'USD', ttl: 33, tl_source: 'tlx', + meta: {} }, { requestId: '30b31c1838de1e', @@ -487,6 +489,7 @@ describe('triplelift adapter', function () { tl_source: 'hdx', mediaType: 'video', vastXml: 'The Trade Desk', + meta: {} } ]; let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); @@ -499,6 +502,12 @@ describe('triplelift adapter', function () { let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); expect(result).to.have.length(2); }); + + it('should include the advertiser name in the meta field if available', function () { + let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); + expect(result[0].meta.advertiserName).to.equal('fake advertiser name') + expect(result[1].meta).to.not.have.key('advertiserName'); + }); }); describe('getUserSyncs', function() { From f0ba084bff2028fe095430a1691ae91d21dfd3d3 Mon Sep 17 00:00:00 2001 From: colbertk <50499465+colbertk@users.noreply.github.com> Date: Thu, 10 Sep 2020 13:09:18 -0400 Subject: [PATCH 13/27] Triplelift: FPD key value pair support (#5) * Triplelift: Add support for global fpd * don't filter fpd --- modules/tripleliftBidAdapter.js | 42 +++++++++++++++++-- .../spec/modules/tripleliftBidAdapter_spec.js | 31 ++++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 9fe1bbfa1c4..0c6cbb9b8cf 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -107,6 +107,8 @@ function _getSyncType(syncOptions) { function _buildPostBody(bidRequests) { let data = {}; let { schain } = bidRequests[0]; + const globalFpd = _getGlobalFpd(); + data.imp = bidRequests.map(function(bidRequest, index) { let imp = { id: index, @@ -133,10 +135,10 @@ function _buildPostBody(bidRequests) { }; } - if (schain) { - data.ext = { - schain - } + let ext = _getExt(schain, globalFpd); + + if (!utils.isEmpty(ext)) { + data.ext = ext; } return data; } @@ -168,6 +170,38 @@ function _getFloor (bid) { return floor !== null ? floor : bid.params.floor; } +function _getGlobalFpd() { + let fpd = {}; + const fpdContext = Object.assign({}, config.getConfig('fpd.context')); + const fpdUser = Object.assign({}, config.getConfig('fpd.user')); + + _addEntries(fpd, fpdContext); + _addEntries(fpd, fpdUser); + + return fpd; +} + +function _addEntries(target, source) { + if (!utils.isEmpty(source)) { + Object.keys(source).forEach(key => { + if (source[key] != null) { + target[key] = source[key]; + } + }); + } +} + +function _getExt(schain, fpd) { + let ext = {}; + if (!utils.isEmpty(schain)) { + ext.schain = { ...schain }; + } + if (!utils.isEmpty(fpd)) { + ext.fpd = { ...fpd }; + } + return ext; +} + function getUnifiedIdEids(bidRequests) { return getEids(bidRequests, 'tdid', 'adserver.org', 'TDID'); } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 5ab3bd45977..08c676dafa3 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -4,6 +4,7 @@ import { newBidder } from 'src/adapters/bidderFactory.js'; import { deepClone } from 'src/utils.js'; import { config } from 'src/config.js'; import prebid from '../../../package.json'; +import * as utils from 'src/utils.js'; const ENDPOINT = 'https://tlx.3lift.com/header/auction?'; const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY'; @@ -11,6 +12,7 @@ const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7V describe('triplelift adapter', function () { const adapter = newBidder(tripleliftAdapterSpec); let bid, instreamBid; + let sandbox; this.beforeEach(() => { bid = { @@ -194,6 +196,10 @@ describe('triplelift adapter', function () { gdprApplies: true }, }; + sandbox = sinon.sandbox.create(); + }); + afterEach(() => { + sandbox.restore(); }); it('exists and is an object', function () { @@ -383,6 +389,31 @@ describe('triplelift adapter', function () { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].floor).to.equal(1.99); }); + it('should send fpd on root level ext if kvps are available', function() { + const sens = null; + const category = ['news', 'weather', 'hurricane']; + const pmp_elig = 'true'; + const fpd = { + context: { + pmp_elig, + category, + }, + user: { + sens, + } + } + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + fpd + }; + return utils.deepAccess(config, key); + }); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const { data: payload } = request; + expect(payload.ext.fpd).to.not.haveOwnProperty('sens'); + expect(payload.ext.fpd).to.haveOwnProperty('category'); + expect(payload.ext.fpd).to.haveOwnProperty('pmp_elig'); + }); }); describe('interpretResponse', function () { From 373b4b4d9246420c3b6b22c025d18db721264988 Mon Sep 17 00:00:00 2001 From: colbertk Date: Thu, 10 Sep 2020 14:45:03 -0400 Subject: [PATCH 14/27] adds coppa support back in --- modules/tripleliftBidAdapter.js | 4 ++++ test/spec/modules/tripleliftBidAdapter_spec.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 0c6cbb9b8cf..b003de7785f 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -51,6 +51,10 @@ export const tripleliftAdapterSpec = { tlCall = utils.tryAppendQueryString(tlCall, 'us_privacy', bidderRequest.uspConsent); } + if (config.getConfig('coppa') === true) { + tlCall = utils.tryAppendQueryString(tlCall, 'coppa', true); + } + if (tlCall.lastIndexOf('&') === tlCall.length - 1) { tlCall = tlCall.substring(0, tlCall.length - 1); } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 08c676dafa3..797b3fab0c1 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -369,6 +369,20 @@ describe('triplelift adapter', function () { const url = request.url; expect(url).to.match(/(\?|&)us_privacy=1YYY/); }); + it('should return coppa param when COPPA config is set to true', function() { + sinon.stub(config, 'getConfig').withArgs('coppa').returns(true); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + config.getConfig.restore(); + const url = request.url; + expect(url).to.match(/(\?|&)coppa=true/); + }); + it('should not return coppa param when COPPA config is set to false', function() { + sinon.stub(config, 'getConfig').withArgs('coppa').returns(false); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + config.getConfig.restore(); + const url = request.url; + expect(url).not.to.match(/(\?|&)coppa=/); + }); it('should return schain when present', function() { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; From feb4f6273b11c1a59f4bdacfab0dd29b65e0bc9d Mon Sep 17 00:00:00 2001 From: Sy Dao Date: Mon, 26 Oct 2020 15:02:38 -0700 Subject: [PATCH 15/27] add gvlid, update validation method, add unit tests --- modules/tripleliftBidAdapter.js | 8 +- .../spec/modules/tripleliftBidAdapter_spec.js | 174 +++++++++++++++++- 2 files changed, 172 insertions(+), 10 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 77a313a0f55..04506e49758 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -3,20 +3,17 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import * as utils from '../src/utils.js'; import { config } from '../src/config.js'; +const GVLID = 28; const BIDDER_CODE = 'triplelift'; const STR_ENDPOINT = 'https://tlx.3lift.com/header/auction?'; let gdprApplies = true; let consentString = null; export const tripleliftAdapterSpec = { - + gvlid: GVLID, code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid: function (bid) { - if (bid.mediaTypes.video) { - let video = _getORTBVideo(bid); - if (!video.w || !video.h) return false; - } return typeof bid.params.inventoryCode !== 'undefined'; }, @@ -295,6 +292,7 @@ function _buildResponseObject(bidderRequest, bid) { if (bid.advertiser_name) { bidResponse.meta.advertiserName = bid.advertiser_name; + bidResponse.meta.advertiserDomains = [bid.advertiser_name]; } }; return bidResponse; diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 96cab3d837c..e2f4841feef 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -83,15 +83,21 @@ describe('triplelift adapter', function () { expect(tripleliftAdapterSpec.isBidRequestValid(instreamBid)).to.equal(true); }); + it('should return true when required params found - instream - 2', function () { + delete instreamBid.mediaTypes.playerSize; + delete instreamBid.params.video.w; + delete instreamBid.params.video.h; + // the only required param is inventoryCode + expect(tripleliftAdapterSpec.isBidRequestValid(instreamBid)).to.equal(true); + }); + it('should return false when required params are not passed', function () { delete bid.params.inventoryCode; expect(tripleliftAdapterSpec.isBidRequestValid(bid)).to.equal(false); }); it('should return false when required params are not passed - instream', function () { - delete instreamBid.mediaTypes.playerSize; - delete instreamBid.params.video.w; - delete instreamBid.params.video.h; + delete instreamBid.params.inventoryCode; expect(tripleliftAdapterSpec.isBidRequestValid(instreamBid)).to.equal(false); }); }); @@ -165,6 +171,138 @@ describe('triplelift adapter', function () { userId: {}, schain, }, + // banner and outstream video + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480] + }, + banner: { + sizes: [ + [970, 250], + [1, 1] + ] + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // banner and incomplete video + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + + }, + banner: { + sizes: [ + [970, 250], + [1, 1] + ] + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // incomplete banner and incomplete video + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + + }, + banner: { + + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // banner and instream video + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480] + }, + banner: { + sizes: [ + [970, 250], + [1, 1] + ] + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // banner and outream video and native { bidder: 'triplelift', params: { @@ -188,6 +326,9 @@ describe('triplelift adapter', function () { [970, 250], [1, 1] ] + }, + native: { + } }, adUnitCode: 'adunit-code-instream', @@ -261,10 +402,26 @@ describe('triplelift adapter', function () { expect(payload.imp[1].tagid).to.equal('insteam_test'); expect(payload.imp[1].floor).to.equal(1.0); expect(payload.imp[1].video).to.exist.and.to.be.a('object'); - + // banner and outstream video expect(payload.imp[2]).to.not.have.property('video'); expect(payload.imp[2]).to.have.property('banner'); expect(payload.imp[2].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + // banner and incomplete video + expect(payload.imp[3]).to.not.have.property('video'); + expect(payload.imp[3]).to.have.property('banner'); + expect(payload.imp[3].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + // incomplete mediatypes.banner and incomplete video + expect(payload.imp[4]).to.not.have.property('video'); + expect(payload.imp[4]).to.have.property('banner'); + expect(payload.imp[4].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + // banner and instream video + expect(payload.imp[5]).to.not.have.property('banner'); + expect(payload.imp[5]).to.have.property('video'); + expect(payload.imp[5].video).to.exist.and.to.be.a('object'); + // banner and outream video and native + expect(payload.imp[6]).to.not.have.property('video'); + expect(payload.imp[6]).to.have.property('banner'); + expect(payload.imp[6].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); }); it('should add tdid to the payload if included', function () { @@ -587,9 +744,16 @@ describe('triplelift adapter', function () { it('should include the advertiser name in the meta field if available', function () { let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); - expect(result[0].meta.advertiserName).to.equal('fake advertiser name') + expect(result[0].meta.advertiserName).to.equal('fake advertiser name'); expect(result[1].meta).to.not.have.key('advertiserName'); }); + + it('should include the advertiser domain in the meta field if available', function () { + let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); + expect(result[0].meta.advertiserDomains[0]).to.equal('fake advertiser name'); + expect(result[0].meta.advertiserDomains.length).to.equal(1); + expect(result[1].meta).to.not.have.key('advertiserDomains'); + }); }); describe('getUserSyncs', function() { From ce9845bdc203c392f8102407879372b92b99451c Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Tue, 27 Oct 2020 11:08:26 -0400 Subject: [PATCH 16/27] remove advertiserDomains logic --- modules/tripleliftBidAdapter.js | 1 - test/spec/modules/tripleliftBidAdapter_spec.js | 8 -------- 2 files changed, 9 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 04506e49758..e4cd40a868b 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -292,7 +292,6 @@ function _buildResponseObject(bidderRequest, bid) { if (bid.advertiser_name) { bidResponse.meta.advertiserName = bid.advertiser_name; - bidResponse.meta.advertiserDomains = [bid.advertiser_name]; } }; return bidResponse; diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index e2f4841feef..d335589a4f5 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -748,14 +748,6 @@ describe('triplelift adapter', function () { expect(result[1].meta).to.not.have.key('advertiserName'); }); - it('should include the advertiser domain in the meta field if available', function () { - let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); - expect(result[0].meta.advertiserDomains[0]).to.equal('fake advertiser name'); - expect(result[0].meta.advertiserDomains.length).to.equal(1); - expect(result[1].meta).to.not.have.key('advertiserDomains'); - }); - }); - 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 + '&'; From 633ea112e3182532769260d1f6a29681a5599939 Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Tue, 27 Oct 2020 11:10:46 -0400 Subject: [PATCH 17/27] typo --- test/spec/modules/tripleliftBidAdapter_spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index d335589a4f5..f01949755c7 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -747,6 +747,7 @@ describe('triplelift adapter', function () { expect(result[0].meta.advertiserName).to.equal('fake advertiser name'); expect(result[1].meta).to.not.have.key('advertiserName'); }); + }); describe('getUserSyncs', function() { let expectedIframeSyncUrl = 'https://eb2.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&'; From a9c63eefda80829b5fede7e0139a90e6f4f7f24d Mon Sep 17 00:00:00 2001 From: Sy Dao Date: Mon, 2 Nov 2020 14:38:23 -0800 Subject: [PATCH 18/27] update _buildResponseObject to use new instream validation --- modules/tripleliftBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 04506e49758..14ab758d9df 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -285,7 +285,7 @@ function _buildResponseObject(bidderRequest, bid) { meta: {} }; - if (breq.mediaTypes.video) { + if (_isInstreamBidRequest(breq)) { bidResponse.vastXml = bid.ad; bidResponse.mediaType = 'video'; }; From 0a700ffffc10bf42f8e46191dd8d937041eb26f5 Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Mon, 16 Nov 2020 18:26:55 -0500 Subject: [PATCH 19/27] add advertiserDomains support --- modules/tripleliftBidAdapter.js | 4 ++++ test/spec/modules/tripleliftBidAdapter_spec.js | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 69c52711236..d54d76efb41 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -293,6 +293,10 @@ function _buildResponseObject(bidderRequest, bid) { if (bid.advertiser_name) { bidResponse.meta.advertiserName = bid.advertiser_name; } + + if (bid.adomain && bid.adomain.length) { + bidResponse.meta.advertiserDomains = bid.adomain; + } }; return bidResponse; } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index f01949755c7..b417876f276 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -638,7 +638,8 @@ describe('triplelift adapter', function () { ad: 'ad-markup', iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg', tl_source: 'tlx', - advertiser_name: 'fake advertiser name' + advertiser_name: 'fake advertiser name', + adomain: ['basspro.com', 'internetalerts.org'] }, { imp_id: 1, @@ -747,6 +748,13 @@ describe('triplelift adapter', function () { expect(result[0].meta.advertiserName).to.equal('fake advertiser name'); expect(result[1].meta).to.not.have.key('advertiserName'); }); + + it('should include the advertiser domain array in the meta field if available', function () { + let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); + expect(result[0].meta.advertiserDomains[0]).to.equal('basspro.com'); + expect(result[0].meta.advertiserDomains[1]).to.equal('internetalerts.org'); + expect(result[1].meta).to.not.have.key('advertiserDomains'); + }); }); describe('getUserSyncs', function() { From 7096e4a2376e96a10bf4a0c3b86887f082704284 Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Tue, 24 Nov 2020 12:47:39 -0500 Subject: [PATCH 20/27] follow spec to parse fpd --- modules/tripleliftBidAdapter.js | 13 +++++++++++-- test/spec/modules/tripleliftBidAdapter_spec.js | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index d54d76efb41..388b5c2e8a3 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -184,12 +184,21 @@ function _getFloor (bid) { function _getGlobalFpd() { let fpd = {}; + let context = {} + let user = {}; + const fpdContext = Object.assign({}, config.getConfig('fpd.context')); const fpdUser = Object.assign({}, config.getConfig('fpd.user')); - _addEntries(fpd, fpdContext); - _addEntries(fpd, fpdUser); + _addEntries(context, fpdContext); + _addEntries(user, fpdUser); + if (!utils.isEmpty(context)) { + fpd.context = context; + } + if (!utils.isEmpty(user)) { + fpd.user = user; + } return fpd; } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index b417876f276..df33ad3ef11 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -618,9 +618,9 @@ describe('triplelift adapter', function () { }); const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; - expect(payload.ext.fpd).to.not.haveOwnProperty('sens'); - expect(payload.ext.fpd).to.haveOwnProperty('category'); - expect(payload.ext.fpd).to.haveOwnProperty('pmp_elig'); + expect(payload.ext.fpd.user).to.not.exist; + expect(payload.ext.fpd.context).to.haveOwnProperty('category'); + expect(payload.ext.fpd.context).to.haveOwnProperty('pmp_elig'); }); }); From f202f4c32ad0f91b8061880aba28477dd6192a2d Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Tue, 24 Nov 2020 18:01:19 -0500 Subject: [PATCH 21/27] ad unit support stub --- modules/tripleliftBidAdapter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 388b5c2e8a3..a250c2a46db 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -114,7 +114,8 @@ function _buildPostBody(bidRequests) { let imp = { id: index, tagid: bidRequest.params.inventoryCode, - floor: _getFloor(bidRequest) + floor: _getFloor(bidRequest), + fpd: _getAdUnitFpd(bidRequest) }; // remove the else to support multi-imp if (_isInstreamBidRequest(bidRequest)) { @@ -202,6 +203,11 @@ function _getGlobalFpd() { return fpd; } +function _getAdUnitFpd(bid) { + let fpd = {}; + return fpd; +} + function _addEntries(target, source) { if (!utils.isEmpty(source)) { Object.keys(source).forEach(key => { From 4e417a297052f0c2ea64cdaee0de9e35beb4a363 Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Tue, 24 Nov 2020 18:25:22 -0500 Subject: [PATCH 22/27] adunit method --- modules/tripleliftBidAdapter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index a250c2a46db..2f9231504ed 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -204,8 +204,10 @@ function _getGlobalFpd() { } function _getAdUnitFpd(bid) { - let fpd = {}; - return fpd; + if (!utils.isEmpty(bid.fpd)) { + return bid.fpd; + } + return null; } function _addEntries(target, source) { From de66901fa778692e1dfcaffcc1d9bd440b0fa751 Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Wed, 25 Nov 2020 11:43:32 -0500 Subject: [PATCH 23/27] ad unit etc --- modules/tripleliftBidAdapter.js | 20 +++++++++++++------ .../spec/modules/tripleliftBidAdapter_spec.js | 17 +++++++++++++++- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 2f9231504ed..64685f7f051 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -114,8 +114,7 @@ function _buildPostBody(bidRequests) { let imp = { id: index, tagid: bidRequest.params.inventoryCode, - floor: _getFloor(bidRequest), - fpd: _getAdUnitFpd(bidRequest) + floor: _getFloor(bidRequest) }; // remove the else to support multi-imp if (_isInstreamBidRequest(bidRequest)) { @@ -123,6 +122,9 @@ function _buildPostBody(bidRequests) { } else if (bidRequest.mediaTypes.banner) { imp.banner = { format: _sizes(bidRequest.sizes) }; }; + if (!utils.isEmpty(bidRequest.fpd)) { + imp.fpd = _getAdUnitFpd(bidRequest.fpd); + } return imp; }); @@ -203,11 +205,17 @@ function _getGlobalFpd() { return fpd; } -function _getAdUnitFpd(bid) { - if (!utils.isEmpty(bid.fpd)) { - return bid.fpd; +function _getAdUnitFpd(adUnitFpd) { + let fpd = {}; + let context = {}; + + _addEntries(context, adUnitFpd.context); + + if (!utils.isEmpty(context)) { + fpd.context = context; } - return null; + + return fpd; } function _addEntries(target, source) { diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index df33ad3ef11..87a5590686f 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -143,6 +143,14 @@ describe('triplelift adapter', function () { auctionId: '1d1a030790a475', userId: {}, schain, + fpd: { + context: { + pbAdSlot: 'homepage-top-rect', + data: { + adUnitSpecificAttribute: 123 + } + } + } }, { bidder: 'triplelift', @@ -597,7 +605,7 @@ describe('triplelift adapter', function () { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].floor).to.equal(1.99); }); - it('should send fpd on root level ext if kvps are available', function() { + it('should send global config fpd if kvps are available', function() { const sens = null; const category = ['news', 'weather', 'hurricane']; const pmp_elig = 'true'; @@ -622,6 +630,13 @@ describe('triplelift adapter', function () { expect(payload.ext.fpd.context).to.haveOwnProperty('category'); expect(payload.ext.fpd.context).to.haveOwnProperty('pmp_elig'); }); + it.only('should send ad unit fpd if kvps are available', function() { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[0].fpd.context).to.haveOwnProperty('pbAdSlot'); + expect(request.data.imp[0].fpd.context).to.haveOwnProperty('data'); + expect(request.data.imp[0].fpd.context.data).to.haveOwnProperty('adUnitSpecificAttribute'); + expect(request.data.imp[1].fpd).to.not.exist; + }); }); describe('interpretResponse', function () { From f1758396abced85c765902c879a510810b798e99 Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Wed, 25 Nov 2020 11:47:15 -0500 Subject: [PATCH 24/27] typo --- test/spec/modules/tripleliftBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 87a5590686f..8aa96336610 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -630,7 +630,7 @@ describe('triplelift adapter', function () { expect(payload.ext.fpd.context).to.haveOwnProperty('category'); expect(payload.ext.fpd.context).to.haveOwnProperty('pmp_elig'); }); - it.only('should send ad unit fpd if kvps are available', function() { + it('should send ad unit fpd if kvps are available', function() { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].fpd.context).to.haveOwnProperty('pbAdSlot'); expect(request.data.imp[0].fpd.context).to.haveOwnProperty('data'); From fe09847541d19e72f9dcd96d2a259f6dc4b3d8b1 Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Wed, 25 Nov 2020 13:11:27 -0500 Subject: [PATCH 25/27] fix test --- test/spec/modules/tripleliftBidAdapter_spec.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 8aa96336610..3f36123a55b 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -605,17 +605,19 @@ describe('triplelift adapter', function () { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].floor).to.equal(1.99); }); - it('should send global config fpd if kvps are available', function() { + it.only('should send global config fpd if kvps are available', function() { const sens = null; const category = ['news', 'weather', 'hurricane']; const pmp_elig = 'true'; const fpd = { context: { - pmp_elig, - category, + pmp_elig: pmp_elig, + data: { + category: category + } }, user: { - sens, + sens: sens, } } sandbox.stub(config, 'getConfig').callsFake(key => { @@ -627,7 +629,7 @@ describe('triplelift adapter', function () { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; expect(payload.ext.fpd.user).to.not.exist; - expect(payload.ext.fpd.context).to.haveOwnProperty('category'); + expect(payload.ext.fpd.context.data).to.haveOwnProperty('category'); expect(payload.ext.fpd.context).to.haveOwnProperty('pmp_elig'); }); it('should send ad unit fpd if kvps are available', function() { From 9fe0ffc83f2f9229defebe9fb1fb9eb54ff47c83 Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Wed, 25 Nov 2020 13:11:57 -0500 Subject: [PATCH 26/27] typo --- test/spec/modules/tripleliftBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 3f36123a55b..82578424027 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -605,7 +605,7 @@ describe('triplelift adapter', function () { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].floor).to.equal(1.99); }); - it.only('should send global config fpd if kvps are available', function() { + it('should send global config fpd if kvps are available', function() { const sens = null; const category = ['news', 'weather', 'hurricane']; const pmp_elig = 'true'; From cf75abacd1194bff66c7f29ecdfa85deacf19cce Mon Sep 17 00:00:00 2001 From: Brandon Ling Date: Tue, 1 Dec 2020 13:11:25 -0500 Subject: [PATCH 27/27] change to const --- modules/tripleliftBidAdapter.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 64685f7f051..4679c1faf62 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -186,9 +186,9 @@ function _getFloor (bid) { } function _getGlobalFpd() { - let fpd = {}; - let context = {} - let user = {}; + const fpd = {}; + const context = {} + const user = {}; const fpdContext = Object.assign({}, config.getConfig('fpd.context')); const fpdUser = Object.assign({}, config.getConfig('fpd.user')); @@ -206,8 +206,8 @@ function _getGlobalFpd() { } function _getAdUnitFpd(adUnitFpd) { - let fpd = {}; - let context = {}; + const fpd = {}; + const context = {}; _addEntries(context, adUnitFpd.context);