Skip to content

Commit

Permalink
Merge branch 'master' into prebid-7
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed Jun 7, 2022
2 parents 3682d62 + 302411b commit d44519b
Show file tree
Hide file tree
Showing 14 changed files with 443 additions and 120 deletions.
30 changes: 29 additions & 1 deletion modules/adoceanBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const BIDDER_CODE = 'adocean';
function buildEndpointUrl(emiter, payloadMap) {
const payload = [];
_each(payloadMap, function(v, k) {
payload.push(k + '=' + encodeURIComponent(v));
payload.push(k + '=' + (k === 'schain' ? v : encodeURIComponent(v)));
});

const randomizedPart = Math.random().toString().slice(2);
Expand All @@ -23,6 +23,10 @@ function buildRequest(masterBidRequests, masterId, gdprConsent) {
payload.gdpr_consent = gdprConsent.consentString || undefined;
payload.gdpr = gdprConsent.gdprApplies ? 1 : 0;
}
const anyKey = Object.keys(masterBidRequests)[0];
if (masterBidRequests[anyKey].schain) {
payload.schain = serializeSupplyChain(masterBidRequests[anyKey].schain);
}

const bidIdMap = {};

Expand All @@ -48,6 +52,30 @@ function buildRequest(masterBidRequests, masterId, gdprConsent) {
};
}

const SCHAIN_FIELDS = ['asi', 'sid', 'hp', 'rid', 'name', 'domain', 'ext'];
function serializeSupplyChain(schain) {
const header = `${schain.ver},${schain.complete}!`;

const serializedNodes = [];
_each(schain.nodes, function(node) {
const serializedNode = SCHAIN_FIELDS
.map(fieldName => {
if (fieldName === 'ext') {
// do not serialize ext data, just mark if it was available
return ('ext' in node ? '1' : '0');
}
if (fieldName in node) {
return encodeURIComponent(node[fieldName]).replace(/!/g, '%21');
}
return '';
})
.join(',');
serializedNodes.push(serializedNode);
});

return header + serializedNodes.join('!');
}

