Skip to content

Commit

Permalink
rebased on top of master
Browse files Browse the repository at this point in the history
  • Loading branch information
jlquaccia committed Apr 4, 2023
1 parent 9acd07d commit a1fe985
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,6 @@ pbjsInstance.getHighestCpmBids = function (adUnitCode) {
return targeting.getWinningBids(adUnitCode);
};

<<<<<<< HEAD
if (FEATURES.VIDEO) {
/**
* Mark the winning bid as used, should only be used in conjunction with video
Expand All @@ -1002,30 +1001,7 @@ if (FEATURES.VIDEO) {
* @alias module:pbjs.markWinningBidAsUsed
*/
pbjsInstance.markWinningBidAsUsed = function (markBidRequest) {
let bids = [];

if (markBidRequest.adUnitCode && markBidRequest.adId) {
bids = auctionManager.getBidsReceived()
.filter(bid => bid.adId === markBidRequest.adId && bid.adUnitCode === markBidRequest.adUnitCode);
} else if (markBidRequest.adUnitCode) {
bids = targeting.getWinningBids(markBidRequest.adUnitCode);
} else if (markBidRequest.adId) {
bids = auctionManager.getBidsReceived().filter(bid => bid.adId === markBidRequest.adId);
} else {
logWarn('Improper use of markWinningBidAsUsed. It needs an adUnitCode or an adId to function.');
}
=======
/**
* Mark the winning bid as used, should only be used in conjunction with video
* @typedef {Object} MarkBidRequest
* @property {string} adUnitCode The ad unit code
* @property {string} adId The id representing the ad we want to mark
*
* @alias module:pbjs.markWinningBidAsUsed
*/
$$PREBID_GLOBAL$$.markWinningBidAsUsed = function (markBidRequest) {
const bids = fetchReceivedBids(markBidRequest, 'Improper use of markWinningBidAsUsed. It needs an adUnitCode or an adId to function.');
>>>>>>> 5fe144c74 (addressed feedback)
const bids = fetchReceivedBids(markBidRequest, 'Improper use of markWinningBidAsUsed. It needs an adUnitCode or an adId to function.');

if (bids.length > 0) {
bids[0].status = CONSTANTS.BID_STATUS.RENDERED;
Expand Down Expand Up @@ -1127,4 +1103,22 @@ pbjsInstance.processQueue = function () {
processQueue(pbjsInstance.cmd);
};

/**
* @alias module:pbjs.triggerBilling
*/
pbjsInstance.triggerBilling = (winningBid) => {
const bids = fetchReceivedBids(winningBid, 'Improper use of triggerBilling. It requires a bid with at least an adUnitCode or an adId to function.');
const triggerBillingBid = bids.find(bid => bid.requestId === winningBid.requestId);

if (bids.length > 0 && triggerBillingBid) {
try {
adapterManager.callBidBillableBidder(triggerBillingBid);
} catch (e) {
logError('Error when triggering billing :', e);
}
} else {
logWarn('The bid provided to triggerBilling did not match any bids received.');
}
};

export default pbjsInstance;

0 comments on commit a1fe985

Please sign in to comment.