-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core & PBS Adapter: support
eventtrackers
, and normalize burl
/ `…
…ext.prebid.events.win` into it (#12711) * Extract native event tracker parsing logic * ortbConverter: set response eventtrackers and translate PBS burl, events.win * fire impression trackers on billing, win trackers on render * clean up pbs wurl logic * more cleanup * rename analytics to events in markWinningBidAsUsed * lint fixes * try to appease jsdoc * add PBS test case --------- Co-authored-by: mkomorski <[email protected]>
- Loading branch information
Showing
15 changed files
with
268 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {EVENT_TYPE_IMPRESSION, EVENT_TYPE_WIN, TRACKER_METHOD_IMG} from '../../../src/eventTrackers.js'; | ||
|
||
export function addEventTrackers(bidResponse, bid) { | ||
bidResponse.eventtrackers = bidResponse.eventtrackers || []; | ||
[ | ||
[bid.burl, EVENT_TYPE_IMPRESSION], // core used to fire burl directly, but only for bids coming from PBS | ||
[bid?.ext?.prebid?.events?.win, EVENT_TYPE_WIN] | ||
].filter(([winUrl, type]) => winUrl && bidResponse.eventtrackers.find( | ||
({method, event, url}) => event === type && method === TRACKER_METHOD_IMG && url === winUrl | ||
) == null) | ||
.forEach(([url, event]) => { | ||
bidResponse.eventtrackers.push({ | ||
method: TRACKER_METHOD_IMG, | ||
event, | ||
url | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export const TRACKER_METHOD_IMG = 1; | ||
export const TRACKER_METHOD_JS = 2; | ||
export const EVENT_TYPE_IMPRESSION = 1; | ||
export const EVENT_TYPE_WIN = 500; | ||
|
||
/** | ||
* Returns a map from event type (EVENT_TYPE_*) | ||
* to a map from tracker method (TRACKER_METHOD_*) | ||
* to an array of tracking URLs | ||
* | ||
* @param {{}[]} eventTrackers an array of "Event Tracker Response Object" as defined | ||
* in the ORTB native 1.2 spec (https://www.iab.com/wp-content/uploads/2018/03/OpenRTB-Native-Ads-Specification-Final-1.2.pdf, section 5.8) | ||
* @returns {{[type: string]: {[method: string]: string[]}}} | ||
*/ | ||
export function parseEventTrackers(eventTrackers) { | ||
return (eventTrackers ?? []).reduce((tally, {event, method, url}) => { | ||
const trackersForType = tally[event] = tally[event] ?? {}; | ||
const trackersForMethod = trackersForType[method] = trackersForType[method] ?? []; | ||
trackersForMethod.push(url); | ||
return tally; | ||
}, {}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.