function assignToMaster(bidRequest, bidRequestsByMaster) {
const masterId = bidRequest.params.masterId;
const slaveId = bidRequest.params.slaveId;
Expand Down
2 changes: 1 addition & 1 deletion modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const BIDDER_CODE = 'ix';
const ALIAS_BIDDER_CODE = 'roundel';
const GLOBAL_VENDOR_ID = 10;
const MODULE_TYPE = 'bid-adapter';
const SECURE_BID_URL = 'https://htlb.casalemedia.com/cygnus';
const SECURE_BID_URL = 'https://htlb.casalemedia.com/openrtb/pbjs';
const SUPPORTED_AD_TYPES = [BANNER, VIDEO];
const BANNER_ENDPOINT_VERSION = 7.2;
const VIDEO_ENDPOINT_VERSION = 8.1;
Expand Down
2 changes: 1 addition & 1 deletion modules/ixBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,4 @@ The `size` parameter is no longer a required field, the `siteId` will now be ass
In your browser of choice, create a new tab and open the developer tools. In
developer tools, select the network tab. Then, navigate to a page where IX is
setup to bid. Now, in the network tab, search for requests to
`casalemedia.com/cygnus`. These are the bid requests.
`casalemedia.com/openrtb/pbjs`. These are the bid requests.
74 changes: 43 additions & 31 deletions modules/merkleIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {submodule} from '../src/hook.js'
import {getStorageManager} from '../src/storageManager.js';

const MODULE_NAME = 'merkleId';
const ID_URL = 'https://id2.sv.rkdms.com/identity/';
const ID_URL = 'https://prebid.sv.rkdms.com/identity/';
const DEFAULT_REFRESH = 7 * 3600;
const SESSION_COOKIE_NAME = '_svsid';

Expand All @@ -30,19 +30,19 @@ function getSession(configParams) {
function setCookie(name, value, expires) {
let expTime = new Date();
expTime.setTime(expTime.getTime() + expires * 1000 * 60);
storage.setCookie(name, value, expTime.toUTCString());
storage.setCookie(name, value, expTime.toUTCString(), 'Lax');
}

function setSession(storage, response) {
logInfo('Merkle setting session ');
if (response && response.c && response.c.value && typeof response.c.value === 'string') {
setCookie(SESSION_COOKIE_NAME, response.c.value, storage.expires);
logInfo('Merkle setting ' + `${SESSION_COOKIE_NAME}`);
if (response && response[SESSION_COOKIE_NAME] && typeof response[SESSION_COOKIE_NAME] === 'string') {
setCookie(SESSION_COOKIE_NAME, response[SESSION_COOKIE_NAME], storage.expires);
}
}

function constructUrl(configParams) {
const session = getSession(configParams);
let url = configParams.endpoint + `?vendor=${configParams.vendor}&sv_cid=${configParams.sv_cid}&sv_domain=${configParams.sv_domain}&sv_pubid=${configParams.sv_pubid}`;
let url = configParams.endpoint + `?sv_domain=${configParams.sv_domain}&sv_pubid=${configParams.sv_pubid}&ssp_ids=${configParams.ssp_ids.join()}`;
if (session) {
url = `${url}&sv_session=${session}`;
}
Expand Down Expand Up @@ -86,52 +86,60 @@ function generateId(configParams, configStorage) {
/** @type {Submodule} */
export const merkleIdSubmodule = {
/**
* used to link submodule with config
* @type {string}
*/
* used to link submodule with config
* @type {string}
*/
name: MODULE_NAME,

/**
* decode the stored id value for passing to bid requests
* @function
* @param {string} value
* @returns {{merkleId:string}}
*/
* decode the stored id value for passing to bid requests
* @function
* @param {string} value
* @returns {{eids:arrayofields}}
*/
decode(value) {
// Legacy support for a single id
const id = (value && value.pam_id && typeof value.pam_id.id === 'string') ? value.pam_id : undefined;
logInfo('Merkle id ' + JSON.stringify(id));
return id ? {'merkleId': id} : undefined;

if (id) {
return {'merkleId': id}
}

// Supports multiple IDs for different SSPs
const merkleIds = (value && value?.merkleId && Array.isArray(value.merkleId)) ? value.merkleId : undefined;
logInfo('merkleIds: ' + JSON.stringify(merkleIds));

return merkleIds ? {'merkleId': merkleIds} : undefined;
},

/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleConfig} [config]
* @param {ConsentData} [consentData]
* @returns {IdResponse|undefined}
*/
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleConfig} [config]
* @param {ConsentData} [consentData]
* @returns {IdResponse|undefined}
*/
getId(config, consentData) {
logInfo('User ID - merkleId generating id');

const configParams = (config && config.params) || {};

if (!configParams || typeof configParams.vendor !== 'string') {
logError('User ID - merkleId submodule requires a valid vendor to be defined');
return;
}

if (typeof configParams.sv_cid !== 'string') {
logError('User ID - merkleId submodule requires a valid sv_cid string to be defined');
if (typeof configParams.sv_pubid !== 'string') {
logError('User ID - merkleId submodule requires a valid sv_pubid string to be defined');
return;
}

if (typeof configParams.sv_pubid !== 'string') {
logError('User ID - merkleId submodule requires a valid sv_pubid string to be defined');
if (!Array.isArray(configParams.ssp_ids)) {
logError('User ID - merkleId submodule requires a valid ssp_ids array to be defined');
return;
}

if (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) {
logError('User ID - merkleId submodule does not currently handle consent strings');
return;
}

if (typeof configParams.endpoint !== 'string') {
logWarn('User ID - merkleId submodule endpoint string is not defined');
configParams.endpoint = ID_URL
Expand All @@ -146,7 +154,7 @@ export const merkleIdSubmodule = {
return {callback: resp};
},
extendId: function (config = {}, consentData, storedId) {
logInfo('User ID - merkleId stored id ' + storedId);
logInfo('User ID - stored id ' + storedId);
const configParams = (config && config.params) || {};

if (typeof configParams.endpoint !== 'string') {
Expand All @@ -162,15 +170,18 @@ export const merkleIdSubmodule = {
if (typeof configParams.sv_domain !== 'string') {
configParams.sv_domain = merkleIdSubmodule.findRootDomain();
}

const configStorage = (config && config.storage) || {};
if (configStorage && configStorage.refreshInSeconds && typeof configParams.refreshInSeconds === 'number') {
return {id: storedId};
}

let refreshInSeconds = DEFAULT_REFRESH;
if (configParams && configParams.refreshInSeconds && typeof configParams.refreshInSeconds === 'number') {
refreshInSeconds = configParams.refreshInSeconds;
logInfo('User ID - merkleId param refreshInSeconds' + refreshInSeconds);
}

const storedDate = new Date(storedId.date);
let refreshNeeded = false;
if (storedDate) {
Expand All @@ -181,6 +192,7 @@ export const merkleIdSubmodule = {
return {callback: resp};
}
}

logInfo('User ID - merkleId not refreshed');
return {id: storedId};
}
Expand Down
82 changes: 49 additions & 33 deletions modules/pubmaticAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ function setMediaTypes(types, bid) {
function copyRequiredBidDetails(bid) {
return pick(bid, [
'bidder',
'bidderCode',
'adapterCode',
'bidId',
'status', () => NO_BID, // default a bid to NO_BID until response is recieved or bid is timed out
'finalSource as source',
'params',
'adUnit', () => pick(bid, [
'adUnitCode',
'transactionId',
'sizes as dimensions', sizes => sizes.map(sizeToDimensions),
'sizes as dimensions', sizes => sizes && sizes.map(sizeToDimensions),
'mediaTypes', (types) => setMediaTypes(types, bid)
])
]);
Expand Down Expand Up @@ -185,11 +187,11 @@ function getDevicePlatform() {
}

function getValueForKgpv(bid, adUnitId) {
if (bid.params.regexPattern) {
if (bid.params && bid.params.regexPattern) {
return bid.params.regexPattern;
} else if (bid.bidResponse && bid.bidResponse.regexPattern) {
return bid.bidResponse.regexPattern;
} else if (bid.params.kgpv) {
} else if (bid.params && bid.params.kgpv) {
return bid.params.kgpv;
} else {
return adUnitId;
Expand Down Expand Up @@ -218,30 +220,31 @@ function getAdDomain(bidResponse) {
function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) {
highestBid = (highestBid && highestBid.length > 0) ? highestBid[0] : null;
return Object.keys(adUnit.bids).reduce(function(partnerBids, bidId) {
let bid = adUnit.bids[bidId];
partnerBids.push({
'pn': getAdapterNameForAlias(bid.bidder),
'bc': bid.bidder,
'bidid': bid.bidId,
'db': bid.bidResponse ? 0 : 1,
'kgpv': getValueForKgpv(bid, adUnitId),
'kgpsv': bid.params.kgpv ? bid.params.kgpv : adUnitId,
'psz': bid.bidResponse ? (bid.bidResponse.dimensions.width + 'x' + bid.bidResponse.dimensions.height) : '0x0',
'eg': bid.bidResponse ? bid.bidResponse.bidGrossCpmUSD : 0,
'en': bid.bidResponse ? bid.bidResponse.bidPriceUSD : 0,
'di': bid.bidResponse ? (bid.bidResponse.dealId || EMPTY_STRING) : EMPTY_STRING,
'dc': bid.bidResponse ? (bid.bidResponse.dealChannel || EMPTY_STRING) : EMPTY_STRING,
'l1': bid.bidResponse ? bid.clientLatencyTimeMs : 0,
'l2': 0,
'adv': bid.bidResponse ? getAdDomain(bid.bidResponse) || undefined : undefined,
'ss': (s2sBidders.indexOf(bid.bidder) > -1) ? 1 : 0,
't': (bid.status == ERROR && bid.error.code == TIMEOUT_ERROR) ? 1 : 0,
'wb': (highestBid && highestBid.requestId === bid.bidId ? 1 : 0),
'mi': bid.bidResponse ? (bid.bidResponse.mi || undefined) : undefined,
'af': bid.bidResponse ? (bid.bidResponse.mediaType || undefined) : undefined,
'ocpm': bid.bidResponse ? (bid.bidResponse.originalCpm || 0) : 0,
'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD,
'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING
adUnit.bids[bidId].forEach(function(bid) {
partnerBids.push({
'pn': getAdapterNameForAlias(bid.adapterCode || bid.bidder),
'bc': bid.bidderCode || bid.bidder,
'bidid': bid.bidId || bidId,
'db': bid.bidResponse ? 0 : 1,
'kgpv': getValueForKgpv(bid, adUnitId),
'kgpsv': bid.params && bid.params.kgpv ? bid.params.kgpv : adUnitId,
'psz': bid.bidResponse ? (bid.bidResponse.dimensions.width + 'x' + bid.bidResponse.dimensions.height) : '0x0',
'eg': bid.bidResponse ? bid.bidResponse.bidGrossCpmUSD : 0,
'en': bid.bidResponse ? bid.bidResponse.bidPriceUSD : 0,
'di': bid.bidResponse ? (bid.bidResponse.dealId || EMPTY_STRING) : EMPTY_STRING,
'dc': bid.bidResponse ? (bid.bidResponse.dealChannel || EMPTY_STRING) : EMPTY_STRING,
'l1': bid.bidResponse ? bid.clientLatencyTimeMs : 0,
'l2': 0,
'adv': bid.bidResponse ? getAdDomain(bid.bidResponse) || undefined : undefined,
'ss': (s2sBidders.indexOf(bid.bidder) > -1) ? 1 : 0,
't': (bid.status == ERROR && bid.error.code == TIMEOUT_ERROR) ? 1 : 0,
'wb': (highestBid && highestBid.adId === bid.adId ? 1 : 0),
'mi': bid.bidResponse ? (bid.bidResponse.mi || undefined) : undefined,
'af': bid.bidResponse ? (bid.bidResponse.mediaType || undefined) : undefined,
'ocpm': bid.bidResponse ? (bid.bidResponse.originalCpm || 0) : 0,
'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD,
'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING
});
});
return partnerBids;
}, [])
Expand Down Expand Up @@ -307,8 +310,14 @@ function executeBidsLoggerCall(e, highestCpmBids) {

function executeBidWonLoggerCall(auctionId, adUnitId) {
const winningBidId = cache.auctions[auctionId].adUnitCodes[adUnitId].bidWon;
const winningBid = cache.auctions[auctionId].adUnitCodes[adUnitId].bids[winningBidId];
const adapterName = getAdapterNameForAlias(winningBid.bidder);
const winningBids = cache.auctions[auctionId].adUnitCodes[adUnitId].bids[winningBidId];
let winningBid = winningBids[0];

if (winningBids.length > 1) {
winningBid = winningBids.filter(bid => bid.adId === cache.auctions[auctionId].adUnitCodes[adUnitId].bidWonAdId)[0];
}

const adapterName = getAdapterNameForAlias(winningBid.adapterCode || winningBid.bidder);
let pixelURL = END_POINT_WIN_BID_LOGGER;
pixelURL += 'pubid=' + publisherId;
pixelURL += '&purl=' + enc(config.getConfig('pageUrl') || cache.auctions[auctionId].referer || '');
Expand All @@ -319,7 +328,7 @@ function executeBidWonLoggerCall(auctionId, adUnitId) {
pixelURL += '&pdvid=' + enc(profileVersionId);
pixelURL += '&slot=' + enc(adUnitId);
pixelURL += '&pn=' + enc(adapterName);
pixelURL += '&bc=' + enc(winningBid.bidder);
pixelURL += '&bc=' + enc(winningBid.bidderCode || winningBid.bidder);
pixelURL += '&en=' + enc(winningBid.bidResponse.bidPriceUSD);
pixelURL += '&eg=' + enc(winningBid.bidResponse.bidGrossCpmUSD);
pixelURL += '&kgpv=' + enc(getValueForKgpv(winningBid, adUnitId));
Expand Down Expand Up @@ -362,16 +371,22 @@ function bidRequestedHandler(args) {
dimensions: bid.sizes
};
}
cache.auctions[args.auctionId].adUnitCodes[bid.adUnitCode].bids[bid.bidId] = copyRequiredBidDetails(bid);
cache.auctions[args.auctionId].adUnitCodes[bid.adUnitCode].bids[bid.bidId] = [copyRequiredBidDetails(bid)];
})
}

function bidResponseHandler(args) {
let bid = cache.auctions[args.auctionId].adUnitCodes[args.adUnitCode].bids[args.requestId];
let bid = cache.auctions[args.auctionId].adUnitCodes[args.adUnitCode].bids[args.requestId][0];
if (!bid) {
logError(LOG_PRE_FIX + 'Could not find associated bid request for bid response with requestId: ', args.requestId);
return;
}

if (bid.bidder && args.bidderCode && bid.bidder !== args.bidderCode) {
bid = copyRequiredBidDetails(args);
cache.auctions[args.auctionId].adUnitCodes[args.adUnitCode].bids[args.requestId].push(bid)
}
bid.adId = args.adId;
bid.source = formatSource(bid.source || args.source);
setBidStatus(bid, args);
bid.clientLatencyTimeMs = Date.now() - cache.auctions[args.auctionId].timestamp;
Expand All @@ -397,6 +412,7 @@ function bidderDoneHandler(args) {
function bidWonHandler(args) {
let auctionCache = cache.auctions[args.auctionId];
auctionCache.adUnitCodes[args.adUnitCode].bidWon = args.requestId;
auctionCache.adUnitCodes[args.adUnitCode].bidWonAdId = args.adId;
executeBidWonLoggerCall(args.auctionId, args.adUnitCode);
}

Expand All @@ -413,7 +429,7 @@ function bidTimeoutHandler(args) {
// db = 0 and t = 1 means bidder did respond with a bid but post timeout
args.forEach(badBid => {
let auctionCache = cache.auctions[badBid.auctionId];
let bid = auctionCache.adUnitCodes[badBid.adUnitCode].bids[ badBid.bidId || badBid.requestId ];
let bid = auctionCache.adUnitCodes[badBid.adUnitCode].bids[ badBid.bidId || badBid.requestId ][0];
if (bid) {
bid.status = ERROR;
bid.error = {
Expand Down
2 changes: 1 addition & 1 deletion modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {getStorageManager} from '../src/storageManager.js';
const BIDDER_CODE = 'taboola';
const GVLID = 42;
const CURRENCY = 'USD';
export const END_POINT_URL = 'http://hb.bidder.taboola.com/TaboolaHBOpenRTBRequestHandlerServlet';
export const END_POINT_URL = 'https://hb.bidder.taboola.com/TaboolaHBOpenRTBRequestHandlerServlet';
const USER_ID = 'user-id';
const STORAGE_KEY = `taboola global:${USER_ID}`;
const COOKIE_KEY = 'trc_cookie_storage';
Expand Down
Loading

0 comments on commit d44519b

Please sign in to comment.