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

Prebid 9: rename fledge to paapi #11695

Merged
merged 10 commits into from
Jun 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!--
FLEDGE (Protected Audience API) configuration with GPT and FLEDGE-supporting adapter
gulp serve --modules=fledgeForGpt,openxBidAdapter
gulp serve --modules=paapiForGpt,openxBidAdapter
-->
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!--
FLEDGE (Protected Audience API) configuration with GPT and Prebid-Server
gulp serve --modules=fledgeForGpt,prebidServerBidAdapter
gulp serve --modules=paapiForGpt,prebidServerBidAdapter
-->
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
Expand Down Expand Up @@ -44,8 +44,8 @@

pbjs.que.push(function() {
pbjs.setConfig({
fledgeForGpt: {
enabled: true
paapi: {
enabled: true,
},
s2sConfig: [{
accountId : '1',
Expand All @@ -57,13 +57,6 @@
}]
});

pbjs.setBidderConfig({
bidders: ['openx'],
config: {
fledgeEnabled: true
}
});

pbjs.addAdUnits(adUnits);

pbjs.requestBids({
Expand Down
3 changes: 2 additions & 1 deletion modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
"videojsVideoProvider"
],
"paapi": [
"fledgeForGpt"
"paapiForGpt",
"topLevelPaapi"
]
}
}
4 changes: 2 additions & 2 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export const spec = {
if (fledgeAuctionConfigs?.length) {
return {
bids,
fledgeAuctionConfigs,
paapi: fledgeAuctionConfigs,
};
}

Expand Down Expand Up @@ -449,7 +449,7 @@ function buildContext(bidRequests, bidderRequest) {
url: bidderRequest?.refererInfo?.page || '',
debug: queryString['pbt_debug'] === '1',
noLog: queryString['pbt_nolog'] === '1',
fledgeEnabled: bidderRequest.fledgeEnabled,
fledgeEnabled: bidderRequest.paapi?.enabled,
amp: bidRequests.some(bidRequest => bidRequest.params.integrationMode === 'amp'),
networkId: bidRequests.find(bidRequest => bidRequest.params?.networkId)?.params.networkId,
publisherId: bidRequests.find(bidRequest => bidRequest.params?.pubid)?.params.pubid,
Expand Down
8 changes: 3 additions & 5 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
r = addRequestedFeatureToggles(r, FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES)

// getting ixdiags for adunits of the video, outstream & multi format (MF) style
const fledgeEnabled = deepAccess(bidderRequest, 'fledgeEnabled')
const fledgeEnabled = deepAccess(bidderRequest, 'paapi.enabled')
let ixdiag = buildIXDiag(validBidRequests, fledgeEnabled);
for (let key in ixdiag) {
r.ext.ixdiag[key] = ixdiag[key];
Expand Down Expand Up @@ -1438,7 +1438,7 @@ function createBannerImps(validBidRequest, missingBannerSizes, bannerImps, bidde
bannerImps[validBidRequest.adUnitCode].pos = deepAccess(validBidRequest, 'mediaTypes.banner.pos');

// Add Fledge flag if enabled
const fledgeEnabled = deepAccess(bidderRequest, 'fledgeEnabled')
const fledgeEnabled = deepAccess(bidderRequest, 'paapi.enabled')
if (fledgeEnabled) {
const auctionEnvironment = deepAccess(validBidRequest, 'ortb2Imp.ext.ae')
const paapi = deepAccess(validBidRequest, 'ortb2Imp.ext.paapi')
Expand All @@ -1451,8 +1451,6 @@ function createBannerImps(validBidRequest, missingBannerSizes, bannerImps, bidde
} else {
logWarn('error setting auction environment flag - must be an integer')
}
} else if (deepAccess(bidderRequest, 'defaultForSlots') == 1) {
bannerImps[validBidRequest.adUnitCode].ae = 1
}
}

Expand Down Expand Up @@ -1864,7 +1862,7 @@ export const spec = {
try {
return {
bids,
fledgeAuctionConfigs,
paapi: fledgeAuctionConfigs,
};
} catch (error) {
logWarn('Error attaching AuctionConfigs', error);
Expand Down
2 changes: 1 addition & 1 deletion modules/ixBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ The timeout value must be a positive whole number in milliseconds.
Protected Audience API (FLEDGE)
===========================

In order to enable receiving [Protected Audience API](https://developer.chrome.com/en/docs/privacy-sandbox/fledge/) traffic, follow Prebid's documentation on [fledgeForGpt](https://docs.prebid.org/dev-docs/modules/fledgeForGpt.html) module to build and enable Fledge.
In order to enable receiving [Protected Audience API](https://developer.chrome.com/en/docs/privacy-sandbox/fledge/) traffic, follow Prebid's documentation on [paapiForGpt](https://docs.prebid.org/dev-docs/modules/paapiForGpt.html) module to build and enable Fledge.

Additional Information
======================
Expand Down
2 changes: 1 addition & 1 deletion modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function interpretResponse(response, bidRequest) {
if (fledgeAuctionConfigs.length > 0) {
return {
bids: bidResponses,
fledgeAuctionConfigs
paapi: fledgeAuctionConfigs
}
} else {
return bidResponses;
Expand Down
4 changes: 2 additions & 2 deletions modules/logicadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const spec = {
if (fledgeAuctionConfigs.length) {
return {
bids,
fledgeAuctionConfigs,
paapi: fledgeAuctionConfigs,
};
}

Expand Down Expand Up @@ -74,7 +74,7 @@ function newBidRequest(bidRequest, bidderRequest) {
mediaTypes: bidRequest.mediaTypes,
}

const fledgeEnabled = deepAccess(bidderRequest, 'fledgeEnabled')
const fledgeEnabled = deepAccess(bidderRequest, 'paapi.enabled')
if (fledgeEnabled) {
const ae = deepAccess(bidRequest, 'ortb2Imp.ext.ae');
if (ae) {
Expand Down
2 changes: 1 addition & 1 deletion modules/luceadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function interpretResponse(serverResponse, bidRequest) {
}
}));

return {bids, fledgeAuctionConfigs};
return {bids, paapi: fledgeAuctionConfigs};
}

function report(type, data) {
Expand Down
4 changes: 2 additions & 2 deletions modules/medianetBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function slotParams(bidRequest, bidderRequests) {
if (floorInfo && floorInfo.length > 0) {
params.bidfloors = floorInfo;
}
if (bidderRequests.fledgeEnabled) {
if (bidderRequests.paapi?.enabled) {
params.ext.ae = bidRequest?.ortb2Imp?.ext?.ae;
}
return params;
Expand Down Expand Up @@ -508,7 +508,7 @@ export const spec = {
}
return {
bids: validBids,
fledgeAuctionConfigs,
paapi: fledgeAuctionConfigs,
}
},
getUserSyncs: function(syncOptions, serverResponses) {
Expand Down
6 changes: 3 additions & 3 deletions modules/medianetBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ var adUnits = [{

In order to enable PAAPI auctions follow the instructions below:

1. Add the fledgeForGpt and paapi modules to your prebid bundle.
1. Add the paapiForGpt and paapi modules to your prebid bundle.
2. Add the following configuration for the module
```
pbjs.que.push(function() {
pbjs.setConfig({
fledgeForGpt: {
paapi: {
enabled: true,
bidders: ['medianet'],
defaultForSlots: 1
Expand All @@ -200,4 +200,4 @@ pbjs.que.push(function() {
});
```

For a detailed guide to enabling PAAPI auctions follow Prebid's documentation on [fledgeForGpt](https://docs.prebid.org/dev-docs/modules/fledgeForGpt.html)
For a detailed guide to enabling PAAPI auctions follow Prebid's documentation on [paapiForGpt](https://docs.prebid.org/dev-docs/modules/paapiForGpt.html)
4 changes: 2 additions & 2 deletions modules/onetagBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function buildRequests(validBidRequests, bidderRequest) {
const connection = navigator.connection || navigator.webkitConnection;
payload.networkConnectionType = (connection && connection.type) ? connection.type : null;
payload.networkEffectiveConnectionType = (connection && connection.effectiveType) ? connection.effectiveType : null;
payload.fledgeEnabled = Boolean(bidderRequest && bidderRequest.fledgeEnabled)
payload.fledgeEnabled = Boolean(bidderRequest?.paapi?.enabled)
return {
method: 'POST',
url: ENDPOINT,
Expand Down Expand Up @@ -156,7 +156,7 @@ function interpretResponse(serverResponse, bidderRequest) {
const fledgeAuctionConfigs = body.fledgeAuctionConfigs
return {
bids,
fledgeAuctionConfigs,
paapi: fledgeAuctionConfigs,
}
} else {
return bids;
Expand Down
2 changes: 1 addition & 1 deletion modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const converter = ortbConverter({
});
return {
bids: response.bids,
fledgeAuctionConfigs,
paapi: fledgeAuctionConfigs,
}
} else {
return response.bids
Expand Down
2 changes: 1 addition & 1 deletion modules/optableBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const spec = {
return { bidId: impid, config }
})

return { bids, fledgeAuctionConfigs: auctionConfigs }
return { bids, paapi: auctionConfigs }
},
supportedMediaTypes: [BANNER]
}
Expand Down
83 changes: 37 additions & 46 deletions modules/paapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,16 @@ const pendingBuyersForAuction = auctionStore();
let latestAuctionForAdUnit = {};
let moduleConfig = {};

['paapi', 'fledgeForGpt'].forEach(ns => {
config.getConfig(ns, config => {
init(config[ns], ns);
});
config.getConfig('paapi', config => {
init(config.paapi);
});

export function reset() {
submodules.splice(0, submodules.length);
latestAuctionForAdUnit = {};
}

export function init(cfg, configNamespace) {
if (configNamespace !== 'paapi') {
logWarn(`'${configNamespace}' configuration options will be renamed to 'paapi'; consider using setConfig({paapi: [...]}) instead`);
}
export function init(cfg) {
if (cfg && cfg.enabled === true) {
moduleConfig = cfg;
logInfo(`${MODULE} enabled (browser ${isFledgeSupported() ? 'supports' : 'does NOT support'} runAdAuction)`, cfg);
Expand Down Expand Up @@ -147,7 +142,7 @@ function setFPD(target, {ortb2, ortb2Imp}) {
}

export function addPaapiConfigHook(next, request, paapiConfig) {
if (getFledgeConfig().enabled) {
if (getFledgeConfig(config.getCurrentBidder()).enabled) {
const {adUnitCode, auctionId} = request;

// eslint-disable-next-line no-inner-declarations
Expand Down Expand Up @@ -305,12 +300,11 @@ function isFledgeSupported() {
return 'runAdAuction' in navigator && 'joinAdInterestGroup' in navigator;
}

function getFledgeConfig() {
const bidder = config.getCurrentBidder();
const useGlobalConfig = moduleConfig.enabled && (bidder == null || !moduleConfig.bidders?.length || moduleConfig.bidders?.includes(bidder));
function getFledgeConfig(bidder) {
const enabled = moduleConfig.enabled && (bidder == null || !moduleConfig.bidders?.length || moduleConfig.bidders?.includes(bidder));
return {
enabled: config.getConfig('fledgeEnabled') ?? useGlobalConfig,
ae: config.getConfig('defaultForSlots') ?? (useGlobalConfig ? moduleConfig.defaultForSlots : undefined)
enabled,
ae: enabled ? moduleConfig.defaultForSlots : undefined
};
}

Expand Down Expand Up @@ -340,45 +334,42 @@ function getRequestedSize(adUnit) {
export function markForFledge(next, bidderRequests) {
if (isFledgeSupported()) {
bidderRequests.forEach((bidderReq) => {
config.runWithBidder(bidderReq.bidderCode, () => {
const {enabled, ae} = getFledgeConfig();
Object.assign(bidderReq, {
fledgeEnabled: enabled,
paapi: {
enabled,
componentSeller: !!moduleConfig.componentSeller?.auctionConfig
}
});
bidderReq.bids.forEach(bidReq => {
// https://github.com/InteractiveAdvertisingBureau/openrtb/blob/main/extensions/community_extensions/Protected%20Audience%20Support.md
const igsAe = bidReq.ortb2Imp?.ext?.igs != null
? bidReq.ortb2Imp.ext.igs.ae || 1
: null
const extAe = bidReq.ortb2Imp?.ext?.ae;
if (igsAe !== extAe && igsAe != null && extAe != null) {
logWarn(MODULE, `Bid request defines conflicting ortb2Imp.ext.ae and ortb2Imp.ext.igs, using the latter`, bidReq);
}
const bidAe = igsAe ?? extAe ?? ae;
if (bidAe) {
deepSetValue(bidReq, 'ortb2Imp.ext.ae', bidAe);
bidReq.ortb2Imp.ext.igs = Object.assign({
ae: bidAe,
biddable: 1
}, bidReq.ortb2Imp.ext.igs)
const requestedSize = getRequestedSize(bidReq);
if (requestedSize) {
deepSetValue(bidReq, 'ortb2Imp.ext.paapi.requestedSize', requestedSize);
}
const {enabled, ae} = getFledgeConfig(bidderReq.bidderCode);
Object.assign(bidderReq, {
paapi: {
enabled,
componentSeller: !!moduleConfig.componentSeller?.auctionConfig
}
});
bidderReq.bids.forEach(bidReq => {
// https://github.com/InteractiveAdvertisingBureau/openrtb/blob/main/extensions/community_extensions/Protected%20Audience%20Support.md
const igsAe = bidReq.ortb2Imp?.ext?.igs != null
? bidReq.ortb2Imp.ext.igs.ae || 1
: null;
const extAe = bidReq.ortb2Imp?.ext?.ae;
if (igsAe !== extAe && igsAe != null && extAe != null) {
logWarn(MODULE, `Bid request defines conflicting ortb2Imp.ext.ae and ortb2Imp.ext.igs, using the latter`, bidReq);
}
const bidAe = igsAe ?? extAe ?? ae;
if (bidAe) {
deepSetValue(bidReq, 'ortb2Imp.ext.ae', bidAe);
bidReq.ortb2Imp.ext.igs = Object.assign({
ae: bidAe,
biddable: 1
}, bidReq.ortb2Imp.ext.igs);
const requestedSize = getRequestedSize(bidReq);
if (requestedSize) {
deepSetValue(bidReq, 'ortb2Imp.ext.paapi.requestedSize', requestedSize);
}
});
}
});
});
}
next(bidderRequests);
}

export function setImpExtAe(imp, bidRequest, context) {
if (!context.bidderRequest.fledgeEnabled) {
if (!context.bidderRequest.paapi?.enabled) {
delete imp.ext?.ae;
delete imp.ext?.igs;
}
Expand Down Expand Up @@ -449,7 +440,7 @@ export function setResponsePaapiConfigs(response, ortbResponse, context) {

registerOrtbProcessor({
type: RESPONSE,
name: 'fledgeAuctionConfigs',
name: 'paapiConfigs',
priority: -1,
fn: setResponsePaapiConfigs,
});
22 changes: 4 additions & 18 deletions modules/fledgeForGpt.js → modules/paapiForGpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,15 @@ import {getGptSlotForAdUnitCode} from '../libraries/gptUtils/gptUtils.js';
import {config} from '../src/config.js';
import {getGlobal} from '../src/prebidGlobal.js';

// import parent module to keep backwards-compat for NPM consumers after paapi was split from fledgeForGpt
// there's a special case in webpack.conf.js to avoid duplicating build output on non-npm builds
// TODO: remove this in prebid 9
// eslint-disable-next-line prebid/validate-imports
import './paapi.js';
import {keyCompare} from '../src/utils/reducers.js';
const MODULE = 'fledgeForGpt';
const MODULE = 'paapiForGpt';

let getPAAPIConfig;

// for backwards compat, we attempt to automatically set GPT configuration as soon as we
// have the auction configs available. Disabling this allows one to call pbjs.setPAAPIConfigForGPT at their
// own pace.
let autoconfig = true;
let autoconfig = false;

Object.entries({
[MODULE]: MODULE,
'paapi': 'paapi.gpt'
}).forEach(([topic, ns]) => {
const configKey = `${ns}.autoconfig`;
config.getConfig(topic, (cfg) => {
autoconfig = deepAccess(cfg, configKey, true);
});
config.getConfig('paapi', (cfg) => {
autoconfig = deepAccess(cfg, 'paapi.gpt.autoconfig', false);
});

export function slotConfigurator() {
Expand Down
Loading