Skip to content

Commit

Permalink
Merge branch 'prebid:master' into UOE-11611
Browse files Browse the repository at this point in the history
  • Loading branch information
pm-priyanka-deshmane authored Dec 6, 2024
2 parents 2b6ed1b + 6a2c4cd commit b08648a
Show file tree
Hide file tree
Showing 156 changed files with 2,404 additions and 2,024 deletions.
2 changes: 1 addition & 1 deletion libraries/advangUtils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function isVideoBid(bid) {

export function getBannerBidFloor(bid) {
let floorInfo = isFn(bid.getFloor) ? bid.getFloor({ currency: 'USD', mediaType: 'banner', size: '*' }) : {};
return floorInfo.floor || getBannerBidParam(bid, 'bidfloor');
return floorInfo?.floor || getBannerBidParam(bid, 'bidfloor');
}

export function getVideoBidFloor(bid) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/currencyUtils/floor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function getBidFloor(bid) {
mediaType: '*',
size: '*',
});
return bidFloor.floor;
return bidFloor?.floor;
} catch (_) {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/dspxUtils/bidderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export function getBidFloor(bid) {
mediaType: '*',
size: '*',
});
return bidFloor.floor;
return bidFloor?.floor;
} catch (_) {
return 0
}
Expand Down
12 changes: 12 additions & 0 deletions libraries/gptUtils/gptUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ export function isSlotMatchingAdUnitCode(adUnitCode) {
return (slot) => compareCodeAndSlot(slot, adUnitCode);
}

/**
* @summary Export a k-v pair to GAM
*/
export function setKeyValue(key, value) {
if (!key || typeof key !== 'string') return false;
window.googletag = window.googletag || {cmd: []};
window.googletag.cmd = window.googletag.cmd || [];
window.googletag.cmd.push(() => {
window.googletag.pubads().setTargeting(key, value);
});
}

/**
* @summary Uses the adUnit's code in order to find a matching gpt slot object on the page
*/
Expand Down
2 changes: 1 addition & 1 deletion libraries/intentIqConstants/intentIqConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export const OPT_OUT = 'O';
export const BLACK_LIST = 'L';
export const CLIENT_HINTS_KEY = '_iiq_ch';
export const EMPTY = 'EMPTY'
export const VERSION = 0.22
export const VERSION = 0.24
10 changes: 10 additions & 0 deletions libraries/intentIqUtils/detectBrowserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ export function detectBrowserFromUserAgent(userAgent) {
ie: /MSIE|Trident/,
};

// Check for Edge first
if (browserRegexPatterns.edge.test(userAgent)) {
return 'edge';
}

// Check for Opera next
if (browserRegexPatterns.opera.test(userAgent)) {
return 'opera';
}

