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
DimaIntentIQ authored Oct 24, 2024
2 parents fcbe1f0 + c012232 commit a298a00
Show file tree
Hide file tree
Showing 106 changed files with 3,854 additions and 1,025 deletions.
1 change: 1 addition & 0 deletions integrationExamples/top-level-paapi/gam-contextual.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
debug: true,
paapi: {
enabled: true,
parallel: true,
gpt: {
autoconfig: false
},
Expand Down
1 change: 1 addition & 0 deletions integrationExamples/top-level-paapi/no_adserver.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
debug: true,
paapi: {
enabled: true,
parallel: true,
gpt: {
autoconfig: false
},
Expand Down
105 changes: 102 additions & 3 deletions libraries/audUtils/bidderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import {
logError
} from '../../src/utils.js';

// Declare native assets
const NATIVE_ASSETS = [
{ id: 1, required: 1, title: { len: 100 } }, // Title
{ id: 2, required: 1, img: { type: 3, w: 300, h: 250 } }, // Main image
{ id: 3, required: 0, data: { type: 1, len: 140 } }, // Body
{ id: 4, required: 1, data: { type: 2 } }, // Sponsored by
{ id: 5, required: 1, icon: { w: 50, h: 50 } }, // Icon
{ id: 6, required: 1, data: { type: 12, len: 15 } } // Call to action
];
// Function to get Request
export const getBannerRequest = (bidRequests, bidderRequest, ENDPOINT) => {
let request = [];
Expand Down Expand Up @@ -34,6 +43,7 @@ export const getBannerRequest = (bidRequests, bidderRequest, ENDPOINT) => {
if (bidderRequest?.uspConsent) {
deepSetValue(req, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}
req.MediaType = getMediaType(bidReq);
request.push(req);
});
// Return the array of request
Expand All @@ -48,6 +58,15 @@ export const getBannerRequest = (bidRequests, bidderRequest, ENDPOINT) => {
}
// Function to get Response
export const getBannerResponse = (bidResponse, mediaType) => {
return formatResponse(bidResponse, mediaType);
}
// Function to get NATIVE Response
export const getNativeResponse = (bidResponse, bidRequest, mediaType) => {
const assets = JSON.parse(JSON.parse(bidRequest.data)[0].imp[0].native.request).assets;
return formatResponse(bidResponse, mediaType, assets);
}
// Function to format response
const formatResponse = (bidResponse, mediaType, assets) => {
let responseArray = [];
if (bidResponse) {
try {
Expand All @@ -61,14 +80,28 @@ export const getBannerResponse = (bidResponse, mediaType) => {
response.height = bidReq.h;
response.ad = bidReq.adm;
response.meta = {
advertiserDomains: bidReq.adomain
advertiserDomains: bidReq.adomain,
primaryCatId: bidReq.cat || [],
attr: bidReq.attr || []
};
response.creativeId = bidReq.crid;
response.netRevenue = false;
response.currency = 'USD';
response.ttl = 300;
response.dealId = bidReq.dealId;
response.mediaType = mediaType;
if (mediaType == 'native') {
let nativeResp = JSON.parse(bidReq.adm).native;
let nativeData = {
clickUrl: nativeResp.link.url,
impressionTrackers: nativeResp.imptrackers
};
nativeResp.assets.forEach(asst => {
let data = getNativeAssestData(asst, assets);
nativeData[data.key] = data.value;
});
response.native = nativeData;
}
responseArray.push(response);
});
}
Expand All @@ -78,13 +111,18 @@ export const getBannerResponse = (bidResponse, mediaType) => {
}
return responseArray;
}
// Function to get imp
// Function to get imp based on Media Type
const getImpDetails = (bidReq) => {
let imp = {};
if (bidReq) {
imp.id = bidReq.bidId;
imp.bidfloor = getFloorPrice(bidReq);
imp.banner = getBannerDetails(bidReq);
if (bidReq.mediaTypes.native) {
let assets = { assets: NATIVE_ASSETS };
imp.native = { request: JSON.stringify(assets) };
} else if (bidReq.mediaTypes.banner) {
imp.banner = getBannerDetails(bidReq);
}
}
return imp;
}
Expand Down Expand Up @@ -137,3 +175,64 @@ const getUserDetails = (bidReq) => {
}
return user;
}
// Function to get asset data for response
const getNativeAssestData = (params, assets) => {
let response = {};
if (params.title) {
response.key = 'title';
response.value = params.title.text;
}
if (params.data) {
response.key = getAssetData(params.id, assets);
response.value = params.data.value;
}
if (params.img) {
response.key = getAssetImageDataType(params.id, assets);
response.value = {
url: params.img.url,
height: params.img.h,
width: params.img.w
}
}
return response;
}
// Function to get asset data types based on id
const getAssetData = (paramId, asset) => {
let resp = '';
for (let i = 0; i < asset.length; i++) {
if (asset[i].id == paramId) {
switch (asset[i].data.type) {
case 1 : resp = 'sponsored';
break;
case 2 : resp = 'desc';
break;
case 12 : resp = 'cta';
break;
}
}
}
return resp;
}
// Function to get image type based on the id
const getAssetImageDataType = (paramId, asset) => {
let resp = '';
for (let i = 0; i < asset.length; i++) {
if (asset[i].id == paramId) {
switch (asset[i].img.type) {
case 1 : resp = 'icon';
break;
case 3 : resp = 'image';
break;
}
}
}
return resp;
}
// Function to get Media Type
const getMediaType = (bidReq) => {
if (bidReq.mediaTypes.native) {
return 'native';
} else if (bidReq.mediaTypes.banner) {
return 'banner';
}
}
2 changes: 1 addition & 1 deletion 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, DEFAULT_DELAY, GVLID, PRIMARY_IDS, parseRequestedAttributes } from './shared.js'
import { DEFAULT_AJAX_TIMEOUT, MODULE_NAME, composeIdObject, eids, GVLID, DEFAULT_DELAY, PRIMARY_IDS, parseRequestedAttributes } from './shared.js'

/**
* @typedef {import('../modules/userId/index.js').Submodule} Submodule
Expand Down
1 change: 1 addition & 0 deletions libraries/liveIntentId/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { coppaDataHandler } from '../../src/adapterManager.js';
export const PRIMARY_IDS = ['libp'];
export const GVLID = 148;
export const DEFAULT_AJAX_TIMEOUT = 5000;
export const DEFAULT_DELAY = 500;
export const MODULE_NAME = 'liveIntentId';
export const LI_PROVIDER_DOMAIN = 'liveintent.com';
export const DEFAULT_REQUESTED_ATTRIBUTES = { 'nonId': true };
Expand Down
5 changes: 3 additions & 2 deletions modules/51DegreesRtdProvider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MODULE_TYPE_RTD } from '../src/activities/modules.js';
import {loadExternalScript} from '../src/adloader.js';
import {submodule} from '../src/hook.js';
import {
Expand Down Expand Up @@ -263,7 +264,7 @@ export const getBidRequestData = (reqBidsConfigObj, callback, moduleConfig, user
}

// Inject 51Degrees script, get device data and merge it into the ORTB2 object
loadExternalScript(scriptURL, MODULE_NAME, () => {
loadExternalScript(scriptURL, MODULE_TYPE_RTD, MODULE_NAME, () => {
logMessage('Successfully injected 51Degrees script');
const fod = /** @type {Object} */ (window.fod);
// Convert and merge device data in the callback
Expand All @@ -276,7 +277,7 @@ export const getBidRequestData = (reqBidsConfigObj, callback, moduleConfig, user
logMessage('reqBidsConfigObj: ', reqBidsConfigObj);
callback();
});
});
}, document, {crossOrigin: 'anonymous'});
} catch (error) {
// In case of an error, log it and continue
logError(error);
Expand Down
2 changes: 1 addition & 1 deletion modules/a1MediaRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function loadLbScript(tagname) {
linkback.l = true;

const scriptUrl = `${SCRIPT_URL}/${tagname}`;
loadExternalScript(scriptUrl, MODULE_NAME);
loadExternalScript(scriptUrl, MODULE_TYPE_RTD, MODULE_NAME);
}
}

