-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Prebid 11: gpt slots matching to ad units logic unification #14480
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
base: prebid-11.0
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ import {listenMessagesFromCreative} from './secureCreatives.js'; | |
| import {userSync} from './userSync.js'; | ||
| import {config} from './config.js'; | ||
| import {auctionManager} from './auctionManager.js'; | ||
| import {isBidUsable, type SlotMatchingFn, targeting} from './targeting.js'; | ||
| import {isBidUsable, targeting} from './targeting.js'; | ||
| import {hook, wrapHook} from './hook.js'; | ||
| import {loadSession} from './debugging.js'; | ||
| import {storageCallbacks} from './storageManager.js'; | ||
|
|
@@ -610,14 +610,13 @@ addApiMethod('getBidResponsesForAdUnitCode', getBidResponsesForAdUnitCode); | |
| /** | ||
| * Set query string targeting on one or more GPT ad units. | ||
| * @param adUnit a single `adUnit.code` or multiple. | ||
| * @param customSlotMatching gets a GoogleTag slot and returns a filter function for adUnitCode, so you can decide to match on either eg. return slot => { return adUnitCode => { return slot.getSlotElementId() === 'myFavoriteDivId'; } }; | ||
| */ | ||
| function setTargetingForGPTAsync(adUnit?: AdUnitCode | AdUnitCode[], customSlotMatching?: SlotMatchingFn) { | ||
| function setTargetingForGPTAsync(adUnit?: AdUnitCode | AdUnitCode[]) { | ||
| if (!isGptPubadsDefined()) { | ||
| logError('window.googletag is not defined on the page'); | ||
| return; | ||
| } | ||
| targeting.setTargetingForGPT(adUnit, customSlotMatching); | ||
| targeting.setTargetingForGPT(adUnit); | ||
|
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 removes the per-call matcher from Useful? React with 👍 / 👎. 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 call now always invokes Useful? React with 👍 / 👎. |
||
| } | ||
| addApiMethod('setTargetingForGPTAsync', setTargetingForGPTAsync); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import type {AdUnitDefinition} from "../adUnits.ts"; | ||
| import type {BidRequest} from "../adapterManager.ts"; | ||
| import type {Bid} from "../bidfactory.ts"; | ||
|
|
||
| // TODO: for 11, this should be merged with the GPT/AST logic in secureCreatives | ||
| // (after customGptSlotMatching becomes config - https://github.com/prebid/Prebid.js/issues/14408) | ||
| export function getAdUnitElement(bidRequest: BidRequest<any>): HTMLElement | ||
| export function getAdUnitElement(bidResponse: Bid): HTMLElement | ||
| export function getAdUnitElement(adUnit: AdUnitDefinition): HTMLElement | ||
| export function getAdUnitElement(target: { | ||
| code?: string, | ||
| adUnitCode?: string, | ||
| element?: HTMLElement | ||
| }): HTMLElement { | ||
| if (target.element != null) { | ||
| return target.element; | ||
| } | ||
| const id = target.adUnitCode ?? target.code; | ||
| if (id) { | ||
| return document.getElementById(id); | ||
| } | ||
| return null; | ||
| } |
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.
getMatchingWinningBidForGPTSlotno longer evaluatesbidViewability.customMatchFunction, so existing configs that relied on that hook now cannot customize bid↔slot matching. In those deployments, slots that only matched via the custom function will now returnnull, which suppresses BID_VIEWABLE emission and viewability pixel firing for otherwise valid impressions. Consider preserving the old module-level matcher as a fallback.Useful? React with 👍 / 👎.