// Check for Chrome first to avoid confusion with Safari
if (browserRegexPatterns.chrome.test(userAgent)) {
return 'chrome';
Expand Down
16 changes: 16 additions & 0 deletions libraries/intentIqUtils/getGppValue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {gppDataHandler} from '../../src/consentHandler.js';

/**
* Retrieves the GPP string value and additional GPP-related information.
* This function extracts the GPP data, encodes it, and determines specific GPP flags such as GPI and applicable sections.
* @return {Object} An object containing:
* - `gppString` (string): The encoded GPP string value.
* - `gpi` (number): An indicator representing whether GPP consent is available (0 if available, 1 if not).
*/
export function getGppValue() {
const gppData = gppDataHandler.getConsentData();
const gppString = gppData?.gppString || '';
const gpi = gppString ? 0 : 1;

return { gppString, gpi };
}
22 changes: 22 additions & 0 deletions libraries/interpretResponseUtils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {logError} from '../../src/utils.js';

export function interpretResponseUtil(serverResponse, {bidderRequest}, eachBidCallback) {
const bids = [];
if (!serverResponse.body || serverResponse.body.error) {
let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`;
if (serverResponse.body && serverResponse.body.error) { errorMessage += `: ${serverResponse.body.error}`; }
logError(errorMessage);
return bids;
}
(serverResponse.body.tags || []).forEach(serverBid => {
try {
const bid = eachBidCallback(serverBid);
if (bid) {
bids.push(bid);
}
} catch (e) {
// Do nothing
}
});
return bids;
}
3 changes: 3 additions & 0 deletions libraries/ortb2Utils/currency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getCurrencyFromBidderRequest(bidderRequest) {
return bidderRequest?.ortb2?.ext?.prebid?.adServerCurrency;
}
2 changes: 1 addition & 1 deletion libraries/precisoUtils/bidUtilsCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function getBidFloor(bid) {
mediaType: '*',
size: '*',
});
return bidFloor.floor;
return bidFloor?.floor;
} catch (_) {
return 0
}
Expand Down
5 changes: 3 additions & 2 deletions libraries/riseUtils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
isEmpty,
contains,
isInteger,
getBidIdParameter
getBidIdParameter,
isPlainObject
} from '../../src/utils.js';
import { BANNER, VIDEO } from '../../src/mediaTypes.js';
import {config} from '../../src/config.js';
Expand All @@ -19,7 +20,7 @@ export function getFloor(bid, mediaType) {
mediaType: mediaType,
size: '*'
});
return floorResult.currency === 'USD' && floorResult.floor ? floorResult.floor : 0;
return isPlainObject(floorResult) && floorResult.currency === 'USD' && floorResult.floor ? floorResult.floor : 0;
}

export function getSizesArray(bid, mediaType) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/teqblazeUtils/bidderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getBidFloor = (bid) => {
size: '*',
});

return bidFloor.floor;
return bidFloor?.floor;
} catch (err) {
return 0;
}
Expand Down
22 changes: 22 additions & 0 deletions libraries/timeoutQueue/timeoutQueue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export function timeoutQueue() {
const queue = [];
return {
submit(timeout, onResume, onTimeout) {
const item = [
onResume,
setTimeout(() => {
queue.splice(queue.indexOf(item), 1);
onTimeout();
}, timeout)
];
queue.push(item);
},
resume() {
while (queue.length) {
const [onResume, timerId] = queue.shift();
clearTimeout(timerId);
onResume();
}
}
}
}
2 changes: 1 addition & 1 deletion libraries/vidazooUtils/bidderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidder
size: '*'
});

if (floorInfo.currency === 'USD') {
if (floorInfo?.currency === 'USD') {
bidFloor = floorInfo.floor;
}
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/xeUtils/bidderUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {deepAccess, getBidIdParameter, isFn, logError, isArray, parseSizesInput} from '../../src/utils.js';
import {deepAccess, getBidIdParameter, isFn, logError, isArray, parseSizesInput, isPlainObject} from '../../src/utils.js';
import {getAdUnitSizes} from '../sizeUtils/sizeUtils.js';
import {findIndex} from '../../src/polyfill.js';

Expand All @@ -13,7 +13,7 @@ export function getBidFloor(bid, currency = 'USD') {
size: '*'
});

if (typeof floor === 'object' && !isNaN(floor.floor) && floor.currency === currency) {
if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === currency) {
return floor.floor;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ function _getBidFloors(bidRequest, size, mediaType) {
size: [ size.w, size.h ]
});

if (!isNaN(bidFloors.floor) && (bidFloors.currency === CURRENCY)) {
if (!isNaN(bidFloors?.floor) && (bidFloors?.currency === CURRENCY)) {
return bidFloors.floor;
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function _getFloors(bidRequest) {
floors.push(cleanObj({
mt: mediaType,
s: isArray(size) ? `${size[0]}x${size[1]}` : undefined,
f: (!isNaN(info.floor) && info.currency === CURRENCY) ? info.floor : undefined
f: (!isNaN(info?.floor) && info?.currency === CURRENCY) ? info?.floor : undefined
}));
}

Expand Down
7 changes: 4 additions & 3 deletions modules/adfBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {deepAccess, deepClone, deepSetValue, mergeDeep, parseSizesInput, setOnAny} from '../src/utils.js';
import {config} from '../src/config.js';
import {Renderer} from '../src/Renderer.js';
import { getCurrencyFromBidderRequest } from '../libraries/ortb2Utils/currency.js';

const { getConfig } = config;

Expand Down Expand Up @@ -60,7 +61,7 @@ export const spec = {
const pt = setOnAny(validBidRequests, 'params.pt') || setOnAny(validBidRequests, 'params.priceType') || 'net';
const tid = bidderRequest.ortb2?.source?.tid;
const test = setOnAny(validBidRequests, 'params.test');
const currency = getConfig('currency.adServerCurrency');
const currency = getCurrencyFromBidderRequest(bidderRequest);
const cur = currency && [ currency ];
const eids = setOnAny(validBidRequests, 'userIdAsEids');
const schain = setOnAny(validBidRequests, 'schain');
Expand All @@ -75,8 +76,8 @@ export const spec = {
mediaType: '*'
}) : {};

const bidfloor = floorInfo.floor;
const bidfloorcur = floorInfo.currency;
const bidfloor = floorInfo?.floor;
const bidfloorcur = floorInfo?.currency;
const { mid, inv, mname } = bid.params;
const impExtData = bid.ortb2Imp?.ext?.data;

Expand Down
27 changes: 14 additions & 13 deletions modules/adgenerationBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {deepAccess, getBidIdParameter} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
import {convertOrtbRequestToProprietaryNative} from '../src/native.js';
import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js';
import {escapeUnsafeChars} from '../libraries/htmlEscape/htmlEscape.js';
import { escapeUnsafeChars } from '../libraries/htmlEscape/htmlEscape.js';
import { getCurrencyFromBidderRequest } from '../libraries/ortb2Utils/currency.js';
import { tryAppendQueryString } from '../libraries/urlUtils/urlUtils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE } from '../src/mediaTypes.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
import { deepAccess, getBidIdParameter } from '../src/utils.js';

/**
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest
Expand Down Expand Up @@ -61,7 +61,7 @@ export const spec = {
data = tryAppendQueryString(data, 't', 'json3');
data = tryAppendQueryString(data, 'transactionid', validReq.ortb2Imp?.ext?.tid);
data = tryAppendQueryString(data, 'sizes', getSizes(validReq));
data = tryAppendQueryString(data, 'currency', getCurrencyType());
data = tryAppendQueryString(data, 'currency', getCurrencyType(bidderRequest));
data = tryAppendQueryString(data, 'pbver', '$prebid.version$');
data = tryAppendQueryString(data, 'sdkname', 'prebidjs');
data = tryAppendQueryString(data, 'adapterver', ADGENE_PREBID_VERSION);
Expand Down Expand Up @@ -94,7 +94,8 @@ export const spec = {
method: 'GET',
url: url,
data: data,
bidRequest: validBidRequests[i]
bidRequest: validBidRequests[i],
bidderRequest
});
}
return serverRequests;
Expand All @@ -119,7 +120,7 @@ export const spec = {
height: body.h ? body.h : 1,
creativeId: body.creativeid || '',
dealId: body.dealid || '',
currency: getCurrencyType(),
currency: getCurrencyFromBidderRequest(bidRequests.bidderRequest),
netRevenue: true,
ttl: body.ttl || 10,
};
Expand Down Expand Up @@ -304,9 +305,9 @@ function getSizes(validReq) {
/**
* @return {?string} USD or JPY
*/
function getCurrencyType() {
if (config.getConfig('currency.adServerCurrency') && config.getConfig('currency.adServerCurrency').toUpperCase() === 'USD') return 'USD';
return 'JPY';
function getCurrencyType(bidderRequest) {
const adServerCurrency = getCurrencyFromBidderRequest(bidderRequest) || ''
return adServerCurrency.toUpperCase() === 'USD' ? 'USD' : 'JPY'
}

/**
Expand Down
3 changes: 2 additions & 1 deletion modules/adkernelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export const spec = {
{code: 'rxnetwork'},
{code: 'revbid'},
{code: 'spinx', gvlid: 1308},
{code: 'oppamedia'}
{code: 'oppamedia'},
{code: 'pixelpluses', gvlid: 1209}
],
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

Expand Down
14 changes: 6 additions & 8 deletions modules/admaticBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {getValue, formatQS, logError, deepAccess, isArray, getBidIdParameter} from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js';
import { getCurrencyFromBidderRequest } from '../libraries/ortb2Utils/currency.js';
import { Renderer } from '../src/Renderer.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { deepAccess, formatQS, getBidIdParameter, getValue, isArray, logError } from '../src/utils.js';
import {getUserSyncParams} from '../libraries/userSyncUtils/userSyncUtils.js';
import { interpretNativeAd } from '../libraries/precisoUtils/bidNativeUtils.js';

Expand Down Expand Up @@ -56,6 +56,7 @@ export const spec = {
const ortb = bidderRequest.ortb2;
const networkId = getValue(validBidRequests[0].params, 'networkId');
let host = getValue(validBidRequests[0].params, 'host');
const currency = getCurrencyFromBidderRequest(bidderRequest) || 'TRY';
const bidderName = validBidRequests[0].bidder;

const payload = {
Expand Down Expand Up @@ -84,10 +85,7 @@ export const spec = {
tmax: parseInt(tmax)
};

if (config.getConfig('currency.adServerCurrency')) {
payload.ext.cur = config.getConfig('currency.adServerCurrency');
}

payload.ext.cur = currency;
if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) {
const consentStr = (bidderRequest.gdprConsent.consentString)
? bidderRequest.gdprConsent.consentString.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '') : '';
Expand Down
2 changes: 1 addition & 1 deletion modules/admixerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function getBidFloor(bid) {
mediaType: '*',
size: '*',
});
return bidFloor.floor;
return bidFloor?.floor;
} catch (_) {
return 0;
}
Expand Down
19 changes: 10 additions & 9 deletions modules/adotBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Renderer} from '../src/Renderer.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {isArray, isBoolean, isFn, isPlainObject, isStr, logError, replaceAuctionPrice} from '../src/utils.js';
import {find} from '../src/polyfill.js';
import {config} from '../src/config.js';
import {OUTSTREAM} from '../src/video.js';
import { getCurrencyFromBidderRequest } from '../libraries/ortb2Utils/currency.js';
import { Renderer } from '../src/Renderer.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
import { find } from '../src/polyfill.js';
import { isArray, isBoolean, isFn, isPlainObject, isStr, logError, replaceAuctionPrice } from '../src/utils.js';
import { OUTSTREAM } from '../src/video.js';
import { NATIVE_ASSETS_IDS as NATIVE_ID_MAPPING, NATIVE_ASSETS as NATIVE_PLACEMENTS } from '../libraries/braveUtils/nativeAssets.js';

/**
Expand Down Expand Up @@ -310,7 +311,7 @@ function buildImpFromAdUnit(adUnit, bidderRequest) {
if (!mediaType) return null;

const media = IMP_BUILDER[mediaType](mediaTypes[mediaType], bidderRequest, adUnit)
const currency = config.getConfig('currency.adServerCurrency') || DEFAULT_CURRENCY;
const currency = getCurrencyFromBidderRequest(bidderRequest) || DEFAULT_CURRENCY;
const bidfloor = getMainFloor(adUnit, media.format, mediaType, currency);

return {
Expand Down Expand Up @@ -641,7 +642,7 @@ function getFloor(adUnit, size, mediaType, currency) {

const floorResult = adUnit.getFloor({ currency, mediaType, size });

return floorResult.currency === currency ? floorResult.floor : 0;
return floorResult?.currency === currency ? floorResult?.floor : 0;
}

/**
Expand Down
Loading

0 comments on commit b08648a

Please sign in to comment.