-
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
New function markWinningBidAsUsed for marking video bids #2777
Conversation
markWinningBidAsUsed functionality
src/prebid.js
Outdated
* @param {string} adUnitCode - required ad unit code | ||
* @alias module:pbjs.markWinningBidAsUsed | ||
*/ | ||
$$PREBID_GLOBAL$$.markWinningBidAsUsed = function (adUnitCode) { |
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.
@Caspervw
Can you make this accept an object instead of a string?
I'm thinking we would also want to match against a bidId as well as a adUnitCode.
example:
{
adUnitCode : <code>,
bidId : <id>
}
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.
Sure thing
@mkendall07 I made the change, however I wonder if it became better. If you look at the snippet we now explicitly need to know which bid we’re going to mark. This improves the robustness, however (as far as I know) there is no exposed version of targeting.getWinningBids(adUnitCode);, so which bid did prebid start and what do we need to mark? Do you think pbjs.getHighestCpmBids() is the best approach for that? What do you recon needs to go on the ...? pbjs.requestBids({
bidsBackHandler: function(bids) {
// The video advertisement you want to show
const bid = ...
var videoUrl = pbjs.adServers.dfp.buildVideoUrl({
adUnit: videoAdUnit,
bid: bid
params: {
iu: '/19968336/prebid_cache_video_adunit'
}
});
// Mark the bid, used in buildVideoUrl, as used
pbjs.markWinningBidAsUsed({
adUnitCode: videoAdUnit.code
adId: bid.adId
});
invokeVideoPlayer(videoUrl);
}
}); |
@Caspervw
or find exact bid:
if both are specified, then both must match. |
@mkendall07 Pushed the requested changes. |
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.
LGTM. Thanks for updating!
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.
LGTM
* Quick function to mark a video-bid as used * Added tests for the mark function * comments * Changed the function to accept a markBidRequest object to improve security * Changed the markWinningBidAsUsed to take and/or adUnitCode/adId
* Quick function to mark a video-bid as used * Added tests for the mark function * comments * Changed the function to accept a markBidRequest object to improve security * Changed the markWinningBidAsUsed to take and/or adUnitCode/adId
* Quick function to mark a video-bid as used * Added tests for the mark function * comments * Changed the function to accept a markBidRequest object to improve security * Changed the markWinningBidAsUsed to take and/or adUnitCode/adId
* Quick function to mark a video-bid as used * Added tests for the mark function * comments * Changed the function to accept a markBidRequest object to improve security * Changed the markWinningBidAsUsed to take and/or adUnitCode/adId
* Quick function to mark a video-bid as used * Added tests for the mark function * comments * Changed the function to accept a markBidRequest object to improve security * Changed the markWinningBidAsUsed to take and/or adUnitCode/adId
Type of change
Description of change
In accordance with the discussion in #2282 I’ve created a new function that’s capable of marking a winning bid as used. This addresses the issue where a video-advertisement can be played multiple times on the same page. By proactively calling
pbjs.markWinningBidAsUsed
the winning video-bid can be marked as consumed. We currently use it in production and call it straight after the buildVideoUrl function. It resolved most of our discrepancy issues video header bidding partners.Documentation update: prebid/prebid.github.io#861