-
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
video bug fix #1906
video bug fix #1906
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 |
---|---|---|
|
@@ -56,6 +56,7 @@ import { Renderer } from 'src/Renderer'; | |
import { config } from 'src/config'; | ||
import { userSync } from 'src/userSync'; | ||
import { createHook } from 'src/hook'; | ||
import { videoAdUnit } from 'src/video'; | ||
|
||
const { syncUsers } = userSync; | ||
const utils = require('./utils'); | ||
|
@@ -112,6 +113,16 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) | |
} | ||
|
||
if (_callback != null) { | ||
if (timedOut) { | ||
utils.logMessage(`Auction ${_auctionId} timedOut`); | ||
const timedOutBidders = getTimedOutBids(_bidderRequests, _bidsReceived); | ||
if (timedOutBidders.length) { | ||
events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, timedOutBidders); | ||
} | ||
} | ||
|
||
events.emit(CONSTANTS.EVENTS.AUCTION_END, {auctionId: _auctionId}); | ||
|
||
try { | ||
_auctionStatus = AUCTION_COMPLETED; | ||
const adUnitCodes = _adUnitCodes; | ||
|
@@ -130,14 +141,6 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) | |
} | ||
} | ||
_callback = null; | ||
|
||
if (timedOut) { | ||
utils.logMessage(`Auction ${_auctionId} timedOut`); | ||
const timedOutBidders = getTimedOutBids(_bidderRequests, _bidsReceived); | ||
if (timedOutBidders.length) { | ||
events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, timedOutBidders); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
@@ -148,15 +151,25 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) | |
return innerBidRequestId === bidRequest.bidderRequestId; | ||
}); | ||
request.doneCbCallCount += 1; | ||
if (_bidderRequests.every((bidRequest) => bidRequest.doneCbCallCount >= 1)) { | ||
// when all bidders have called done callback atleast once it means auction is complete | ||
utils.logInfo(`Bids Received for Auction with id: ${_auctionId}`, _bidsReceived); | ||
_auctionStatus = AUCTION_COMPLETED; | ||
executeCallback(false, true); | ||
// In case of mediaType video and prebidCache enabled, call bidsBackHandler after cache is stored. | ||
if ((request.bids.filter(videoAdUnit).length == 0) || (request.bids.filter(videoAdUnit).length > 0 && !config.getConfig('usePrebidCache'))) { | ||
bidsBackAll() | ||
} | ||
}, 1); | ||
} | ||
|
||
/** | ||
* Execute bidBackHandler if all bidders have called done. | ||
*/ | ||
function bidsBackAll() { | ||
if (_bidderRequests.every((bidRequest) => bidRequest.doneCbCallCount >= 1)) { | ||
// when all bidders have called done callback atleast once it means auction is complete | ||
utils.logInfo(`Bids Received for Auction with id: ${_auctionId}`, _bidsReceived); | ||
_auctionStatus = AUCTION_COMPLETED; | ||
executeCallback(false, true); | ||
} | ||
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. should we emit auction end event here? 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. Not here because executeCallback also gets called in case of timeout. |
||
} | ||
|
||
function callBids() { | ||
startAuctionTimer(); | ||
_auctionStatus = AUCTION_STARTED; | ||
|
@@ -183,6 +196,7 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) | |
addBidReceived, | ||
executeCallback, | ||
callBids, | ||
bidsBackAll, | ||
setWinningBid: (winningBid) => { _winningBid = winningBid }, | ||
getWinningBid: () => _winningBid, | ||
getTimeout: () => _timeout, | ||
|
@@ -232,6 +246,7 @@ export const addBidResponse = createHook('asyncSeries', function(adUnitCode, bid | |
bidResponse.vastUrl = getCacheUrl(bidResponse.videoCacheKey); | ||
} | ||
addBidToAuction(bidResponse); | ||
auctionInstance.bidsBackAll(); | ||
} | ||
doCallbacksIfNeeded(); | ||
}); | ||
|
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.
just a note this will need to change when #1904 is merged (usePrebidCache is deprecated).