Skip to content

Commit

Permalink
Merge branch 'prebid:master' into adverxo_adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-adverxo committed Nov 9, 2024
2 parents 43a2ac0 + f71023d commit 4cb971c
Show file tree
Hide file tree
Showing 62 changed files with 2,843 additions and 773 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Prebid.js is open source software that is offered for free as a convenience. Whi

*Note:* Requires Prebid.js v1.38.0+

Prebid.js depends on Babel and some Babel Plugins in order to run correctly in the browser. Here are some examples for
Prebid.js depends on Babel and some Babel Plugins in order to run correctly in the browser. Here are some examples for
configuring webpack to work with Prebid.js.

With Babel 7:
Expand All @@ -37,7 +37,7 @@ module.exports = {
mode: 'production',
module: {
rules: [

// this rule can be excluded if you don't require babel-loader for your other application files
{
test: /\.m?js$/,
Expand All @@ -46,7 +46,7 @@ module.exports = {
loader: 'babel-loader',
}
},

// this separate rule is required to make sure that the Prebid.js files are babel-ified. this rule will
// override the regular exclusion from above (for being inside node_modules).
{
Expand All @@ -71,15 +71,15 @@ Or for Babel 6:
// you must manually install and specify the presets and plugins yourself
options: {
plugins: [
"transform-object-assign", // required (for IE support) and "babel-plugin-transform-object-assign"
"transform-object-assign", // required (for IE support) and "babel-plugin-transform-object-assign"
// must be installed as part of your package.
require('prebid.js/plugins/pbjsGlobals.js') // required!
],
presets: [
["env", { // you can use other presets if you wish.
"targets": { // this example is using "babel-presets-env", which must be installed if you
"browsers": [ // follow this example.
... // your browser targets. they should probably match the targets you're using for the rest
... // your browser targets. they should probably match the targets you're using for the rest
// of your application
]
}
Expand Down Expand Up @@ -143,7 +143,7 @@ This will run testing but not linting. A web server will start at `http://localh

Development may be a bit slower but if you prefer linting and additional watch files you can also still run just:

$ gulp serve
$ gulp serve


### Build Optimization
Expand All @@ -162,11 +162,11 @@ Building with just these adapters will result in a smaller bundle which should a
- Then run the build:

$ gulp build --modules=openxBidAdapter,rubiconBidAdapter,sovrnBidAdapter

Alternatively, a `.json` file can be specified that contains a list of modules you would like to include.

$ gulp build --modules=modules.json

With `modules.json` containing the following
```json modules.json
[
Expand Down Expand Up @@ -202,7 +202,7 @@ gulp bundle --tag one --modules=one.json
gulp bundle --tag two --modules=two.json
```

This generates slightly larger files, but has the advantage of being much faster to run (after the initial `gulp build`). It's also the method used by [the Prebid.org download page](https://docs.prebid.org/download.html).
This generates slightly larger files, but has the advantage of being much faster to run (after the initial `gulp build`). It's also the method used by [the Prebid.org download page](https://docs.prebid.org/download.html).

<a name="Run"></a>

Expand Down Expand Up @@ -378,7 +378,7 @@ For instructions on writing tests for Prebid.js, see [Testing Prebid.js](https:/

### Supported Browsers

Prebid.js is supported on IE11 and modern browsers until 5.x. 6.x+ transpiles to target >0.25%; not Opera Mini; not IE11.
Prebid.js is supported on IE11 and modern browsers until 5.x. 6.x+ transpiles to target >0.25%; not Opera Mini; not IE11.

### Governance
Review our governance model [here](https://github.com/prebid/Prebid.js/tree/master/governance.md).
Expand Down
70 changes: 70 additions & 0 deletions libraries/biddoInvamiaUtils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Helper function to build request payload for banner ads.
* @param {Object} bidRequest - The bid request object.
* @param {string} endpointUrl - The endpoint URL specific to the bidder.
* @returns {Array} An array of server requests.
*/
export function buildBannerRequests(bidRequest, endpointUrl) {
const serverRequests = [];
const sizes = bidRequest.mediaTypes.banner.sizes;

sizes.forEach(([width, height]) => {
bidRequest.params.requestedSizes = [width, height];

const payload = {
ctype: 'div',
pzoneid: bidRequest.params.zoneId,
width,
height,
};

const payloadString = Object.keys(payload)
.map((key) => `${key}=${encodeURIComponent(payload[key])}`)
.join('&');

serverRequests.push({
method: 'GET',
url: endpointUrl,
data: payloadString,
bidderRequest: bidRequest,
});
});

return serverRequests;
}

/**
* Helper function to interpret server response for banner ads.
* @param {Object} serverResponse - The server response object.
* @param {Object} bidderRequest - The matched bid request for this response.
* @returns {Array} An array of bid responses.
*/
export function interpretBannerResponse(serverResponse, bidderRequest) {
const response = serverResponse.body;
const bidResponses = [];

if (response && response.template && response.template.html) {
const { bidId } = bidderRequest;
const [width, height] = bidderRequest.params.requestedSizes;

const bidResponse = {
requestId: bidId,
cpm: response.hb.cpm,
creativeId: response.banner.hash,
currency: 'USD',
netRevenue: response.hb.netRevenue,
ttl: 600,
ad: response.template.html,
mediaType: 'banner',
meta: {
advertiserDomains: response.hb.adomains || [],
},
width,
height,
};

bidResponses.push(bidResponse);
}

return bidResponses;
}
30 changes: 30 additions & 0 deletions libraries/equativUtils/equativUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { VIDEO } from '../../src/mediaTypes.js';
import { deepAccess, isFn } from '../../src/utils.js';

const DEFAULT_FLOOR = 0.0;

/**
* Get floors from Prebid Price Floors module
*
* @param {object} bid Bid request object
* @param {string} currency Ad server currency
* @param {string} mediaType Bid media type
* @return {number} Floor price
*/
export function getBidFloor (bid, currency, mediaType) {
const floors = [];

if (isFn(bid.getFloor)) {
(deepAccess(bid, `mediaTypes.${mediaType}.${mediaType === VIDEO ? 'playerSize' : 'sizes'}`) || []).forEach(size => {
const floor = bid.getFloor({
currency: currency || 'USD',
mediaType,
size
}).floor;

floors.push(!isNaN(floor) ? floor : DEFAULT_FLOOR);
});
}

return floors.length ? Math.min(...floors) : DEFAULT_FLOOR;
}
7 changes: 4 additions & 3 deletions libraries/liveIntentId/externalIdSystem.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { logError } from '../../src/utils.js';
import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../../src/adapterManager.js';
import { submodule } from '../../src/hook.js';
import { DEFAULT_AJAX_TIMEOUT, MODULE_NAME, parseRequestedAttributes, composeIdObject, eids, GVLID, PRIMARY_IDS } from './shared.js'
import { DEFAULT_AJAX_TIMEOUT, MODULE_NAME, parseRequestedAttributes, composeIdObject, eids, GVLID, PRIMARY_IDS, makeSourceEventToSend } from './shared.js'

// Reference to the client for the liQHub.
let cachedClientRef
Expand Down Expand Up @@ -97,8 +97,9 @@ function initializeClient(configParams) {
resolveSettings
})

if (configParams.emailHash != null) {
window.liQHub.push({ type: 'collect', clientRef, sourceEvent: { hash: configParams.emailHash } })
let sourceEvent = makeSourceEventToSend(configParams)
if (sourceEvent != null) {
window.liQHub.push({ type: 'collect', clientRef, sourceEvent })
}

cachedClientRef = clientRef
Expand Down
19 changes: 13 additions & 6 deletions libraries/liveIntentId/idSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { submodule } from '../../src/hook.js';
import { LiveConnect } from 'live-connect-js'; // eslint-disable-line prebid/validate-imports
import { getStorageManager } from '../../src/storageManager.js';
import { MODULE_TYPE_UID } from '../../src/activities/modules.js';
import { DEFAULT_AJAX_TIMEOUT, MODULE_NAME, composeIdObject, eids, GVLID, DEFAULT_DELAY, PRIMARY_IDS, parseRequestedAttributes } from './shared.js'
import { DEFAULT_AJAX_TIMEOUT, MODULE_NAME, composeIdObject, eids, GVLID, DEFAULT_DELAY, PRIMARY_IDS, parseRequestedAttributes, makeSourceEventToSend } from './shared.js'

/**
* @typedef {import('../modules/userId/index.js').Submodule} Submodule
Expand All @@ -23,7 +23,7 @@ const EVENTS_TOPIC = 'pre_lips';

export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME});
const calls = {
ajaxGet: (url, onSuccess, onError, timeout) => {
ajaxGet: (url, onSuccess, onError, timeout, headers) => {
ajaxBuilder(timeout)(
url,
{
Expand All @@ -33,7 +33,8 @@ const calls = {
undefined,
{
method: 'GET',
withCredentials: true
withCredentials: true,
customHeaders: headers
}
)
},
Expand Down Expand Up @@ -92,7 +93,11 @@ function initializeLiveConnect(configParams) {
const publisherId = configParams.publisherId || 'any';
const identityResolutionConfig = {
publisherId: publisherId,
requestedAttributes: parseRequestedAttributes(configParams.requestedAttributesOverrides)
requestedAttributes: parseRequestedAttributes(configParams.requestedAttributesOverrides),
extraAttributes: {
ipv4: configParams.ipv4,
ipv6: configParams.ipv6
}
};
if (configParams.url) {
identityResolutionConfig.url = configParams.url;
Expand Down Expand Up @@ -136,8 +141,10 @@ function initializeLiveConnect(configParams) {
// The second param is the storage object, LS & Cookie manipulation uses PBJS.
// The third param is the ajax and pixel object, the AJAX and pixel use PBJS.
liveConnect = liveIntentIdSubmodule.getInitializer()(liveConnectConfig, storage, calls);
if (configParams.emailHash) {
liveConnect.push({ hash: configParams.emailHash });

const sourceEvent = makeSourceEventToSend(configParams)
if (sourceEvent != null) {
liveConnect.push(sourceEvent);
}
return liveConnect;
}
Expand Down
25 changes: 25 additions & 0 deletions libraries/liveIntentId/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@ export function parseRequestedAttributes(overrides) {
}
}

export function makeSourceEventToSend(configParams) {
const sourceEvent = {}
let nonEmpty = false
if (typeof configParams.emailHash === 'string') {
nonEmpty = true
sourceEvent.emailHash = configParams.emailHash
}
if (typeof configParams.ipv4 === 'string') {
nonEmpty = true
sourceEvent.ipv4 = configParams.ipv4
}
if (typeof configParams.ipv6 === 'string') {
nonEmpty = true
sourceEvent.ipv6 = configParams.ipv6
}
if (typeof configParams.userAgent === 'string') {
nonEmpty = true
sourceEvent.userAgent = configParams.userAgent
}

if (nonEmpty) {
return sourceEvent
}
}

export function composeIdObject(value) {
const result = {};

Expand Down
12 changes: 11 additions & 1 deletion modules/adagioAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const cache = {
return { auctionId: null, adUnitCode: null }
}
};

const enc = window.encodeURIComponent;

/**
Expand Down Expand Up @@ -195,7 +196,14 @@ function handlerAuctionInit(event) {
const w = getBestWindowForAdagio();

const prebidAuctionId = event.auctionId;
const adUnitCodes = removeDuplicates(event.adUnitCodes, adUnitCode => adUnitCode);

// adUnitCodes come from `event.bidderRequests` to be sure to keep the ad-units that are valid and will be effectively used during the auction.
// This array can be different than `event.adUnitCodes` because of the usage of conditionnal ad-units (see: https://docs.prebid.org/dev-docs/conditional-ad-units.html)
const adUnitCodes = new Set(
event.bidderRequests
.map(br => br.bids.map(bid => bid.adUnitCode))
.flat()
);

// Check if Adagio is on the bid requests.
const adagioBidRequest = event.bidderRequests.find(bidRequest => isAdagio(bidRequest.bidderCode));
Expand All @@ -207,6 +215,7 @@ function handlerAuctionInit(event) {

adUnitCodes.forEach(adUnitCode => {
// event.adUnits are splitted by mediatypes
// having twin ad-unit codes is ok: https://docs.prebid.org/dev-docs/adunit-reference.html#twin-adunit-codes
const adUnits = event.adUnits.filter(adUnit => adUnit.code === adUnitCode);

// Get all bidders configured for the ad unit.
Expand Down Expand Up @@ -236,6 +245,7 @@ function handlerAuctionInit(event) {
const request = event.bidderRequests.find(br => br.bidderCode === bidder)
return request ? request.bids[0].src : null
}

const biddersSrc = sortedBidderNames.map(bidSrcMapper).join(',');
const biddersCode = sortedBidderNames.map(bidder => adapterManager.resolveAlias(bidder)).join(',');

Expand Down
10 changes: 1 addition & 9 deletions modules/aniviewBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const converter = ortbConverter({
imp(buildImp, bidRequest, context) {
const { mediaType } = context;
const imp = buildImp(bidRequest, context);
const isVideo = mediaType === VIDEO;
const isBanner = mediaType === BANNER;
const { width, height } = getSize(context, bidRequest);
const floor = getFloor(bidRequest, { width, height }, mediaType);
Expand All @@ -43,14 +42,7 @@ const converter = ortbConverter({
imp.bidfloorcur = DEFAULT_CURRENCY;
}

if (isVideo) {
deepSetValue(imp, `ext.${BIDDER_CODE}`, {
AV_WIDTH: width,
AV_HEIGHT: height,
bidWidth: width,
bidHeight: height,
});
} else if (isBanner) {
if (isBanner) {
// TODO: remove once serving will be fixed
deepSetValue(imp, 'banner', { w: width, h: height });
}
Expand Down
2 changes: 1 addition & 1 deletion modules/atsAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ atsAnalyticsAdapter.getUserAgent = function () {

atsAnalyticsAdapter.setSamplingCookie = function (samplRate) {
const now = new Date();
now.setTime(now.getTime() + 86400000);
now.setTime(now.getTime() + 604800000);
storage.setCookie('_lr_sampling_rate', samplRate, now.toUTCString());
}

Expand Down
Loading

0 comments on commit 4cb971c

Please sign in to comment.