Expand Down
3 changes: 2 additions & 1 deletion modules/aaxBlockmeterRtdProvider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {isEmptyStr, isStr, logError, isFn, logWarn} from '../src/utils.js';
import {submodule} from '../src/hook.js';
import { loadExternalScript } from '../src/adloader.js';
import { MODULE_TYPE_RTD } from '../src/activities/modules.js';

export const _config = {
MODULE: 'aaxBlockmeter',
Expand Down Expand Up @@ -28,7 +29,7 @@ function loadBlockmeter(_rtdConfig) {
}

const scriptUrl = `https://${url}&${params.join('&')}`;
loadExternalScript(scriptUrl, _config.MODULE);
loadExternalScript(scriptUrl, MODULE_TYPE_RTD, _config.MODULE);
return true;
}

Expand Down
5 changes: 4 additions & 1 deletion modules/adagioRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ function loadAdagioScript(config) {
return;
}

loadExternalScript(SCRIPT_URL, SUBMODULE_NAME, undefined, undefined, { id: `adagiojs-${getUniqueIdentifierStr()}`, 'data-pid': config.params.organizationId });
loadExternalScript(SCRIPT_URL, MODULE_TYPE_RTD, SUBMODULE_NAME, undefined, undefined, {
id: `adagiojs-${getUniqueIdentifierStr()}`,
'data-pid': config.params.organizationId
});
});
}

