Skip to content

Bugfix: internal bids requested overwritten #1173

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

Merged
merged 3 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/adapters/prebidServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const cookiePersistUrl = '//ib.adnxs.com/seg?add=1&redir=';
function PrebidServer() {

let baseAdapter = Adapter.createNew('prebidServer');
let bidRequests = [];
let config;

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

bidRequest.ad_units.forEach(adUnit => {
adUnit.bids.forEach(bidder => {
bidRequests[bidder.bidder] = utils.getBidRequest(bidder.bid_id);
});
});

let requestJson = {
account_id : config.accountId,
tid : bidRequest.tid,
Expand All @@ -57,13 +50,18 @@ function PrebidServer() {
if(result.status === 'OK') {
if(result.bidder_status) {
result.bidder_status.forEach(bidder => {
if(bidder.no_bid || bidder.no_cookie) {
let bidRequest = bidRequests[bidder.bidder];
let bidObject = bidfactory.createBid(STATUS.NO_BID, bidRequest);
bidObject.bidderCode = bidRequest.bidder;
bidmanager.addBidResponse(bidRequest.placementCode, bidObject);
if(bidder.no_bid) {
// store a "No Bid" bid response

let bidObject = bidfactory.createBid(STATUS.NO_BID, {
bidId: bidder.bid_id
});
bidObject.adUnitCode = bidder.ad_unit;
bidObject.bidderCode = bidder.bidder;
bidmanager.addBidResponse(bidObject.adUnitCode, bidObject);
}
if(bidder.no_cookie) {
// if no cookie is present then no bids were made, we don't store a bid response
queueSync({bidder: bidder.bidder, url : bidder.usersync.url, type : bidder.usersync.type});
}
});
Expand Down
9 changes: 1 addition & 8 deletions src/bidmanager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {uniques, flatten, adUnitsFilter} from './utils';
import { uniques, flatten, adUnitsFilter, getBidderRequest } from './utils';
import {getPriceBucketString} from './cpmBucketManager';

var CONSTANTS = require('./constants.json');
Expand Down Expand Up @@ -82,13 +82,6 @@ exports.bidsBackAll = function () {
return bidsBackAll();
};

function getBidderRequest(bidder, adUnitCode) {
return $$PREBID_GLOBAL$$._bidsRequested.find(request => {
return request.bids
.filter(bid => bid.bidder === bidder && bid.placementCode === adUnitCode).length > 0;
}) || { start: null, requestId: null };
}

/*
* This function should be called to by the bidder adapter to register a bid response
*/
Expand Down
7 changes: 7 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,10 @@ export function replaceAuctionPrice(str, cpm) {
if(!str) return;
return str.replace(/\$\{AUCTION_PRICE\}/g, cpm);
}

export function getBidderRequest(bidder, adUnitCode) {
return $$PREBID_GLOBAL$$._bidsRequested.find(request => {
return request.bids
.filter(bid => bid.bidder === bidder && bid.placementCode === adUnitCode).length > 0;
}) || { start: null, requestId: null };
}