Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple modules: use ortb2.source.tid and ortb2Imp.ext.tid instead of auctionId/transactionId #9969

Merged
merged 17 commits into from
May 23, 2023
21 changes: 11 additions & 10 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {config} from '../src/config.js';
import {
deepAccess,
uniques,
isArray,
getWindowSelf,
getWindowTop,
isArray,
isGptPubadsDefined,
isSlotMatchingAdUnitCode,
logInfo,
logWarn,
getWindowSelf,
mergeDeep,
pick
pick,
uniques
} from '../src/utils.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';

// **************************** UTILS *************************** //
const BIDDER_CODE = '33across';
Expand Down Expand Up @@ -183,7 +183,8 @@ function buildRequests(bidRequests, bidderRequest) {
uspConsent,
pageUrl,
referer,
ttxSettings
ttxSettings,
bidderRequest,
})
)
}
Expand Down Expand Up @@ -246,7 +247,7 @@ function _getMRAKey(bidRequest) {
}

// Infer the necessary data from valid bid for a minimal ttxRequest and create HTTP request
function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageUrl, referer, ttxSettings }) {
function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageUrl, referer, ttxSettings, bidderRequest }) {
const ttxRequest = {};
const firstBidRequest = bidRequests[0];
const { siteId, test } = firstBidRequest.params;
Expand All @@ -271,7 +272,7 @@ function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageU
ttxRequest.site.ref = referer;
}

ttxRequest.id = firstBidRequest.auctionId;
ttxRequest.id = bidderRequest?.bidderRequestId;