Expand Down
3 changes: 2 additions & 1 deletion modules/adlooxAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
parseUrl
} from '../src/utils.js';
import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js';
import { MODULE_TYPE_ANALYTICS } from '../src/activities/modules.js';

const MODULE = 'adlooxAnalyticsAdapter';

Expand Down Expand Up @@ -262,7 +263,7 @@ analyticsAdapter[`handle_${EVENTS.BID_WON}`] = function(bid) {
[ 'creatype', '%%creatype%%' ]
]);

loadExternalScript(analyticsAdapter.url(`${analyticsAdapter.context.js}#`, params, bid), 'adloox');
loadExternalScript(analyticsAdapter.url(`${analyticsAdapter.context.js}#`, params, bid), MODULE_TYPE_ANALYTICS, 'adloox');
}

adapterManager.registerAnalyticsAdapter({
Expand Down
4 changes: 3 additions & 1 deletion modules/ads_interactiveBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { isBidRequestValid, buildRequests, interpretResponse, getUserSyncs } from '../libraries/teqblazeUtils/bidderUtils.js';

const BIDDER_CODE = 'ads_interactive';
const AD_URL = 'https://bntb.adsintreactive.com/pbjs';
const AD_URL = 'https://bntb.adsinteractive.com/pbjs';
const SYNC_URL = 'https://cstb.adsinteractive.com';
const GVLID = 1212;

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

isBidRequestValid: isBidRequestValid(),
Expand Down
2 changes: 1 addition & 1 deletion modules/airgridRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function attachScriptTagToDOM(rtdConfig) {
edktInitializor.apiKey = rtdConfig.params.apiKey;
edktInitializor.invoked = true;
const moduleSrc = getModuleUrl(rtdConfig.params.accountId);
loadExternalScript(moduleSrc, SUBMODULE_NAME);
loadExternalScript(moduleSrc, MODULE_TYPE_RTD, SUBMODULE_NAME);
}
}

Expand Down
Loading

0 comments on commit a298a00

Please sign in to comment.