Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenX Adapter: Forcing https requests and adding UserID module support for LiveRamp and TTD #4182

Merged
merged 2 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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