Skip to content

Commit

Permalink
Prebid Core: switch native assets to ortb2 format (prebid#8086)
Browse files Browse the repository at this point in the history
* switch native assets to ortb2 format

* put rendererUrl, adTemplate back in message

* rename ortb2 to ortb

* typo fix

* changes to support ortb for native media type

* handle bid won case

* mark bid as won on any post message for native

* fix tests for bid_won event for native

* add missing imports

* native converting functions

* convert new native ortb media type object to proprietary format for native bidders

* fix LGTM.com issue

* added comments; minor fixes

* added test for convertOrtbRequestToProprietaryNative + fixes

* add nativeParams to conversion

* support nativeParams

* check that when native.ortb is present, it's the only property

* remove commented code

* removed unnecessary tests

* added test that checks that BID_WON is not fired more than once for the same adId

* validation is now performed on ortb data only

* fix for prebidServer_native_example.html

* PrebidServerBidAdapter also responds in ortb format

* fix aspect_ratios as an array in tests

* LGTM fix - remove unused variables

* Better name for native constants

* use WeakSet instead of Set

* when native request is openRTB, the whole native.ortb is passed over

* retain some defaults dor native PBS request

* fix for empty ortbRequest in nativeBidIsValid

* add non-asset properties to media type object

* final fixes after rebasing

* handle tracking of soon-deprecated ortb imptrackers and jstracker

* let native ad unit take all horizontal space

* pass "mapping" from legacy native to ortb to prebid universal creative

* Convert ortb assets to legacy for backward compatibility with legacy templates

* add ortb conversion for more bid adapters

* wrap conversion function in FEATURES.NATIVE

* remove expired bids from native wrapper

* instead of modifying bidresponse, use nativeReq

* wrap test in FEATURES.NATIVE

* fix for native mapping in prebidServerBidAdapter

* use copy-on-write to convert ortb requests to legacy

* fix comment on function

* Update criteoBidAdapter.js

Co-authored-by: Filip Stamenkovic <[email protected]>
Co-authored-by: Michele Nasti <[email protected]>
Co-authored-by: Patrick McCann <[email protected]>
  • Loading branch information
4 people authored and jorgeluisrocha committed May 18, 2023
1 parent ddb56cf commit ccef107
Show file tree
Hide file tree
Showing 95 changed files with 1,652 additions and 396 deletions.
4 changes: 2 additions & 2 deletions integrationExamples/gpt/prebidServer_native_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@
<script>
// GPT setup
googletag.cmd.push(function () {
// var slot1 = googletag.defineSlot('/19968336/prebid_native_example_1', [[360, 360]], 'div-1').addService(googletag.pubads());
// var slot2 = googletag.defineSlot('/19968336/prebid_native_example_2', 'fluid', 'div-2').addService(googletag.pubads());
googletag.defineSlot('/19968336/prebid_native_example_1', [[360, 360]], 'div-1').addService(googletag.pubads());
googletag.defineSlot('/19968336/prebid_native_example_2', 'fluid', 'div-2').addService(googletag.pubads());
googletag.pubads().disableInitialLoad();
googletag.pubads().enableSingleRequest();
googletag.enableServices();
Expand Down
4 changes: 4 additions & 0 deletions modules/ablidaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { triggerPixel } from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'ablida';
const ENDPOINT_URL = 'https://bidder.ablida.net/prebid';
Expand All @@ -28,6 +29,9 @@ export const spec = {
* @param bidderRequest
*/
buildRequests: function (validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

if (validBidRequests.length === 0) {
return [];
}
Expand Down
4 changes: 4 additions & 0 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {Renderer} from '../src/Renderer.js';
import {OUTSTREAM} from '../src/video.js';
import { getGlobal } from '../src/prebidGlobal.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'adagio';
const LOG_PREFIX = 'Adagio:';
Expand Down Expand Up @@ -882,6 +883,9 @@ export const spec = {
},

buildRequests(validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

const secure = (location.protocol === 'https:') ? 1 : 0;
const device = internal.getDevice();
const site = internal.getSite(bidderRequest);
Expand Down
4 changes: 4 additions & 0 deletions modules/adbookpspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
uniques
} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

/**
* CONSTANTS
Expand Down Expand Up @@ -101,6 +102,9 @@ function isBidRequestValid(bidRequest) {
}

function buildRequests(validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

const requests = [];

if (validBidRequests.length > 0) {
Expand Down
4 changes: 4 additions & 0 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 {_map, deepAccess, deepSetValue, mergeDeep, parseSizesInput} from '../src/utils.js';
import {config} from '../src/config.js';
import {Renderer} from '../src/Renderer.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const { getConfig } = config;

Expand Down Expand Up @@ -60,6 +61,9 @@ export const spec = {
return !!(mid || (inv && mname));
},
buildRequests: (validBidRequests, bidderRequest) => {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

let app, site;

const commonFpd = bidderRequest.ortb2 || {};
Expand Down
3 changes: 3 additions & 0 deletions modules/adgenerationBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {tryAppendQueryString, 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';

const ADG_BIDDER_CODE = 'adgeneration';

Expand All @@ -25,6 +26,8 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
const ADGENE_PREBID_VERSION = '1.4.0';
let serverRequests = [];
for (let i = 0, len = validBidRequests.length; i < len; i++) {
Expand Down
4 changes: 4 additions & 0 deletions modules/adkernelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {find, includes} from '../src/polyfill.js';
import {config} from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

/*
* In case you're AdKernel whitelable platform's client who needs branded adapter to
Expand Down Expand Up @@ -119,6 +120,9 @@ export const spec = {
* @returns {ServerRequest[]}
*/
buildRequests: function (bidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);

let impGroups = groupImpressionsByHostZone(bidRequests, bidderRequest.refererInfo);
let requests = [];
let schain = bidRequests[0].schain;
Expand Down
4 changes: 4 additions & 0 deletions modules/admanBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { isFn, deepAccess, logMessage } from '../src/utils.js';
import {config} from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'adman';
const AD_URL = 'https://pub.admanmedia.com/?c=o&m=multi';
Expand Down Expand Up @@ -63,6 +64,9 @@ export const spec = {
},

buildRequests: (validBidRequests = [], bidderRequest) => {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

let winTop = window;
let location;
// TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin
Expand Down
4 changes: 4 additions & 0 deletions modules/admixerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { logError } 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 { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'admixer';
const ALIASES = ['go2net', 'adblender', 'adsyield', 'futureads'];
Expand All @@ -20,6 +21,9 @@ export const spec = {
* Make a server request from the list of BidRequests.
*/
buildRequests: function (validRequest, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validRequest = convertOrtbRequestToProprietaryNative(validRequest);

let w;
let docRef;
do {
Expand Down
4 changes: 4 additions & 0 deletions modules/adnowBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE} from '../src/mediaTypes.js';
import {deepAccess, parseQueryStringParameters, parseSizesInput} from '../src/utils.js';
import {includes} from '../src/polyfill.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'adnow';
const ENDPOINT = 'https://n.ads3-adnow.com/a';
Expand Down Expand Up @@ -48,6 +49,9 @@ export const spec = {
* @return {ServerRequest}
*/
buildRequests(validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

return validBidRequests.map(req => {
const mediaType = this._isBannerRequest(req) ? BANNER : NATIVE;
const codeId = parseInt(req.params.codeId, 10);
Expand Down
3 changes: 3 additions & 0 deletions modules/adotBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {isArray, isBoolean, isFn, isPlainObject, isStr, logError, replaceAuction
import {find} from '../src/polyfill.js';
import {config} from '../src/config.js';
import {OUTSTREAM} from '../src/video.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'adot';
const ADAPTER_VERSION = 'v2.0.0';
Expand Down Expand Up @@ -373,6 +374,8 @@ function splitAdUnits(validBidRequests) {
* @returns {Array<AjaxRequest>}
*/
function buildRequests(validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
const adUnits = splitAdUnits(validBidRequests);
const publisherPathConfig = config.getConfig('adot.publisherPath');
const publisherPath = publisherPathConfig === undefined ? '' : '/' + publisherPathConfig;
Expand Down
4 changes: 4 additions & 0 deletions modules/adprimeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { isFn, deepAccess, logMessage } from '../src/utils.js';
import { config } from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'adprime';
const AD_URL = 'https://delta.adprime.com/pbjs';
Expand Down Expand Up @@ -50,6 +51,9 @@ export const spec = {
},

buildRequests: (validBidRequests = [], bidderRequest) => {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

let winTop = window;
let location;
// TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin
Expand Down
4 changes: 4 additions & 0 deletions modules/adrelevantisBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {find, includes} from '../src/polyfill.js';
import {INSTREAM, OUTSTREAM} from '../src/video.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'adrelevantis';
const URL = 'https://ssp.adrelevantis.com/prebid';
Expand Down Expand Up @@ -71,6 +72,9 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function(bidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);

const tags = bidRequests.map(bidToTag);
const userObjBid = find(bidRequests, hasUserInfo);
let userObj;
Expand Down
3 changes: 3 additions & 0 deletions modules/adrinoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import {triggerPixel} from '../src/utils.js';
import {NATIVE} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'adrino';
const REQUEST_METHOD = 'POST';
Expand All @@ -28,6 +29,8 @@ export const spec = {
},

buildRequests: function (validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
const bidRequests = [];

for (let i = 0; i < validBidRequests.length; i++) {
Expand Down
4 changes: 4 additions & 0 deletions modules/adtrueBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
import {getStorageManager} from '../src/storageManager.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'adtrue';
const storage = getStorageManager({bidderCode: BIDDER_CODE});
Expand Down Expand Up @@ -450,6 +451,9 @@ export const spec = {
},

buildRequests: function (validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

let refererInfo;
if (bidderRequest && bidderRequest.refererInfo) {
refererInfo = bidderRequest.refererInfo;
Expand Down
4 changes: 4 additions & 0 deletions modules/aduptechBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {deepAccess, getAdUnitSizes} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE} from '../src/mediaTypes.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

export const BIDDER_CODE = 'aduptech';
export const ENDPOINT_URL_PUBLISHER_PLACEHOLDER = '{PUBLISHER}';
Expand Down Expand Up @@ -198,6 +199,9 @@ export const spec = {
* @returns {Object[]}
*/
buildRequests: (validBidRequests, bidderRequest) => {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

const requests = [];

// stop here on invalid or empty data
Expand Down
4 changes: 4 additions & 0 deletions modules/adxcgBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
triggerPixel
} from '../src/utils.js';
import {config} from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const { getConfig } = config;

Expand Down Expand Up @@ -65,6 +66,9 @@ export const spec = {
return !!(adzoneid);
},
buildRequests: (validBidRequests, bidderRequest) => {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

let app, site;

const commonFpd = bidderRequest.ortb2 || {};
Expand Down
3 changes: 3 additions & 0 deletions modules/adyoulikeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import {createEidsArray} from './userId/eids.js';
import {find} from '../src/polyfill.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const VERSION = '1.0';
const BIDDER_CODE = 'adyoulike';
Expand Down Expand Up @@ -60,6 +61,8 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (bidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);
let hasVideo = false;
const payload = {
Version: VERSION,
Expand Down
4 changes: 4 additions & 0 deletions modules/ajaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getBidIdParameter, tryAppendQueryString, createTrackPixelHtml, logError
import { Renderer } from '../src/Renderer.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { VIDEO, BANNER, NATIVE } from '../src/mediaTypes.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'aja';
const URL = 'https://ad.as.amanad.adtdp.com/v2/prebid';
Expand Down Expand Up @@ -35,6 +36,9 @@ export const spec = {
* @returns {ServerRequest|ServerRequest[]}
*/
buildRequests: function(validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

const bidRequests = [];
const pageUrl = bidderRequest?.refererInfo?.page || undefined;

Expand Down
4 changes: 4 additions & 0 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {INSTREAM, OUTSTREAM} from '../src/video.js';
import {getStorageManager} from '../src/storageManager.js';
import {bidderSettings} from '../src/bidderSettings.js';
import {hasPurpose1Consent} from '../src/utils/gpdr.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'appnexus';
const URL = 'https://ib.adnxs.com/ut/v3/prebid';
Expand Down Expand Up @@ -122,6 +123,9 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (bidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);

const tags = bidRequests.map(bidToTag);
const userObjBid = find(bidRequests, hasUserInfo);
let userObj = {};
Expand Down
3 changes: 3 additions & 0 deletions modules/apstreamBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { generateUUID, deepAccess, createTrackPixelHtml, getDNT } from '../src/u
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { getStorageManager } from '../src/storageManager.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const CONSTANTS = {
DSU_KEY: 'apr_dsu',
Expand Down Expand Up @@ -416,6 +417,8 @@ function isBidRequestValid(bid) {
}

function buildRequests(bidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);
const data = {
med: encodeURIComponent(window.location.href),
auid: bidderRequest.auctionId,
Expand Down
4 changes: 4 additions & 0 deletions modules/bidscubeBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { logMessage, getWindowLocation } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js'
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'bidscube'
const URL = 'https://supply.bidscube.com/?c=o&m=multi'
Expand All @@ -15,6 +16,9 @@ export const spec = {
},

buildRequests: function (validBidRequests) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

validBidRequests = validBidRequests || []
let winTop = window
try {
Expand Down
Loading

0 comments on commit ccef107

Please sign in to comment.