-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Vast trackers: additional event injection feature #14409
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: master
Are you sure you want to change the base?
Changes from all commits
58b6b92
5c17215
447e560
e3309de
4b5fe9e
9fff7dc
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 |
|---|---|---|
|
|
@@ -25,37 +25,65 @@ const ttlBufferInSeconds = 15; | |
|
|
||
| export const vastLocalCache = new Map(); | ||
|
|
||
| /** | ||
| * VAST Trackers interface for video cache | ||
| */ | ||
| export interface VastTrackers { | ||
| impression?: string[]; | ||
| error?: string[]; | ||
| trackingEvents?: Array<{ event: string; url: string }>; | ||
| } | ||
|
|
||
| /** | ||
| * Function which wraps a URI that serves VAST XML, so that it can be loaded. | ||
| * | ||
| * @param uri The URI where the VAST content can be found. | ||
| * @param impTrackerURLs An impression tracker URL for the delivery of the video ad | ||
| * @param trackers VAST trackers object containing impression, error, and trackingEvents | ||
| * @return A VAST URL which loads XML from the given URI. | ||
| */ | ||
| function wrapURI(uri: string, impTrackerURLs: string | string[]) { | ||
| impTrackerURLs = impTrackerURLs && (Array.isArray(impTrackerURLs) ? impTrackerURLs : [impTrackerURLs]); | ||
| function wrapURI(uri: string, trackers?: VastTrackers) { | ||
| // Technically, this is vulnerable to cross-script injection by sketchy vastUrl bids. | ||
| // We could make sure it's a valid URI... but since we're loading VAST XML from the | ||
| // URL they provide anyway, that's probably not a big deal. | ||
| const impressions = impTrackerURLs ? impTrackerURLs.map(trk => `<Impression><![CDATA[${trk}]]></Impression>`).join('') : ''; | ||
| return `<VAST version="3.0"> | ||
| <Ad> | ||
| <Wrapper> | ||
| <AdSystem>prebid.org wrapper</AdSystem> | ||
| <VASTAdTagURI><![CDATA[${uri}]]></VASTAdTagURI> | ||
| ${impressions} | ||
| <Creatives></Creatives> | ||
| </Wrapper> | ||
| </Ad> | ||
| </VAST>`; | ||
|
|
||
| // Build Impression tags | ||
| const impressions = trackers?.impression?.length | ||
| ? trackers.impression.map(trk => `<Impression><![CDATA[${trk}]]></Impression>`).join('') | ||
| : ''; | ||
|
|
||
| // Build Error tags | ||
| const errors = trackers?.error?.length | ||
| ? trackers.error.map(trk => `<Error><![CDATA[${trk}]]></Error>`).join('') | ||
| : ''; | ||
|
|
||
| // Build TrackingEvents for Linear creative | ||
| let trackingEventsXml = ''; | ||
| if (trackers?.trackingEvents?.length) { | ||
| const trackingTags = trackers.trackingEvents | ||
| .map(({event, url}) => `<Tracking event="${event}"><![CDATA[${url}]]></Tracking>`) | ||
| .join(''); | ||
| trackingEventsXml = `<Creative><Linear><TrackingEvents>${trackingTags}</TrackingEvents></Linear></Creative>`; | ||
| } | ||
|
|
||
| return '<VAST version="3.0">' + | ||
| '<Ad>' + | ||
| '<Wrapper>' + | ||
| '<AdSystem>prebid.org wrapper</AdSystem>' + | ||
| '<VASTAdTagURI><![CDATA[' + uri + ']]></VASTAdTagURI>' + | ||
| impressions + | ||
| errors + | ||
| '<Creatives>' + trackingEventsXml + '</Creatives>' + | ||
| '</Wrapper>' + | ||
| '</Ad>' + | ||
| '</VAST>'; | ||
| } | ||
|
|
||
| declare module './bidfactory' { | ||
| interface VideoBidResponseProperties { | ||
| /** | ||
| * VAST impression trackers to attach to this bid. | ||
| * VAST trackers to attach to this bid (impression, error, and tracking events). | ||
| */ | ||
| vastImpUrl?: string | string [] | ||
| vastTrackers?: VastTrackers | ||
|
Collaborator
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. There's more adapters that are populating
Contributor
Author
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.
Please let me know if you have a different opinion or any concerns. |
||
| /** | ||
| * Cache key to use for caching this bid's VAST. | ||
| */ | ||
|
|
@@ -185,7 +213,7 @@ function shimStorageCallback(done: VideoCacheStoreCallback) { | |
| } | ||
|
|
||
| function getVastXml(bid) { | ||
| return bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl); | ||
| return bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastTrackers); | ||
|
Comment on lines
215
to
+216
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 only passes Useful? React with 👍 / 👎. |
||
| }; | ||
|
|
||
| /** | ||
|
|
||
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.
This is not backwards compatible is it? since there's only one user IMO it's worth refactoring it as part of this.
Prebid.js/modules/medianetAnalyticsAdapter.js
Lines 215 to 220 in cceccba