Skip to content

Commit 41526ba

Browse files
Nate Cozimatthewlane
Nate Cozi
authored andcommitted
Bugfix: internal bids requested overwritten (#1173)
* promote getBidderRequest to utils * handle no_bid and no_cookie lookups on bidsRequested remove internal bids requested collection * no bid response creates bid with bid_ad, ad_unit
1 parent d6fd130 commit 41526ba

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

src/adapters/prebidServer.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const cookiePersistUrl = '//ib.adnxs.com/seg?add=1&redir=';
1515
function PrebidServer() {
1616

1717
let baseAdapter = Adapter.createNew('prebidServer');
18-
let bidRequests = [];
1918
let config;
2019

2120
baseAdapter.setConfig = function(s2sconfig) {
@@ -25,12 +24,6 @@ function PrebidServer() {
2524
/* Prebid executes this function when the page asks to send out bid requests */
2625
baseAdapter.callBids = function(bidRequest) {
2726

28-
bidRequest.ad_units.forEach(adUnit => {
29-
adUnit.bids.forEach(bidder => {
30-
bidRequests[bidder.bidder] = utils.getBidRequest(bidder.bid_id);
31-
});
32-
});
33-
3427
let requestJson = {
3528
account_id : config.accountId,
3629
tid : bidRequest.tid,
@@ -57,13 +50,18 @@ function PrebidServer() {
5750
if(result.status === 'OK') {
5851
if(result.bidder_status) {
5952
result.bidder_status.forEach(bidder => {
60-
if(bidder.no_bid || bidder.no_cookie) {
61-
let bidRequest = bidRequests[bidder.bidder];
62-
let bidObject = bidfactory.createBid(STATUS.NO_BID, bidRequest);
63-
bidObject.bidderCode = bidRequest.bidder;
64-
bidmanager.addBidResponse(bidRequest.placementCode, bidObject);
53+
if(bidder.no_bid) {
54+
// store a "No Bid" bid response
55+
56+
let bidObject = bidfactory.createBid(STATUS.NO_BID, {
57+
bidId: bidder.bid_id
58+
});
59+
bidObject.adUnitCode = bidder.ad_unit;
60+
bidObject.bidderCode = bidder.bidder;
61+
bidmanager.addBidResponse(bidObject.adUnitCode, bidObject);
6562
}
6663
if(bidder.no_cookie) {
64+
// if no cookie is present then no bids were made, we don't store a bid response
6765
queueSync({bidder: bidder.bidder, url : bidder.usersync.url, type : bidder.usersync.type});
6866
}
6967
});

src/bidmanager.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {uniques, flatten, adUnitsFilter} from './utils';
1+
import { uniques, flatten, adUnitsFilter, getBidderRequest } from './utils';
22
import {getPriceBucketString} from './cpmBucketManager';
33

44
var CONSTANTS = require('./constants.json');
@@ -82,13 +82,6 @@ exports.bidsBackAll = function () {
8282
return bidsBackAll();
8383
};
8484

85-
function getBidderRequest(bidder, adUnitCode) {
86-
return $$PREBID_GLOBAL$$._bidsRequested.find(request => {
87-
return request.bids
88-
.filter(bid => bid.bidder === bidder && bid.placementCode === adUnitCode).length > 0;
89-
}) || { start: null, requestId: null };
90-
}
91-
9285
/*
9386
* This function should be called to by the bidder adapter to register a bid response
9487
*/

src/utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,3 +647,10 @@ export function replaceAuctionPrice(str, cpm) {
647647
if(!str) return;
648648
return str.replace(/\$\{AUCTION_PRICE\}/g, cpm);
649649
}
650+
651+
export function getBidderRequest(bidder, adUnitCode) {
652+
return $$PREBID_GLOBAL$$._bidsRequested.find(request => {
653+
return request.bids
654+
.filter(bid => bid.bidder === bidder && bid.placementCode === adUnitCode).length > 0;
655+
}) || { start: null, requestId: null };
656+
}

0 commit comments

Comments
 (0)