if (gdprConsent.consentString) {
ttxRequest.user = setExtensions(ttxRequest.user, {
Expand Down
3 changes: 2 additions & 1 deletion modules/adWMGBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ export const spec = {
}

const request = {
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auctionId: bidRequest.auctionId,
requestId: bidRequest.bidId,
bidRequestsCount: bidRequest.bidRequestsCount,
bidderRequestId: bidRequest.bidderRequestId,
transactionId: bidRequest.transactionId,
transactionId: bidRequest.ortb2Imp?.ext?.tid,
referrer: referrer,
timeout: timeout,
adUnit: adUnit,
Expand Down
1 change: 1 addition & 0 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ function storeRequestInAdagioNS(bidRequest) {
bidder: bidRequest.bidder,
params: bidRequest.params // use the updated bid.params object with auto-detected params
}],
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auctionId: bidRequest.auctionId,
pageviewId: internal.getPageviewId(),
printNumber,
Expand Down
2 changes: 1 addition & 1 deletion modules/adbookpspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function buildRegs(bidderRequest) {
function buildSource(bidRequests, bidderRequest) {
const source = {
fd: 1,
tid: bidderRequest.auctionId,
tid: bidderRequest.ortb2.source.tid,
};
const schain = deepAccess(bidRequests, '0.schain');

Expand Down
1 change: 1 addition & 0 deletions modules/addefendBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const spec = {
for (var i = 0; i < validBidRequests.length; i++) {
let vb = validBidRequests[i];
let o = vb.params;
// TODO: fix auctionId/transactionId leak: https://github.com/prebid/Prebid.js/issues/9781
bid.auctionId = vb.auctionId;
o.bidId = vb.bidId;
o.transactionId = vb.transactionId;
Expand Down
6 changes: 3 additions & 3 deletions modules/adfBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {deepAccess, deepSetValue, mergeDeep, parseSizesInput, deepClone} from '../src/utils.js';
import {deepAccess, deepClone, deepSetValue, mergeDeep, parseSizesInput} from '../src/utils.js';
import {config} from '../src/config.js';
import {Renderer} from '../src/Renderer.js';

Expand Down Expand Up @@ -58,7 +58,7 @@ export const spec = {
const adxDomain = setOnAny(validBidRequests, 'params.adxDomain') || 'adx.adform.net';

const pt = setOnAny(validBidRequests, 'params.pt') || setOnAny(validBidRequests, 'params.priceType') || 'net';
const tid = bidderRequest.auctionId;
const tid = bidderRequest.ortb2?.source?.tid;
const test = setOnAny(validBidRequests, 'params.test');
const currency = getConfig('currency.adServerCurrency');
const cur = currency && [ currency ];
Expand Down Expand Up @@ -139,7 +139,7 @@ export const spec = {
});

const request = {
id: bidderRequest.auctionId,
id: bidderRequest.bidderRequestId,
site,
app,
user,
Expand Down
2 changes: 1 addition & 1 deletion modules/adgenerationBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const spec = {
data = tryAppendQueryString(data, 'sdktype', '0');
data = tryAppendQueryString(data, 'hb', 'true');
data = tryAppendQueryString(data, 't', 'json3');
data = tryAppendQueryString(data, 'transactionid', validReq.transactionId);
data = tryAppendQueryString(data, 'transactionid', validReq.ortb2Imp?.ext?.tid);
data = tryAppendQueryString(data, 'sizes', getSizes(validReq));
data = tryAppendQueryString(data, 'currency', getCurrencyType());
data = tryAppendQueryString(data, 'pbver', '$prebid.version$');
Expand Down
10 changes: 5 additions & 5 deletions modules/adkernelAdnBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepAccess, parseSizesInput, isArray, deepSetValue, isStr, isNumber, logInfo } from '../src/utils.js';
import {deepAccess, deepSetValue, isArray, isNumber, isStr, logInfo, parseSizesInput} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
Expand Down Expand Up @@ -58,11 +58,11 @@ function canonicalizeSizesArray(sizes) {
}

function buildRequestParams(tags, bidderRequest) {
let {auctionId, gdprConsent, uspConsent, transactionId, refererInfo} = bidderRequest;
let {gdprConsent, uspConsent, refererInfo, ortb2} = bidderRequest;
let req = {
id: auctionId,
// TODO: transactionId is undefined here, should this be auctionId? see #8573
tid: transactionId,
id: bidderRequest.bidderRequestId,
// TODO: root-level `tid` is not ORTB; is this intentional?
tid: ortb2?.source?.tid,
site: buildSite(refererInfo),
imp: tags
};
Expand Down
10 changes: 5 additions & 5 deletions modules/adkernelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
deepAccess,
deepSetValue,
getAdUnitSizes,
getDefinedParams,
getDNT,
isArray,
isArrayOfNums,
Expand All @@ -14,14 +15,13 @@ import {
isPlainObject,
isStr,
mergeDeep,
parseGPTSingleSizeArrayToRtbSize,
getDefinedParams
parseGPTSingleSizeArrayToRtbSize
} from '../src/utils.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {find} from '../src/polyfill.js';
import {config} from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.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 @@ -490,9 +490,9 @@ function makeRegulations(bidderRequest) {
* @returns
*/
function makeBaseRequest(bidderRequest, imps, fpd) {
let {auctionId, timeout} = bidderRequest;
let {timeout} = bidderRequest;
let request = {
'id': auctionId,
'id': bidderRequest.bidderRequestId,
'imp': imps,
'at': 1,
'tmax': parseInt(timeout)
Expand Down
1 change: 1 addition & 0 deletions modules/adqueryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ function buildRequest(validBidRequests, bidderRequest) {
let bid = validBidRequests;
return {
placementCode: bid.params.placementId,
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auctionId: bid.auctionId,
type: bid.params.type,
adUnitCode: bid.adUnitCode,
Expand Down
6 changes: 3 additions & 3 deletions modules/adtrueBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ export const spec = {
conf.zoneId = conf.zoneId || bid.params.zoneId;
conf.pubId = conf.pubId || bid.params.publisherId;

conf.transactionId = bid.transactionId;
conf.transactionId = bid.ortb2Imp?.ext?.tid;
if (bidCurrency === '') {
bidCurrency = bid.params.currency || UNDEFINED;
} else if (bid.params.hasOwnProperty('currency') && bidCurrency !== bid.params.currency) {
Expand All @@ -492,7 +492,7 @@ export const spec = {
payload.ext.wrapper = {};

payload.ext.wrapper.transactionId = conf.transactionId;
payload.ext.wrapper.wiid = conf.wiid || bidderRequest.auctionId;
payload.ext.wrapper.wiid = conf.wiid || bidderRequest.ortb2?.ext?.tid;
payload.ext.wrapper.wp = 'pbjs';

payload.user.geo = {};
Expand All @@ -507,7 +507,7 @@ export const spec = {
if (typeof config.getConfig('device') === 'object') {
payload.device = Object.assign(payload.device, config.getConfig('device'));
}

deepSetValue(payload, 'source.tid', conf.transactionId);
// test bids
if (window.location.href.indexOf('adtrueTest=true') !== -1) {
payload.test = 1;
Expand Down
3 changes: 2 additions & 1 deletion modules/aduptechBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export const spec = {
url: internal.buildEndpointUrl(publisher),
method: ENDPOINT_METHOD,
data: {
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auctionId: auctionId,
pageUrl: pageUrl,
referrer: referrer,
Expand All @@ -271,7 +272,7 @@ export const spec = {
groupedBidRequests[publisher].forEach(bidRequest => {
const bid = {
bidId: bidRequest.bidId,
transactionId: bidRequest.transactionId,
transactionId: bidRequest.ortb2Imp?.ext?.tid,
adUnitCode: bidRequest.adUnitCode,
params: internal.extractParams(bidRequest)
};
Expand Down
2 changes: 1 addition & 1 deletion modules/adxcgBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const spec = {
device.dnt = getDNT() ? 1 : 0;
device.language = (navigator && navigator.language) ? navigator.language.split('-')[0] : '';

const tid = bidderRequest.auctionId;
const tid = bidderRequest.ortb2?.source?.tid;
const test = setOnAny(validBidRequests, 'params.test');
const currency = getConfig('currency.adServerCurrency');
const cur = currency && [ currency ];
Expand Down
2 changes: 1 addition & 1 deletion modules/adyoulikeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const spec = {
let size = getSize(sizesArray);
accumulator[bidReq.bidId] = {};
accumulator[bidReq.bidId].PlacementID = bidReq.params.placement;
accumulator[bidReq.bidId].TransactionID = bidReq.transactionId;
accumulator[bidReq.bidId].TransactionID = bidReq.ortb2Imp?.ext?.tid;
accumulator[bidReq.bidId].Width = size.width;
accumulator[bidReq.bidId].Height = size.height;
accumulator[bidReq.bidId].AvailableSizes = sizesArray.join(',');
Expand Down
4 changes: 2 additions & 2 deletions modules/afpBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ export const spec = {
pageUrl: IS_DEV ? TEST_PAGE_URL : refererInfo.page,
gdprConsent: gdprConsent,
bidRequests: validBidRequests.map(validBidRequest => {
const {bidId, transactionId, sizes, params: {
const {bidId, ortb2Imp, sizes, params: {
placeId, placeType, imageUrl, imageWidth, imageHeight
}} = validBidRequest
bidRequestMap[bidId] = validBidRequest
const bidRequest = {
bidId,
transactionId,
transactionId: ortb2Imp?.ext?.tid,
sizes,
placeId,
}
Expand Down
19 changes: 16 additions & 3 deletions modules/aidemBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import {_each, contains, deepAccess, deepSetValue, getDNT, isBoolean, isStr, isNumber, logError, logInfo} from '../src/utils.js';
import {
_each,
contains,
deepAccess,
deepSetValue,
getDNT,
isBoolean,
isNumber,
isStr,
logError,
logInfo
} from '../src/utils.js';
import {config} from '../src/config.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
Expand Down Expand Up @@ -164,6 +175,7 @@ function buildWinNotice(bid) {
impid: deepAccess(bid, 'meta.impid'),
dsp_id: deepAccess(bid, 'meta.dsp_id'),
adUnitCode: bid.adUnitCode,
// TODO: fix auctionId/transactionId leak: https://github.com/prebid/Prebid.js/issues/9781
auctionId: bid.auctionId,
transactionId: bid.transactionId,
ttl: bid.ttl,
Expand Down Expand Up @@ -201,7 +213,7 @@ function getMediaType(bidRequest) {
function getPrebidRequestFields(bidderRequest, bidRequests) {
const payload = {};
// Base Payload Data
deepSetValue(payload, 'id', bidderRequest.auctionId);
deepSetValue(payload, 'id', bidderRequest.bidderRequestId);
// Impressions
setPrebidImpressionObject(bidRequests, payload);
// Device
Expand Down Expand Up @@ -231,7 +243,8 @@ function setPrebidImpressionObject(bidRequests, payload) {
// Placement or ad tag used to initiate the auction
deepSetValue(impressionObject, 'id', bidRequest.bidId);
// Transaction id
deepSetValue(impressionObject, 'tid', deepAccess(bidRequest, 'transactionId'));
// TODO: `imp.tid` is not ORTB, is this intentional?
deepSetValue(impressionObject, 'tid', deepAccess(bidRequest, 'ortb2Imp.ext.tid'));
// placement id
deepSetValue(impressionObject, 'tagid', deepAccess(bidRequest, 'params.placementId', null));
// Publisher id
Expand Down
2 changes: 1 addition & 1 deletion modules/ajaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const spec = {
const asi = getBidIdParameter('asi', bidRequest.params);
queryString = tryAppendQueryString(queryString, 'asi', asi);
queryString = tryAppendQueryString(queryString, 'skt', SDKType);
queryString = tryAppendQueryString(queryString, 'tid', bidRequest.transactionId)
queryString = tryAppendQueryString(queryString, 'tid', bidRequest.ortb2Imp?.ext?.tid)
queryString = tryAppendQueryString(queryString, 'prebid_id', bidRequest.bidId);
queryString = tryAppendQueryString(queryString, 'prebid_ver', '$prebid.version$');

Expand Down
3 changes: 2 additions & 1 deletion modules/alkimiBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {deepClone, deepAccess} from '../src/utils.js';
import {deepAccess, deepClone} from '../src/utils.js';
import {ajax} from '../src/ajax.js';
import {VIDEO} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
Expand Down Expand Up @@ -41,6 +41,7 @@ export const spec = {
const alkimiConfig = config.getConfig('alkimi');

let payload = {
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
requestId: bidderRequest.auctionId,
signRequest: {bids, randomUUID: alkimiConfig && alkimiConfig.randomUUID},
bidIds,
Expand Down
1 change: 1 addition & 0 deletions modules/amxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export const spec = {
};

const payload = {
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
a: bidderRequest.auctionId,
B: 0,
b: loc.host,
Expand Down
2 changes: 1 addition & 1 deletion modules/apacdexBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const spec = {
return {
params: bid.params,
mediaTypes: bid.mediaTypes,
transactionId: bid.transactionId,
transactionId: bid.ortb2Imp?.ext?.tid,
sizes: bid.sizes,
bidId: bid.bidId,
adUnitCode: bid.adUnitCode,
Expand Down
1 change: 1 addition & 0 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ function bidToTag(bid) {
tag['banner_frameworks'] = bid.params.frameworks;
}

// TODO: why does this need to iterate through every ad unit?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsnellbaker icymi

Copy link
Collaborator

@jsnellbaker jsnellbaker May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgirardi I think the idea was to look at the adUnit as the source of truth here, since PBJS (at the time at least, not sure if it's still true today) could create a backup mediaTypes object in the bid object if the mediaTypes field was undefined in the setup. In that scenario, we didn't want to pass along the ad_type field if the publisher didn't define it in their adUnit. (see #4065 for the original PR from ~4 years ago).

There's probably other ways this can be done nowadays, so feel free to give it a try if it will help clean things up for the rest of the project.

Copy link
Collaborator Author

@dgirardi dgirardi May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the reasoning. If prebid says that the default mediatype is banner, why would appnexus want to contradict that? and why would only appnexus want to contradict that? I'd expect all bidders to give me a banner if that's what I am (implicitly) asking for.

Besides that, there are some other scenarios where this would behave surprisingly I think. it's possible to set up a multiformat adUnit and use sizemapping to turn off some mediatypes for some form factors; for example banner & video but banner is disabled on mobile. Granted it's not very likely, but this logic would circumvent it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was done originally due to multi-format requests. There's logic in our system where if certain fields are left empty on the request, then the corresponding value in the adserver UI would take-over - which includes the mediatype values. So if a publisher had left it out on their adUnit, then their placement with banner + video + native could use all 3 types - instead of being narrowed down to banner due to PBJS' defaults.

I'm not sure if sizemapping was properly considered back then - though sizemapping itself has changed over the years, so maybe it worked before and no one has noticed any edge-case issues (or if they did, they just probably just added the mediaTypes info the adUnit to help the logic).

Given the more heavy reliance on the mediaTypes field though in modern Prebid.js, I don't think most setups would include a setup nowadays where the mediaTypes field is left out intentionally (especially since the banner sizes are set there, instead of in old sizes field). This would probably be a safe bit of logic to change to rely on the bid's mediaType data (if that's the preferred way to go here from your take).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a new issue would work? this pr is merging and unrelated, if i'm reading this correctly

let adUnit = find(auctionManager.getAdUnits(), au => bid.transactionId === au.transactionId);
if (adUnit && adUnit.mediaTypes && adUnit.mediaTypes.banner) {
tag.ad_types.push(BANNER);
Expand Down
1 change: 1 addition & 0 deletions modules/apstreamBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ function buildRequests(bidRequests, bidderRequest) {
bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);
const data = {
med: encodeURIComponent(window.location.href),
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auid: bidderRequest.auctionId,
ref: document.referrer,
dnt: getDNT() ? 1 : 0,
Expand Down
2 changes: 1 addition & 1 deletion modules/asoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ function createBasePayload(bidRequest, bidderRequest) {
const urlsInfo = getUrlsInfo(bidderRequest);

const payload = {
id: bidRequest.auctionId + '_' + bidRequest.bidId,
id: bidRequest.bidId,
at: 1,
tmax: bidderRequest.timeout,
site: {
Expand Down
2 changes: 1 addition & 1 deletion modules/astraoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function buildBidRequests(validBidRequests) {
const params = validBidRequest.params;
const bidRequest = {
bidId: validBidRequest.bidId,
transactionId: validBidRequest.transactionId,
transactionId: validBidRequest.ortb2Imp?.ext?.tid,
sizes: validBidRequest.sizes,
placement: params.placement,
placeId: params.placeId,
Expand Down
Loading