Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Video Library: Initial Release

Open karimMourra opened this issue 2 years ago • 5 comments

Type of change

  • [x] Feature

Description of change

The objective of this PR is to implement the Video Module proposed in https://github.com/prebid/Prebid.js/issues/6271 and detailed in the official proposal doc.

Other information

fulfills proposal Addresses: https://github.com/prebid/Prebid.js/issues/6271 #5696

karimMourra avatar Aug 17 '22 19:08 karimMourra

This pull request introduces 1 alert when merging eacbf3af395bd85f599021a43522ff4e23e3fc21 into 059b7c5cbf25806f09af9dc21604260b53507d7e - view on LGTM.com

new alerts:

  • 1 for Inclusion of functionality from an untrusted source

lgtm-com[bot] avatar Aug 17 '22 22:08 lgtm-com[bot]

This pull request introduces 1 alert when merging 128b718c351ff6eea1f464e7f5a02c8a18d01c9b into 8d88902ff6f1479ac991d78d611e482f49c9c81c - view on LGTM.com

new alerts:

  • 1 for Inclusion of functionality from an untrusted source

lgtm-com[bot] avatar Aug 23 '22 21:08 lgtm-com[bot]

cc @FranciscoVergaraC

karimMourra avatar Aug 24 '22 15:08 karimMourra

@dgirardi ready for round 2 of review

karimMourra avatar Aug 24 '22 16:08 karimMourra

copying some comments from @karimMourra into the thread: here's an explanation for how the Video Module determines if an impression came from a bid

We start tracking bids when the BID_ADJUSTMENT events fires on line https://github.com/jwplayer/Prebid.js/blob/440fdde2ab4bc5fb8265140bc3db506c15b1c17e/modules/videoModule/index.js#L60

We use this event because it fires before the ad is cached.

Tracking a bid as seen in this function https://github.com/jwplayer/Prebid.js/blob/440fdde2ab4bc5fb8265140bc3db506c15b1c17e/modules/videoModule/videoImpressionVerifier.js#L138 consists of generating a UUID and storing metadata from the bid (adId, adUnitCode, requestId, auctionId)

The UUID is then used to modify the ad tag being cached: https://github.com/jwplayer/Prebid.js/blob/440fdde2ab4bc5fb8265140bc3db506c15b1c17e/modules/videoModule/videoImpressionVerifier.js#L109 and https://github.com/jwplayer/Prebid.js/blob/440fdde2ab4bc5fb8265140bc3db506c15b1c17e/modules/videoModule/videoImpressionVerifier.js#L111

When a video Impression (or Error) is captured, triggerVideoBidEvent is called, at line https://github.com/jwplayer/Prebid.js/blob/440fdde2ab4bc5fb8265140bc3db506c15b1c17e/modules/videoModule/index.js#L206 which results in attempting to determine if the ad event is related to a bid. This check is done by determining if the ids surfaced in the ad event payload match the UUID generated earlier in https://github.com/jwplayer/Prebid.js/blob/440fdde2ab4bc5fb8265140bc3db506c15b1c17e/modules/videoModule/videoImpressionVerifier.js#L145 . If there is a match, then the bid metadata that was stored with the UUID (adId, adUnitCode, requestId, auctionId) is obtained and is then used to mark the right bid as won.

The adId that comes from the ad event payload, is used to match to the UUID, as well as the array of wrapper ids, and the actual ad tag url since we also append the UUID as a query param. If the id from the event payload matches one of our UUIDs, we return the bid metadata that was stored.

this block ensures we have the right bid

const { adUnitCode, requestId, auctionId } = bidIdentifiers; const bidAdId = bidIdentifiers.adId; const { bids } = pbGlobal.getBidResponsesForAdUnitCode(adUnitCode); return find(bids, bid => bid.adId === bidAdId && bid.requestId === requestId && bid.auctionId === auctionId); where bidIdentifiers is the bid metadata

patmmccann avatar Oct 13 '22 18:10 patmmccann

Hi @bwschmidt thanks for the review! I added docs to the modules

karimMourra avatar Oct 21 '22 18:10 karimMourra

Thanks @bwschmidt !!

patmmccann avatar Oct 21 '22 18:10 patmmccann