Skip to content

Commit

Permalink
Merge branch 'prebid:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
BaronJHYu authored Dec 13, 2023
2 parents 486e88e + 1c4bc7a commit a58ba76
Show file tree
Hide file tree
Showing 63 changed files with 1,606 additions and 386 deletions.
58 changes: 52 additions & 6 deletions modules/adagioAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ const cache = {
getAuction: function(auctionId, adUnitCode) {
return this.auctions[auctionId][adUnitCode];
},
getBiddersFromAuction: function(auctionId, adUnitCode) {
return this.getAuction(auctionId, adUnitCode).bdrs.split(',');
},
getAllAdUnitCodes: function(auctionId) {
return Object.keys(this.auctions[auctionId]);
},
updateAuction: function(auctionId, adUnitCode, values) {
this.auctions[auctionId][adUnitCode] = {
...this.auctions[auctionId][adUnitCode],
Expand Down Expand Up @@ -74,7 +80,8 @@ const adagioEnqueue = function adagioEnqueue(action, data) {

const guard = {
adagio: (value) => isAdagio(value),
bidTracked: (auctionId, adUnitCode) => deepAccess(cache, `auctions.${auctionId}.${adUnitCode}`, false)
bidTracked: (auctionId, adUnitCode) => deepAccess(cache, `auctions.${auctionId}.${adUnitCode}`, false),
auctionTracked: (auctionId) => deepAccess(cache, `auctions.${auctionId}`, false)
};

function removeDuplicates(arr, getKey) {
Expand Down Expand Up @@ -105,6 +112,19 @@ function getMediaTypeAlias(mediaType) {
return mediaTypesMap[mediaType] || mediaType;
};

function addKeyPrefix(obj, prefix) {
return Object.keys(obj).reduce((acc, key) => {
// We don't want to prefix already prefixed keys.
if (key.startsWith(prefix)) {
acc[key] = obj[key];
return acc;
}

acc[`${prefix}${key}`] = obj[key];
return acc;
}, {});
}

/**
* sendRequest to Adagio. It filter null values and encode each query param.
* @param {Object} qp
Expand Down Expand Up @@ -146,6 +166,7 @@ function getTargetedAuctionId(bid) {
* HANDLERS
* - handlerAuctionInit
* - handlerBidResponse
* - handlerAuctionEnd
* - handlerBidWon
* - handlerAdRender
*
Expand Down Expand Up @@ -227,11 +248,10 @@ function handlerAuctionInit(event) {
auct_id: adagioAuctionId,
adu_code: adUnitCode,
url_dmn: w.location.hostname,
dvc: params.environment,
pgtyp: params.pagetype,
plcmt: params.placement,
tname: params.testName || null,
tvname: params.testVariationName || null,
t_n: params.testName || null,
t_v: params.testVersion || null,
mts: mediaTypesKeys.join(','),
ban_szs: bannerSizes.join(','),
bdrs: bidders.map(bidder => getAdapterNameForAlias(bidder.bidder)).sort().join(','),
Expand All @@ -257,11 +277,33 @@ function handlerBidResponse(event) {
return;
}

if (!event.pba) {
return;
}

cache.updateAuction(event.auctionId, event.adUnitCode, {
adg_sid: event.seatId || null
...addKeyPrefix(event.pba, 'e_')
});
};

function handlerAuctionEnd(event) {
const { auctionId } = event;

if (!guard.auctionTracked(auctionId)) {
return;
}

const adUnitCodes = cache.getAllAdUnitCodes(auctionId);
adUnitCodes.forEach(adUnitCode => {
const mapper = (bidder) => event.bidsReceived.find(bid => bid.adUnitCode === adUnitCode && bid.bidder === bidder) ? '1' : '0';

cache.updateAuction(auctionId, adUnitCode, {
bdrs_bid: cache.getBiddersFromAuction(auctionId, adUnitCode).map(mapper).join(',')
});
sendNewBeacon(auctionId, adUnitCode);
});
}

function handlerBidWon(event) {
let auctionId = getTargetedAuctionId(event);

Expand Down Expand Up @@ -340,10 +382,14 @@ let adagioAdapter = Object.assign(adapter({ emptyUrl, analyticsType }), {
case CONSTANTS.EVENTS.BID_RESPONSE:
handlerBidResponse(args);
break;
case CONSTANTS.EVENTS.AUCTION_END:
handlerAuctionEnd(args);
break;
case CONSTANTS.EVENTS.BID_WON:
handlerBidWon(args);
break;
case CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED:
// AD_RENDER_SUCCEEDED seems redundant with BID_WON.
// case CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED:
case CONSTANTS.EVENTS.AD_RENDER_FAILED:
handlerAdRender(args, eventType === CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED);
break;
Expand Down
41 changes: 25 additions & 16 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,9 @@ export const spec = {
}
}

// Enforce the organizationId param to be a string
bidRequest.params.organizationId = bidRequest.params.organizationId.toString();

// Force the Data Layer key and value to be a String
if (bidRequest.params.dataLayer) {
if (isStr(bidRequest.params.dataLayer) || isNumber(bidRequest.params.dataLayer) || isArray(bidRequest.params.dataLayer) || isFn(bidRequest.params.dataLayer)) {
Expand Down Expand Up @@ -1120,30 +1123,36 @@ export const spec = {
bidRequest.gpid = gpid;
}

// store the whole bidRequest (adUnit) object in the ADAGIO namespace.
storeRequestInAdagioNS(bidRequest);

// Remove these fields at the very end, so we can still use them before.
delete bidRequest.transactionId;
delete bidRequest.ortb2Imp;
delete bidRequest.ortb2;
delete bidRequest.sizes;
// Remove some params that are not needed on the server side.
delete bidRequest.params.siteId;

// whitelist the fields that are allowed to be sent to the server.
const adUnit = {
adUnitCode: bidRequest.adUnitCode,
auctionId: bidRequest.auctionId,
bidder: bidRequest.bidder,
bidId: bidRequest.bidId,
params: bidRequest.params,
features: bidRequest.features,
gpid: bidRequest.gpid,
mediaTypes: bidRequest.mediaTypes,
nativeParams: bidRequest.nativeParams,
score: bidRequest.score,
transactionId: bidRequest.transactionId,
}

return bidRequest;
return adUnit;
});

// Group ad units by organizationId
const groupedAdUnits = adUnits.reduce((groupedAdUnits, adUnit) => {
const adUnitCopy = deepClone(adUnit);
adUnitCopy.params.organizationId = adUnitCopy.params.organizationId.toString();

// remove useless props
delete adUnitCopy.floorData;
delete adUnitCopy.params.siteId;
delete adUnitCopy.userId;
delete adUnitCopy.userIdAsEids;
const organizationId = adUnit.params.organizationId

groupedAdUnits[adUnitCopy.params.organizationId] = groupedAdUnits[adUnitCopy.params.organizationId] || [];
groupedAdUnits[adUnitCopy.params.organizationId].push(adUnitCopy);
groupedAdUnits[organizationId] = groupedAdUnits[organizationId] || [];
groupedAdUnits[organizationId].push(adUnit);

return groupedAdUnits;
}, {});
Expand Down
46 changes: 25 additions & 21 deletions modules/adnuntiusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ const VALID_BID_TYPES = ['netBid', 'grossBid'];
const META_DATA_KEY = 'adn.metaData';

export const misc = {
getUnixTimestamp: function(addDays, asMinutes) {
getUnixTimestamp: function (addDays, asMinutes) {
const multiplication = addDays / (asMinutes ? 1440 : 1);
return Date.now() + (addDays && addDays > 0 ? (1000 * 60 * 60 * 24 * multiplication) : 0);
}
};

const storageTool = (function() {
const storage = getStorageManager({bidderCode: BIDDER_CODE});
const storageTool = (function () {
const storage = getStorageManager({ bidderCode: BIDDER_CODE });
let metaInternal;

const getMetaInternal = function() {
const getMetaInternal = function () {
if (!storage.localStorageIsEnabled()) {
return {};
}
Expand Down Expand Up @@ -57,24 +57,24 @@ const storageTool = (function() {
return filteredEntries;
};

const setMetaInternal = function(apiResponse) {
const setMetaInternal = function (apiResponse) {
if (!storage.localStorageIsEnabled()) {
return;
}

const updateVoidAuIds = function(currentVoidAuIds, auIdsAsString) {
const updateVoidAuIds = function (currentVoidAuIds, auIdsAsString) {
const newAuIds = auIdsAsString ? auIdsAsString.split(';') : [];
const notNewExistingAuIds = currentVoidAuIds.filter(auIdObj => {
return newAuIds.indexOf(auIdObj.value) < -1;
}) || [];
const oneDayFromNow = misc.getUnixTimestamp(1);
const apiIdsArray = newAuIds.map(auId => {
return {exp: oneDayFromNow, auId: auId};
return { exp: oneDayFromNow, auId: auId };
}) || [];
return notNewExistingAuIds.concat(apiIdsArray) || [];
}

const metaAsObj = getMetaInternal().reduce((a, entry) => ({...a, [entry.key]: {value: entry.value, exp: entry.exp}}), {});
const metaAsObj = getMetaInternal().reduce((a, entry) => ({ ...a, [entry.key]: { value: entry.value, exp: entry.exp } }), {});
for (const key in apiResponse) {
if (key !== 'voidAuIds') {
metaAsObj[key] = {
Expand All @@ -85,7 +85,7 @@ const storageTool = (function() {
}
const currentAuIds = updateVoidAuIds(metaAsObj.voidAuIds || [], apiResponse.voidAuIds || []);
if (currentAuIds.length > 0) {
metaAsObj.voidAuIds = {value: currentAuIds};
metaAsObj.voidAuIds = { value: currentAuIds };
}
const metaDataForSaving = Object.entries(metaAsObj).map((entrySet) => {
if (entrySet[0] === 'voidAuIds') {
Expand All @@ -103,7 +103,7 @@ const storageTool = (function() {
storage.setDataInLocalStorage(META_DATA_KEY, JSON.stringify(metaDataForSaving));
};

const getUsi = function(meta, ortb2) {
const getUsi = function (meta, ortb2) {
let usi = (meta && meta.usi) ? meta.usi : false;
if (ortb2 && ortb2.user && ortb2.user.id) {
usi = ortb2.user.id
Expand All @@ -128,9 +128,9 @@ const storageTool = (function() {
}

return {
refreshStorage: function(bidderRequest) {
refreshStorage: function (bidderRequest) {
const ortb2 = bidderRequest.ortb2 || {};
metaInternal = getMetaInternal().reduce((a, entry) => ({...a, [entry.key]: entry.value}), {});
metaInternal = getMetaInternal().reduce((a, entry) => ({ ...a, [entry.key]: entry.value }), {});
metaInternal.usi = getUsi(metaInternal, ortb2);
if (!metaInternal.usi) {
delete metaInternal.usi;
Expand All @@ -142,21 +142,21 @@ const storageTool = (function() {
}
metaInternal.segments = getSegmentsFromOrtb(ortb2);
},
saveToStorage: function(serverData) {
saveToStorage: function (serverData) {
setMetaInternal(serverData);
},
getUrlRelatedData: function() {
const {segments, usi, voidAuIdsArray} = metaInternal;
return {segments, usi, voidAuIdsArray};
getUrlRelatedData: function () {
const { segments, usi, voidAuIdsArray } = metaInternal;
return { segments, usi, voidAuIdsArray };
},
getPayloadRelatedData: function() {
const {segments, usi, userId, voidAuIdsArray, voidAuIds, ...payloadRelatedData} = metaInternal;
getPayloadRelatedData: function () {
const { segments, usi, userId, voidAuIdsArray, voidAuIds, ...payloadRelatedData } = metaInternal;
return payloadRelatedData;
}
};
})();

const validateBidType = function(bidTypeOption) {
const validateBidType = function (bidTypeOption) {
return VALID_BID_TYPES.indexOf(bidTypeOption || '') > -1 ? bidTypeOption : 'bid';
}

Expand All @@ -177,10 +177,13 @@ export const spec = {
const queryParamsAndValues = [];
queryParamsAndValues.push('tzo=' + new Date().getTimezoneOffset())
queryParamsAndValues.push('format=json')

const gdprApplies = deepAccess(bidderRequest, 'gdprConsent.gdprApplies');
const consentString = deepAccess(bidderRequest, 'gdprConsent.consentString');
if (gdprApplies !== undefined) queryParamsAndValues.push('consentString=' + consentString);
if (gdprApplies !== undefined) {
const flag = gdprApplies ? '1' : '0'
queryParamsAndValues.push('consentString=' + consentString);
queryParamsAndValues.push('gdpr=' + flag);
}

storageTool.refreshStorage(bidderRequest);

Expand All @@ -194,6 +197,7 @@ export const spec = {

const bidRequests = {};
const networks = {};

for (let i = 0; i < validBidRequests.length; i++) {
const bid = validBidRequests[i];
if ((urlRelatedMetaData.voidAuIdsArray && (urlRelatedMetaData.voidAuIdsArray.indexOf(bid.params.auId) > -1 || urlRelatedMetaData.voidAuIdsArray.indexOf(bid.params.auId.padStart(16, '0')) > -1))) {
Expand Down
4 changes: 2 additions & 2 deletions modules/browsiRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export function collectData() {
let predictorData = {
...{
sk: _moduleParams.siteKey,
pk: _moduleParams.pubKey,
sw: (win.screen && win.screen.width) || -1,
sh: (win.screen && win.screen.height) || -1,
url: `${doc.location.protocol}//${doc.location.host}${doc.location.pathname}`,
Expand Down Expand Up @@ -134,7 +135,6 @@ function getRTD(auc) {
const adSlot = getSlotByCode(uc);
const identifier = adSlot ? getMacroId(_browsiData['pmd'], adSlot) : uc;
const _pd = _bp[identifier];
rp[uc] = getKVObject(-1);
if (!_pd) {
return rp
}
Expand Down Expand Up @@ -275,7 +275,7 @@ function getPredictionsFromServer(url) {
if (req.status === 200) {
try {
const data = JSON.parse(response);
if (data && data.p && data.kn) {
if (data) {
setData({p: data.p, kn: data.kn, pmd: data.pmd, bet: data.bet});
} else {
setData({});
Expand Down
2 changes: 2 additions & 0 deletions modules/deepintentBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { generateUUID, deepSetValue, deepAccess, isArray, isInteger, logError, l
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
const BIDDER_CODE = 'deepintent';
const GVL_ID = 541;
const BIDDER_ENDPOINT = 'https://prebid.deepintent.com/prebid';
const USER_SYNC_URL = 'https://cdn.deepintent.com/syncpixel.html';
const DI_M_V = '1.0.0';
Expand Down Expand Up @@ -32,6 +33,7 @@ export const ORTB_VIDEO_PARAMS = {
};
export const spec = {
code: BIDDER_CODE,
gvlid: GVL_ID,
supportedMediaTypes: [BANNER, VIDEO],
aliases: [],

Expand Down
2 changes: 1 addition & 1 deletion modules/flippBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import {getStorageManager} from '../src/storageManager.js';

const NETWORK_ID = 11090;
const NETWORK_ID = 10922;
const AD_TYPES = [4309, 641];
const DTX_TYPES = [5061];
const TARGET_NAME = 'inline';
Expand Down
6 changes: 4 additions & 2 deletions modules/geoedgeRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function wrapHtml(wrapper, html) {
* @param {string} key
* @return {Object}
*/
function getMacros(bid, key) {
export function getMacros(bid, key) {
return {
'${key}': key,
'%%ADUNIT%%': bid.adUnitCode,
Expand All @@ -116,7 +116,9 @@ function getMacros(bid, key) {
'%_hbadomains': bid.meta && bid.meta.advertiserDomains,
'%%PATTERN:hb_pb%%': bid.pbHg,
'%%SITE%%': location.hostname,
'%_pimp%': PV_ID
'%_pimp%': PV_ID,
'%_hbCpm!': bid.cpm,
'%_hbCurrency!': bid.currency
};
}

Expand Down
4 changes: 2 additions & 2 deletions modules/growthCodeRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ function callServer(configParams, items, expiresAt, userConsent) {
url = tryAppendQueryString(url, 'pid', configParams.pid);
url = tryAppendQueryString(url, 'u', window.location.href);
url = tryAppendQueryString(url, 'gcid', gcid);
if ((userConsent !== null) && (userConsent.gdpr !== null) && (userConsent.gdpr.consentData.getTCData.tcString)) {
url = tryAppendQueryString(url, 'tcf', userConsent.gdpr.consentData.getTCData.tcString)
if ((userConsent !== null) && (userConsent.gdpr !== null) && (userConsent.gdpr.consentString)) {
url = tryAppendQueryString(url, 'tcf', userConsent.gdpr.consentString)
}

ajax.ajaxBuilder()(url, {
Expand Down
Loading

0 comments on commit a58ba76

Please sign in to comment.