-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 Server adapter: fledge support #9342
Changes from 4 commits
b868186
b5aa696
a9cdc9c
0c26667
37f3609
6e63a9c
404749b
f9d7d7c
fb897e7
c05bba2
555e2ef
827890d
abe74d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import { config } from '../src/config.js'; | ||
import { getHook } from '../src/hook.js'; | ||
import { getGptSlotForAdUnitCode, logInfo, logWarn } from '../src/utils.js'; | ||
import {IMP, PBS, registerOrtbProcessor, RESPONSE} from '../src/pbjsORTB.js'; | ||
|
||
const MODULE = 'fledgeForGpt' | ||
|
||
|
@@ -31,12 +32,10 @@ export function init(cfg) { | |
} | ||
} | ||
|
||
export function addComponentAuctionHook(next, bidRequest, componentAuctionConfig) { | ||
export function addComponentAuctionHook(next, adUnitCode, componentAuctionConfig) { | ||
const seller = componentAuctionConfig.seller; | ||
const adUnitCode = bidRequest.adUnitCode; | ||
const gptSlot = getGptSlotForAdUnitCode(adUnitCode); | ||
if (gptSlot && gptSlot.setConfig) { | ||
delete componentAuctionConfig.bidId; | ||
gptSlot.setConfig({ | ||
componentAuction: [{ | ||
configKey: seller, | ||
|
@@ -48,5 +47,50 @@ export function addComponentAuctionHook(next, bidRequest, componentAuctionConfig | |
logWarn(MODULE, `unable to register component auction config for: ${adUnitCode} x ${seller}.`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the warning misleading? to me it makes perfect sense: if your browser does not support flegde, bidders should not be trying to run fledge auctions and I'd want to be warned if they do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message "unable to do something" tells me the expectation was that it should have been able to, so something went wrong. |
||
} | ||
|
||
next(bidRequest, componentAuctionConfig); | ||
next(adUnitCode, componentAuctionConfig); | ||
} | ||
|
||
export function markBidsForFledge(next, bidderRequests) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function enables FLEDGE for bidderRequests, should the name be |
||
if (navigator.runAdAuction) { | ||
dgirardi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bidderRequests.forEach((req) => { | ||
req.fledgeEnabled = config.runWithBidder(req.bidderCode, () => config.getConfig('fledgeEnabled')) | ||
}) | ||
} | ||
next(bidderRequests); | ||
} | ||
getHook('makeBidRequests').after(markBidsForFledge); | ||
|
||
export function setImpExtAe(imp, bidRequest, context) { | ||
if (!context.bidderRequest.fledgeEnabled) { | ||
delete imp.ext?.ae; | ||
} | ||
} | ||
registerOrtbProcessor({type: IMP, name: 'impExtAe', fn: setImpExtAe}); | ||
|
||
// to make it easier to share code between the PBS adapter and adapters whose backend is PBS, break up | ||
// fledge response processing in two steps: first aggregate all the auction configs by their imp... | ||
|
||
export function parseExtPrebidFledge(response, ortbResponse, context) { | ||
(ortbResponse.ext?.prebid?.fledge?.auctionconfigs || []).forEach((cfg) => { | ||
const impCtx = context.impContext[cfg.impid]; | ||
if (!impCtx?.imp?.ext?.ae) { | ||
logWarn('Received fledge auction configuration for an impression that was not in the request or did not ask for it', cfg, impCtx?.imp); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. validation behavior is different between PBS and regular adapter. If adapters adopt this method it may become a non-issue but it may be confusing as is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure this validation makes sense outside of here. There are two things we are checking here -
I can add a warning for 2, I'm not sure about 1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be fine to leave it as it is now and update in a later iteration if it becomes a problem with usage. |
||
} else { | ||
impCtx.fledgeConfigs = impCtx.fledgeConfigs || []; | ||
impCtx.fledgeConfigs.push(cfg); | ||
} | ||
}) | ||
} | ||
registerOrtbProcessor({type: RESPONSE, name: 'extPrebidFledge', fn: parseExtPrebidFledge, dialects: [PBS]}); | ||
|
||
// ...then, make them available in the adapter's response. This is the client side version, for which the | ||
// interpretResponse api is {fledgeAuctionConfigs: [{bidId, config}]} | ||
|
||
export function setResponseFledgeConfigs(response, ortbResponse, context) { | ||
const configs = Object.values(context.impContext) | ||
.flatMap((impCtx) => (impCtx.fledgeConfigs || []).map(cfg => ({bidId: impCtx.bidRequest.bidId, config: cfg.config}))); | ||
if (configs.length > 0) { | ||
response.fledgeAuctionConfigs = configs; | ||
} | ||
} | ||
registerOrtbProcessor({type: RESPONSE, name: 'fledgeAuctionConfigs', priority: -1, fn: setResponseFledgeConfigs, dialects: [PBS]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a hook not benefit more from seeing the original bidRequest ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly, but we don't always have it. In prebid server we may have multiple requests (the fledge config references an imp, but there can be any number of bidders (requests) for that imp). With
allowUnknownBidderCodes
we may also have zero.