Skip to content

Commit

Permalink
Ozone Project Bid Adapter: Support for auctionId and transactionId wh…
Browse files Browse the repository at this point in the history
…en a publisher opts in (#12267)

* Update ozoneBidAdapter_spec.js

* Update ozoneBidAdapter.js

* Update ozoneBidAdapter_spec.js

* Update ozoneBidAdapter_spec.js

* Update ozoneBidAdapter.js

updated device object values to come from ortb.device
  • Loading branch information
AskRupert-DM authored Sep 25, 2024
1 parent 77b974d commit 2b5a767
Show file tree
Hide file tree
Showing 2 changed files with 761 additions and 22 deletions.
49 changes: 27 additions & 22 deletions modules/ozoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const AUCTIONURI = '/openrtb2/auction';
const OZONECOOKIESYNC = '/static/load-cookie.html';
const OZONE_RENDERER_URL = 'https://prebid.the-ozone-project.com/ozone-renderer.js';
const ORIGIN_DEV = 'https://test.ozpr.net';
const OZONEVERSION = '2.9.3';
const OZONEVERSION = '2.9.4';
export const spec = {
gvlid: 524,
aliases: [{code: 'lmc', gvlid: 524}, {code: 'venatus', gvlid: 524}],
Expand Down Expand Up @@ -227,9 +227,13 @@ export const spec = {
const getParams = this.getGetParametersAsObject();
const wlOztestmodeKey = whitelabelPrefix + 'testmode';
const isTestMode = getParams[wlOztestmodeKey] || null; // this can be any string, it's used for testing ads
ozoneRequest.device = {'w': window.innerWidth, 'h': window.innerHeight};
ozoneRequest.device = bidderRequest?.ortb2?.device || {};
let placementIdOverrideFromGetParam = this.getPlacementIdOverrideFromGetParam(); // null or string
let schain = null;
var auctionId = deepAccess(validBidRequests, '0.ortb2.source.tid');
if (auctionId === '0') {
auctionId = null;
}
let tosendtags = validBidRequests.map(ozoneBidRequest => {
var obj = {};
let placementId = placementIdOverrideFromGetParam || this.getPlacementId(ozoneBidRequest); // prefer to use a valid override param, else the bidRequest placement Id
Expand Down Expand Up @@ -329,6 +333,13 @@ export const spec = {
if (gpid) {
deepSetValue(obj, 'ext.gpid', gpid);
}
let transactionId = deepAccess(ozoneBidRequest, 'ortb2Imp.ext.tid');
if (transactionId) {
obj.ext[whitelabelBidder].transactionId = transactionId; // this is the transactionId PER adUnit, common across bidders for this unit
}
if (auctionId) {
obj.ext[whitelabelBidder].auctionId = auctionId; // we were sent a valid auctionId to use - this will also be used as the root id value for the request
}
if (fledgeEnabled) { // fledge is enabled at some config level - pbjs.setBidderConfig or pbjs.setConfig
const auctionEnvironment = deepAccess(ozoneBidRequest, 'ortb2Imp.ext.ae'); // this will be set for one of 3 reasons; adunit, setBidderConfig, setConfig
if (isInteger(auctionEnvironment)) {
Expand Down Expand Up @@ -407,22 +418,16 @@ export const spec = {
}
extObj[whitelabelBidder].cookieDeprecationLabel = deepAccess(bidderRequest, 'ortb2.device.ext.cdep', 'none');
logInfo('cookieDeprecationLabel from bidderRequest object = ' + extObj[whitelabelBidder].cookieDeprecationLabel);
let ozUuid = generateUUID();
let batchRequestsVal = this.getBatchRequests(); // false|numeric
if (typeof batchRequestsVal === 'number') {
logInfo('going to batch the requests');
let arrRet = []; // return an array of objects containing data describing max 10 bids
for (let i = 0; i < tosendtags.length; i += batchRequestsVal) {
if (bidderRequest.auctionId) {
logInfo('Found bidderRequest.auctionId - will pass these values through & not generate our own id');
ozoneRequest.id = bidderRequest.auctionId;
ozoneRequest.auctionId = bidderRequest.auctionId;
deepSetValue(ozoneRequest, 'source.tid', deepAccess(bidderRequest, 'ortb2.source.tid'));
} else {
logInfo('Did not find bidderRequest.auctionId - will generate our own id');
ozoneRequest.id = ozUuid; // Unique ID of the bid request, provided by the exchange. (REQUIRED)
}
ozoneRequest.id = generateUUID(); // Unique ID of the bid request, provided by the exchange. (REQUIRED)
deepSetValue(ozoneRequest, 'user.ext.eids', userExtEids);
if (auctionId) {
deepSetValue(ozoneRequest, 'source.tid', auctionId);
}
ozoneRequest.imp = tosendtags.slice(i, i + batchRequestsVal);
ozoneRequest.ext = extObj;
if (ozoneRequest.imp.length > 0) {
Expand All @@ -440,18 +445,13 @@ export const spec = {
logInfo('requests will not be batched.');
if (singleRequest) {
logInfo('buildRequests starting to generate response for a single request');
if (bidderRequest.auctionId) {
logInfo('Found bidderRequest.auctionId - will pass these values through & not generate our own id');
ozoneRequest.id = bidderRequest.auctionId;
ozoneRequest.auctionId = bidderRequest.auctionId;
deepSetValue(ozoneRequest, 'source.tid', deepAccess(bidderRequest, 'ortb2.source.tid'));
} else {
logInfo('Did not find bidderRequest.auctionId - will generate our own id');
ozoneRequest.id = ozUuid; // Unique ID of the bid request, provided by the exchange. (REQUIRED)
}
ozoneRequest.id = generateUUID(); // Unique ID of the bid request, provided by the exchange. (REQUIRED)
ozoneRequest.imp = tosendtags;
ozoneRequest.ext = extObj;
deepSetValue(ozoneRequest, 'user.ext.eids', userExtEids);
if (auctionId) {
deepSetValue(ozoneRequest, 'source.tid', auctionId);
}
var ret = {
method: 'POST',
url: this.getAuctionUrl(),
Expand All @@ -470,6 +470,9 @@ export const spec = {
ozoneRequestSingle.imp = [imp];
ozoneRequestSingle.ext = extObj;
deepSetValue(ozoneRequestSingle, 'user.ext.eids', userExtEids);
if (auctionId) {
deepSetValue(ozoneRequestSingle, 'source.tid', auctionId);
}
logInfo('buildRequests RequestSingle (for non-single) = ', ozoneRequestSingle);
return {
method: 'POST',
Expand Down Expand Up @@ -891,7 +894,9 @@ export const spec = {
params: bid.params,
price: bid.price,
transactionId: bid.transactionId,
ttl: bid.ttl
ttl: bid.ttl,
ortb2: deepAccess(bid, 'ortb2'),
ortb2Imp: deepAccess(bid, 'ortb2Imp'),
};
if (bid.hasOwnProperty('floorData')) {
logObj.floorData = bid.floorData;
Expand Down
Loading

0 comments on commit 2b5a767

Please sign in to comment.