Skip to content

Commit

Permalink
OpenX Adapter: Forcing https requests and adding UserID module suppor…
Browse files Browse the repository at this point in the history
…t for LiveRamp and TTD (#4182)

* OpenX Adapter: Updated requests to force https

* OpenX Adapter: Added support for TTD's UnifiedID and LiveRamp's IDL
  • Loading branch information
jimee02 authored and Isaac A. Dettman committed Sep 23, 2019
1 parent e817865 commit 495baa9
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 106 deletions.
37 changes: 27 additions & 10 deletions modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const BIDDER_CODE = 'openx';
const BIDDER_CONFIG = 'hb_pb';
const BIDDER_VERSION = '2.1.9';

const USER_ID_CODE_TO_QUERY_ARG = {
idl_env: 'lre', // liveramp
pubcid: 'pubcid', // publisher common id
tdid: 'ttduuid' // the trade desk
};

let shouldSendBoPixel = true;

export function resetBoPixel() {
Expand Down Expand Up @@ -59,7 +65,7 @@ export const spec = {
let pixelType = syncOptions.iframeEnabled ? 'iframe' : 'image';
let url = utils.deepAccess(responses, '0.body.ads.pixels') ||
utils.deepAccess(responses, '0.body.pixels') ||
'//u.openx.net/w/1.0/pd';
'https://u.openx.net/w/1.0/pd';
return [{
type: pixelType,
url: url
Expand Down Expand Up @@ -237,19 +243,30 @@ function buildCommonQueryParamsFromBids(bids, bidderRequest) {
}
}

if ((bids[0].userId && bids[0].userId.pubcid)) {
defaultParams.pubcid = bids[0].userId.pubcid;
} else if (bids[0].crumbs && bids[0].crumbs.pubcid) {
defaultParams.pubcid = bids[0].crumbs.pubcid;
// normalize publisher common id
if (utils.deepAccess(bids[0], 'crumbs.pubcid')) {
utils.deepSetValue(bids[0], 'userId.pubcid', utils.deepAccess(bids[0], 'crumbs.pubcid'));
}
defaultParams = appendUserIdsToQueryParams(defaultParams, bids[0].userId);

// supply chain support
if (bids[0].schain) {
defaultParams.schain = serializeSupplyChain(bids[0].schain);
}

return defaultParams;
}

function appendUserIdsToQueryParams(queryParams, userIds) {
utils._each(userIds, (userIdValue, userIdProviderKey) => {
if (USER_ID_CODE_TO_QUERY_ARG.hasOwnProperty(userIdProviderKey)) {
queryParams[USER_ID_CODE_TO_QUERY_ARG[userIdProviderKey]] = userIdValue;
}
});

return queryParams;
}

function serializeSupplyChain(supplyChain) {
return `${supplyChain.ver},${supplyChain.complete}!${serializeSupplyChainNodes(supplyChain.nodes)}`;
}
Expand Down Expand Up @@ -312,8 +329,8 @@ function buildOXBannerRequest(bids, bidderRequest) {
}

let url = queryParams.ph
? `//u.openx.net/w/1.0/arj`
: `//${bids[0].params.delDomain}/w/1.0/arj`;
? `https://u.openx.net/w/1.0/arj`
: `https://${bids[0].params.delDomain}/w/1.0/arj`;

return {
method: 'GET',
Expand All @@ -326,8 +343,8 @@ function buildOXBannerRequest(bids, bidderRequest) {
function buildOXVideoRequest(bid, bidderRequest) {
let oxVideoParams = generateVideoParameters(bid, bidderRequest);
let url = oxVideoParams.ph
? `//u.openx.net/v/1.0/avjp`
: `//${bid.params.delDomain}/v/1.0/avjp`;
? `https://u.openx.net/v/1.0/avjp`
: `https://${bid.params.delDomain}/v/1.0/avjp`;
return {
method: 'GET',
url: url,
Expand Down Expand Up @@ -442,7 +459,7 @@ function registerBeacon(mediaType, adUnit, startTime) {
if (mediaType === VIDEO) {
let url = parse(adUnit.colo);
beaconParams.ph = adUnit.ph;
beaconUrl = `//${url.hostname}/w/1.0/bo?${buildQueryStringFromParams(beaconParams)}`
beaconUrl = `https://${url.hostname}/w/1.0/bo?${buildQueryStringFromParams(beaconParams)}`
} else {
let recordPixel = utils.deepAccess(adUnit, 'creative.0.tracking.impression');
let boBase = recordPixel.match(/([^?]+\/)ri\?/);
Expand Down
Loading

0 comments on commit 495baa9

Please sign in to comment.