Skip to content

Commit

Permalink
Triplelift: fpd and advertiser name support (prebid#5731)
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

* 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 <wrchapin@gmail.com>
Co-authored-by: David Andersen <davidwoodsandersen@gmail.com>
Co-authored-by: Brandon Ling <bling@triplelift.com>
Co-authored-by: Kevin Zhou <kzhou@triplelift.com>
Co-authored-by: kzhouTL <43545828+kzhouTL@users.noreply.github.com>
  • Loading branch information
6 people authored Sep 14, 2020
1 parent fd38cff commit 0bd72ab
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 5 deletions.
49 changes: 44 additions & 5 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,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,
Expand All @@ -137,10 +139,10 @@ function _buildPostBody(bidRequests) {
};
}

if (schain) {
data.ext = {
schain
}
let ext = _getExt(schain, globalFpd);

if (!utils.isEmpty(ext)) {
data.ext = ext;
}
return data;
}
Expand Down Expand Up @@ -172,6 +174,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');
}
Expand Down Expand Up @@ -239,13 +273,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;
}
Expand Down
40 changes: 40 additions & 0 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ 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';

describe('triplelift adapter', function () {
const adapter = newBidder(tripleliftAdapterSpec);
let bid, instreamBid;
let sandbox;

this.beforeEach(() => {
bid = {
Expand Down Expand Up @@ -194,6 +196,10 @@ describe('triplelift adapter', function () {
gdprApplies: true
},
};
sandbox = sinon.sandbox.create();
});
afterEach(() => {
sandbox.restore();
});

it('exists and is an object', function () {
Expand Down Expand Up @@ -397,6 +403,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 () {
Expand All @@ -413,6 +444,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,
Expand Down Expand Up @@ -486,6 +518,7 @@ describe('triplelift adapter', function () {
currency: 'USD',
ttl: 33,
tl_source: 'tlx',
meta: {}
},
{
requestId: '30b31c1838de1e',
Expand All @@ -501,6 +534,7 @@ describe('triplelift adapter', function () {
tl_source: 'hdx',
mediaType: 'video',
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>',
meta: {}
}
];
let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});
Expand All @@ -513,6 +547,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() {
Expand Down

0 comments on commit 0bd72ab

Please sign in to comment.