Skip to content

Commit

Permalink
Ttd Bid adapter: support for transaction id, bcat, and consolidate pa…
Browse files Browse the repository at this point in the history
…rams (prebid#8679)

* remove siteId parameter
make placementId parameter optional if GPID is passed
pass transactionId through to source.tid
read bcat from ortb2

* enforce check for gpid or placementId

* add error message

* Support badv/battr, get tid from ext object

* Address review feedback

Co-authored-by: Minh Daole <minh.daole@thetradedesk.com>
  • Loading branch information
2 people authored and JacobKlein26 committed Feb 8, 2023
1 parent 5fe9cf3 commit 6ff8cb8
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 68 deletions.
63 changes: 39 additions & 24 deletions modules/ttdBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createEidsArray } from './userId/eids.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

const BIDADAPTERVERSION = 'TTD-PREBID-2022.02.18';
const BIDADAPTERVERSION = 'TTD-PREBID-2022.06.28';
const BIDDER_CODE = 'ttd';
const BIDDER_CODE_LONG = 'thetradedesk';
const BIDDER_ENDPOINT = 'https://direct.adsrvr.org/bid/bidder/';
Expand Down Expand Up @@ -58,7 +58,9 @@ function getBidFloor(bid) {
}

function getSource(validBidRequests) {
let source = {};
let source = {
tid: validBidRequests[0].transactionId
};
if (validBidRequests[0].schain) {
utils.deepSetValue(source, 'ext.schain', validBidRequests[0].schain);
}
Expand Down Expand Up @@ -124,7 +126,6 @@ function getUser(bidderRequest) {

function getSite(bidderRequest, firstPartyData) {
var site = {
id: utils.deepAccess(bidderRequest, 'bids.0.params.siteId'),
page: utils.deepAccess(bidderRequest, 'refererInfo.page'),
publisher: {
id: utils.deepAccess(bidderRequest, 'bids.0.params.publisherId'),
Expand All @@ -141,15 +142,20 @@ function getSite(bidderRequest, firstPartyData) {

function getImpression(bidRequest) {
let impression = {
id: bidRequest.bidId,
tagid: bidRequest.params.placementId
id: bidRequest.bidId
};

let gpid = utils.deepAccess(bidRequest, 'ortb2Imp.ext.gpid');
if (gpid) {
impression.ext = {
gpid: gpid
}
const gpid = utils.deepAccess(bidRequest, 'ortb2Imp.ext.gpid');
const tid = utils.deepAccess(bidRequest, 'ortb2Imp.ext.tid');
if (gpid || tid) {
impression.ext = {}
if (gpid) { impression.ext.gpid = gpid }
if (tid) { impression.ext.tid = tid }
}

const tagid = gpid || bidRequest.params.placementId;
if (tagid) {
impression.tagid = tagid
}

const mediaTypesVideo = utils.deepAccess(bidRequest, 'mediaTypes.video');
Expand Down Expand Up @@ -212,6 +218,12 @@ function banner(bid) {
format: sizes,
},
optionalParams);

const battr = utils.deepAccess(bid, 'ortb2Imp.battr');
if (battr) {
banner.battr = battr
}

return banner;
}

Expand Down Expand Up @@ -279,6 +291,11 @@ function video(bid) {
video.maxbitrate = maxbitrate;
}

const battr = utils.deepAccess(bid, 'ortb2Imp.battr');
if (battr) {
video.battr = battr
}

return video;
}

Expand Down Expand Up @@ -318,20 +335,10 @@ export const spec = {
utils.logWarn(BIDDER_CODE + ': params.publisherId must be 32 characters or less');
return false;
}
if (!bid.params.siteId) {
utils.logWarn(BIDDER_CODE + ': Missing required parameter params.siteId');
return false;
}
if (bid.params.siteId.length > 50) {
utils.logWarn(BIDDER_CODE + ': params.siteId must be 50 characters or less');
return false;
}
if (!bid.params.placementId) {
utils.logWarn(BIDDER_CODE + ': Missing required parameter params.placementId');
return false;
}
if (bid.params.placementId.length > 128) {
utils.logWarn(BIDDER_CODE + ': params.placementId must be 128 characters or less');

const gpid = utils.deepAccess(bid, 'ortb2Imp.ext.gpid');
if (!bid.params.placementId && !gpid) {
utils.logWarn(BIDDER_CODE + ': one of params.placementId or gpid (via the GPT module https://docs.prebid.org/dev-docs/modules/gpt-pre-auction.html) must be passed');
return false;
}

Expand Down Expand Up @@ -387,6 +394,14 @@ export const spec = {
ext: getExt(firstPartyData)
}

if (firstPartyData && firstPartyData.bcat) {
topLevel.bcat = firstPartyData.bcat;
}

if (firstPartyData && firstPartyData.badv) {
topLevel.badv = firstPartyData.badv;
}

let url = BIDDER_ENDPOINT + bidderRequest.bids[0].params.supplySourceId;

let serverRequest = {
Expand Down
14 changes: 4 additions & 10 deletions modules/ttdBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ The Trade Desk bid adapter supports Banner and Video.
bidder: 'ttd',
params: {
supplySourceId: 'supplier',
publisherId: '1427ab10f2e448057ed3b422',
siteId: 'site-123',
placementId: 'footer1'
publisherId: '1427ab10f2e448057ed3b422'
}
}
]
Expand All @@ -51,8 +49,7 @@ The Trade Desk bid adapter supports Banner and Video.
params: {
supplySourceId: 'supplier',
publisherId: '1427ab10f2e448057ed3b422',
siteId: 'site-123',
placementId: 'footer1',
placementId: '/1111/home#header',
banner: {
expdir: [1, 3]
},
Expand All @@ -77,9 +74,7 @@ The Trade Desk bid adapter supports Banner and Video.
bidder: 'ttd',
params: {
supplySourceId: 'supplier',
publisherId: '1427ab10f2e448057ed3b422',
siteId: 'site-123',
placementId: 'footer1'
publisherId: '1427ab10f2e448057ed3b422'
}
}
]
Expand Down Expand Up @@ -112,8 +107,7 @@ The Trade Desk bid adapter supports Banner and Video.
params: {
supplySourceId: 'supplier',
publisherId: '1427ab10f2e448057ed3b422',
siteId: 'site-123',
placementId: 'footer1'
placementId: '/1111/home#header'
}
}
]
Expand Down
Loading

0 comments on commit 6ff8cb8

Please sign in to comment.