Skip to content

Commit 0bd72ab

Browse files
colbertkwillchapindavidwoodsandersenBrandon LingKevin Zhou
authored
Triplelift: fpd and advertiser name support (prebid#5731)
* 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 * Add CCPA query param * Simplify check for usPrivacy argument * put advertiser name in the bid.meta field if it exists * update unit tests with meta.advertiserName field * Triplelift: FPD key value pair support (#5) * Triplelift: Add support for global fpd * don't filter fpd * adds coppa support back in Co-authored-by: Will Chapin <[email protected]> Co-authored-by: David Andersen <[email protected]> Co-authored-by: Brandon Ling <[email protected]> Co-authored-by: Kevin Zhou <[email protected]> Co-authored-by: kzhouTL <[email protected]>
1 parent fd38cff commit 0bd72ab

File tree

2 files changed

+84
-5
lines changed

2 files changed

+84
-5
lines changed

modules/tripleliftBidAdapter.js

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ function _getSyncType(syncOptions) {
111111
function _buildPostBody(bidRequests) {
112112
let data = {};
113113
let { schain } = bidRequests[0];
114+
const globalFpd = _getGlobalFpd();
115+
114116
data.imp = bidRequests.map(function(bidRequest, index) {
115117
let imp = {
116118
id: index,
@@ -137,10 +139,10 @@ function _buildPostBody(bidRequests) {
137139
};
138140
}
139141

140-
if (schain) {
141-
data.ext = {
142-
schain
143-
}
142+
let ext = _getExt(schain, globalFpd);
143+
144+
if (!utils.isEmpty(ext)) {
145+
data.ext = ext;
144146
}
145147
return data;
146148
}
@@ -172,6 +174,38 @@ function _getFloor (bid) {
172174
return floor !== null ? floor : bid.params.floor;
173175
}
174176

177+
function _getGlobalFpd() {
178+
let fpd = {};
179+
const fpdContext = Object.assign({}, config.getConfig('fpd.context'));
180+
const fpdUser = Object.assign({}, config.getConfig('fpd.user'));
181+
182+
_addEntries(fpd, fpdContext);
183+
_addEntries(fpd, fpdUser);
184+
185+
return fpd;
186+
}
187+
188+
function _addEntries(target, source) {
189+
if (!utils.isEmpty(source)) {
190+
Object.keys(source).forEach(key => {
191+
if (source[key] != null) {
192+
target[key] = source[key];
193+
}
194+
});
195+
}
196+
}
197+
198+
function _getExt(schain, fpd) {
199+
let ext = {};
200+
if (!utils.isEmpty(schain)) {
201+
ext.schain = { ...schain };
202+
}
203+
if (!utils.isEmpty(fpd)) {
204+
ext.fpd = { ...fpd };
205+
}
206+
return ext;
207+
}
208+
175209
function getUnifiedIdEids(bidRequests) {
176210
return getEids(bidRequests, 'tdid', 'adserver.org', 'TDID');
177211
}
@@ -239,13 +273,18 @@ function _buildResponseObject(bidderRequest, bid) {
239273
dealId: dealId,
240274
currency: 'USD',
241275
ttl: 300,
242-
tl_source: bid.tl_source
276+
tl_source: bid.tl_source,
277+
meta: {}
243278
};
244279

245280
if (breq.mediaTypes.video) {
246281
bidResponse.vastXml = bid.ad;
247282
bidResponse.mediaType = 'video';
248283
};
284+
285+
if (bid.advertiser_name) {
286+
bidResponse.meta.advertiserName = bid.advertiser_name;
287+
}
249288
};
250289
return bidResponse;
251290
}

test/spec/modules/tripleliftBidAdapter_spec.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { newBidder } from 'src/adapters/bidderFactory.js';
44
import { deepClone } from 'src/utils.js';
55
import { config } from 'src/config.js';
66
import prebid from '../../../package.json';
7+
import * as utils from 'src/utils.js';
78

89
const ENDPOINT = 'https://tlx.3lift.com/header/auction?';
910
const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY';
1011

1112
describe('triplelift adapter', function () {
1213
const adapter = newBidder(tripleliftAdapterSpec);
1314
let bid, instreamBid;
15+
let sandbox;
1416

1517
this.beforeEach(() => {
1618
bid = {
@@ -194,6 +196,10 @@ describe('triplelift adapter', function () {
194196
gdprApplies: true
195197
},
196198
};
199+
sandbox = sinon.sandbox.create();
200+
});
201+
afterEach(() => {
202+
sandbox.restore();
197203
});
198204

199205
it('exists and is an object', function () {
@@ -397,6 +403,31 @@ describe('triplelift adapter', function () {
397403
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
398404
expect(request.data.imp[0].floor).to.equal(1.99);
399405
});
406+
it('should send fpd on root level ext if kvps are available', function() {
407+
const sens = null;
408+
const category = ['news', 'weather', 'hurricane'];
409+
const pmp_elig = 'true';
410+
const fpd = {
411+
context: {
412+
pmp_elig,
413+
category,
414+
},
415+
user: {
416+
sens,
417+
}
418+
}
419+
sandbox.stub(config, 'getConfig').callsFake(key => {
420+
const config = {
421+
fpd
422+
};
423+
return utils.deepAccess(config, key);
424+
});
425+
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
426+
const { data: payload } = request;
427+
expect(payload.ext.fpd).to.not.haveOwnProperty('sens');
428+
expect(payload.ext.fpd).to.haveOwnProperty('category');
429+
expect(payload.ext.fpd).to.haveOwnProperty('pmp_elig');
430+
});
400431
});
401432

402433
describe('interpretResponse', function () {
@@ -413,6 +444,7 @@ describe('triplelift adapter', function () {
413444
ad: 'ad-markup',
414445
iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg',
415446
tl_source: 'tlx',
447+
advertiser_name: 'fake advertiser name'
416448
},
417449
{
418450
imp_id: 1,
@@ -486,6 +518,7 @@ describe('triplelift adapter', function () {
486518
currency: 'USD',
487519
ttl: 33,
488520
tl_source: 'tlx',
521+
meta: {}
489522
},
490523
{
491524
requestId: '30b31c1838de1e',
@@ -501,6 +534,7 @@ describe('triplelift adapter', function () {
501534
tl_source: 'hdx',
502535
mediaType: 'video',
503536
vastXml: '<VAST version=\"2.0\"><Ad id=\"gsen95th\"><Wrapper><Error><![CDATA[https://eb2.3lift.net/ive?aid=156025986241697082890&bmid=10092&bsid=76480&crid=10092_76480_i2j6qm8u&e=[ERRORCODE]]]></Error><Impression><![CDATA[https://eb2.3lift.net/r?rr=creative&bc=0.011&uid=8217096503606905723&pr=%24%7BAUCTION_PRICE%7D&brid=554350&bmid=10092&biid=10066&aid=156025986241697082890&bcud=11&sid=76480&ts=1593552049&fid=11]]></Impression><Impression><![CDATA[https://tlx.3lift.net/header/notify?px=1&pr=${AUCTION_PRICE}&ts=1593552049&aid=156025986241697082890&ec=10092_76480_i2j6qm8u&n=GgDyAqABCAASFTE1NjAyNTk4NjI0MTY5NzA4Mjg5MBgAIAEo7E4wwNUEQAFIAFAAYAtogIAEcO7qIZABAJgBAKgBALABC7gBAMABCsgBC%2BABCvABAPgBlo0GgAL%2FlwWIAgqRAgAAAAAAAPA%2FmQIzMzMzMzPDP6ECAAAAAAAAAACoAgCwAgDIAgTYAgDxAmZmZmZmZuY%2F%2BALSTpADAJgDAKADAKgDA%2FgCDIgDAJIDBDEyMzQ%3D]]></Impression><AdSystem version=\"1.0\">The Trade Desk</AdSystem><VASTAdTagURI><![CDATA[https://insight.adsrvr.org/enduser/vast/?iid=590299b9-1817-4859-a2af-ef007bb4c78e&crid=gsen95th&wp=0.011&aid=1&wpc=USD&sfe=10fba14e&puid=&tdid=&pid=13hzg59&ag=l2w0772&adv=ct0nqrx&sig=1BGM_YxB0HAcl-s55S_NKIu-oLW94YpTn_DjMRmdWHzs.&bp=0.3&cf=1448159&fq=0&td_s=388389451&rcats=&mcat=&mste=&mfld=2&mssi=None&mfsi=ve35dsnkwp&uhow=75&agsa=&rgco=South%20Korea&rgre=Gyeonggi-do&rgme=&rgci=Ansan-si&rgz=15345&svbttd=1&dt=Mobile&osf=iOS&os=iOS134&br=WebView&rlangs=01&mlang=&svpid=7453-EB&did=&rcxt=InApp&lat=37.324400&lon=126.823700&tmpc=9.66&daid=d7804da7-147b-421d-bb44-60ad3ac32681&vp=0&osi=&osv=&svscid=388389451&bffi=41&mk=Apple&mdl=iPhone&vpb=PreRoll&dc=14&vcc=EDwYPDICCAI6BAgBCAJAAUgBUASIAQKgAZ4DqAGwBsgBAdABA-gBAoACA4oCCAgCCAMIBQgGmgIICAMIBQgGCAegAgKoAgGwAgC4AgDAAgE.&sv=triplelift&pidi=3584&advi=270782&cmpi=1319400&agi=6167705&cridi=13268739&svi=70&cmp=a9nj9ex&tsig=tlN4j1OujX9nrFakJmfpTuNNfg-D0qArlSjjNAb8tLg.&c=MAQ4AEgAUAc.&dur=&crrelr=&adpt=tl_ltriplelift&ipl=39250&fpa=826&pcm=3&said=40286845772363793660&ict=Unknown&auct=1&im=1]]></VASTAdTagURI><Creatives><Creative><Linear><VideoClicks><ClickTracking><![CDATA[https://eb2.3lift.net/ec?aid=156025986241697082890]]></ClickTracking></VideoClicks><TrackingEvents><Tracking event=\"mute\"><![CDATA[https://eb2.3lift.net/eee?aid=156025986241697082890&inv_code=niice_main_instream&ev=1&eid=5]]></Tracking><Tracking event=\"unmute\"><![CDATA[https://eb2.3lift.net/eee?aid=156025986241697082890&inv_code=niice_main_instream&ev=1&eid=6]]></Tracking><Tracking event=\"expand\"><![CDATA[https://eb2.3lift.net/eee?aid=156025986241697082890&inv_code=niice_main_instream&ev=1&eid=7]]></Tracking><Tracking event=\"collapse\"><![CDATA[https://eb2.3lift.net/eee?aid=156025986241697082890&inv_code=niice_main_instream&ev=1&eid=8]]></Tracking><Tracking event=\"pause\"><![CDATA[https://eb2.3lift.net/eee?aid=156025986241697082890&inv_code=niice_main_instream&ev=1&eid=14]]></Tracking><Tracking event=\"resume\"><![CDATA[https://eb2.3lift.net/eee?aid=156025986241697082890&inv_code=niice_main_instream&ev=1&eid=15]]></Tracking><Tracking event=\"fullscreen\"><![CDATA[https://eb2.3lift.net/eee?aid=156025986241697082890&inv_code=niice_main_instream&ev=1&eid=16]]></Tracking><Tracking event=\"exitFullscreen\"><![CDATA[https://eb2.3lift.net/eee?aid=156025986241697082890&inv_code=niice_main_instream&ev=1&eid=17]]></Tracking><Tracking event=\"skip\"><![CDATA[https://eb2.3lift.net/eee?aid=156025986241697082890&inv_code=niice_main_instream&ev=1&eid=18]]></Tracking><Tracking event=\"start\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&progress=7]]></Tracking><Tracking event=\"firstQuartile\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&quartile=1]]></Tracking><Tracking event=\"midpoint\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&quartile=2]]></Tracking><Tracking event=\"thirdQuartile\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&quartile=3]]></Tracking><Tracking event=\"complete\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&quartile=4]]></Tracking><Tracking event=\"progress\" offset=\"00:00:02\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&progress=1]]></Tracking><Tracking event=\"progress\" offset=\"00:00:03\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&progress=2]]></Tracking><Tracking event=\"progress\" offset=\"00:00:05\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&progress=3]]></Tracking><Tracking event=\"progress\" offset=\"00:00:10\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&progress=4]]></Tracking><Tracking event=\"progress\" offset=\"00:00:15\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&progress=5]]></Tracking><Tracking event=\"progress\" offset=\"00:00:30\"><![CDATA[https://eb2.3lift.net/evd?aid=156025986241697082890&inv_code=niice_main_instream&bmid=10092&vlt=2&bypassDuration=true&progress=6]]></Tracking></TrackingEvents></Linear></Creative></Creatives></Wrapper></Ad></VAST>',
537+
meta: {}
504538
}
505539
];
506540
let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});
@@ -513,6 +547,12 @@ describe('triplelift adapter', function () {
513547
let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});
514548
expect(result).to.have.length(2);
515549
});
550+
551+
it('should include the advertiser name in the meta field if available', function () {
552+
let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});
553+
expect(result[0].meta.advertiserName).to.equal('fake advertiser name')
554+
expect(result[1].meta).to.not.have.key('advertiserName');
555+
});
516556
});
517557

518558
describe('getUserSyncs', function() {

0 commit comments

Comments
 (0)