Skip to content
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

remove removeRequestId logic when getting bids #3698

Merged
merged 1 commit into from
Apr 3, 2019
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
17 changes: 6 additions & 11 deletions src/prebid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @module pbjs */

import { getGlobal } from './prebidGlobal';
import { flatten, uniques, isGptPubadsDefined, adUnitsFilter, removeRequestId, getLatestHighestCpmBid, isArrayOfNums } from './utils';
import { flatten, uniques, isGptPubadsDefined, adUnitsFilter, getLatestHighestCpmBid, isArrayOfNums } from './utils';
import { listenMessagesFromCreative } from './secureCreatives';
import { userSync } from './userSync.js';
import { loadScript } from './adloader';
Expand Down Expand Up @@ -184,7 +184,7 @@ function getBids(type) {
.filter(bids => bids && bids[0] && bids[0].adUnitCode)
.map(bids => {
return {
[bids[0].adUnitCode]: { bids: bids.map(removeRequestId) }
[bids[0].adUnitCode]: { bids }
};
})
.reduce((a, b) => Object.assign(a, b), {});
Expand Down Expand Up @@ -221,9 +221,7 @@ $$PREBID_GLOBAL$$.getBidResponses = function () {

$$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode = function (adUnitCode) {
const bids = auctionManager.getBidsReceived().filter(bid => bid.adUnitCode === adUnitCode);
return {
bids: bids.map(removeRequestId)
};
return { bids };
};

/**
Expand Down Expand Up @@ -663,8 +661,7 @@ $$PREBID_GLOBAL$$.aliasBidder = function (bidderCode, alias) {
* @return {Array<AdapterBidResponse>} A list of bids that have been rendered.
*/
$$PREBID_GLOBAL$$.getAllWinningBids = function () {
return auctionManager.getAllWinningBids()
.map(removeRequestId);
return auctionManager.getAllWinningBids();
};

/**
Expand All @@ -673,8 +670,7 @@ $$PREBID_GLOBAL$$.getAllWinningBids = function () {
*/
$$PREBID_GLOBAL$$.getAllPrebidWinningBids = function () {
return auctionManager.getBidsReceived()
.filter(bid => bid.status === CONSTANTS.BID_STATUS.BID_TARGETING_SET)
.map(removeRequestId);
.filter(bid => bid.status === CONSTANTS.BID_STATUS.BID_TARGETING_SET);
};

/**
Expand All @@ -686,8 +682,7 @@ $$PREBID_GLOBAL$$.getAllPrebidWinningBids = function () {
*/
$$PREBID_GLOBAL$$.getHighestCpmBids = function (adUnitCode) {
let bidsReceived = getHighestCpmBidsFromBidPool(auctionManager.getBidsReceived(), getLatestHighestCpmBid);
return targeting.getWinningBids(adUnitCode, bidsReceived)
.map(removeRequestId);
return targeting.getWinningBids(adUnitCode, bidsReceived);
};

/**
Expand Down
9 changes: 0 additions & 9 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,15 +1113,6 @@ export function deletePropertyFromObject(object, prop) {
return result;
}

/**
* Delete requestId from external bid object.
* @param {Object} bid
* @return {Object} bid
*/
export function removeRequestId(bid) {
return deletePropertyFromObject(bid, 'requestId');
}

/**
* Checks input is integer or not
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
Expand Down
15 changes: 14 additions & 1 deletion test/fixtures/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ export function getBidResponses() {
'pbAg': '0.10',
'size': '0x0',
'auctionId': 123456,
'requestId': '1144e2f0de84363',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'triplelift',
'hb_adid': '222bb26f9e8bd',
Expand Down Expand Up @@ -372,6 +373,7 @@ export function getBidResponses() {
'size': '300x250',
'alwaysUseBid': true,
'auctionId': 123456,
'requestId': '4dccdc37746135',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'appnexus',
'hb_adid': '233bcbee889d46d',
Expand Down Expand Up @@ -404,6 +406,7 @@ export function getBidResponses() {
'size': '728x90',
'alwaysUseBid': true,
'auctionId': 123456,
'requestId': '392b5a6b05d648',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'appnexus',
'hb_adid': '24bd938435ec3fc',
Expand Down Expand Up @@ -435,6 +438,7 @@ export function getBidResponses() {
'pbAg': '0.50',
'size': '300x250',
'auctionId': 123456,
'requestId': '192c8c1df0f5d1d',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'pagescience',
'hb_adid': '25bedd4813632d7',
Expand Down Expand Up @@ -465,6 +469,7 @@ export function getBidResponses() {
'pbAg': '0.15',
'size': '300x250',
'auctionId': 654321,
'requestId': '135e89c039705da',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'brightcom',
'hb_adid': '26e0795ab963896',
Expand Down Expand Up @@ -496,6 +501,7 @@ export function getBidResponses() {
'pbAg': '0.50',
'size': '300x250',
'auctionId': 654321,
'requestId': '17dd1d869bed44e',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'brealtime',
'hb_adid': '275bd666f5a5a5d',
Expand Down Expand Up @@ -528,6 +534,7 @@ export function getBidResponses() {
'pbAg': '5.90',
'size': '300x250',
'auctionId': 654321,
'requestId': '6d11aa2d5b3659',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'pubmatic',
'hb_adid': '28f4039c636b6a7',
Expand Down Expand Up @@ -558,6 +565,7 @@ export function getBidResponses() {
'pbAg': '2.70',
'size': '300x600',
'auctionId': 654321,
'requestId': '96aff279720d39',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'rubicon',
'hb_adid': '29019e2ab586a5a',
Expand Down Expand Up @@ -1062,6 +1070,7 @@ export function getBidResponsesFromAPI() {
'pbAg': '0.15',
'size': '300x250',
'auctionId': 654321,
'requestId': '135e89c039705da',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'brightcom',
'hb_adid': '26e0795ab963896',
Expand Down Expand Up @@ -1093,6 +1102,7 @@ export function getBidResponsesFromAPI() {
'pbAg': '0.50',
'size': '300x250',
'auctionId': 654321,
'requestId': '17dd1d869bed44e',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'brealtime',
'hb_adid': '275bd666f5a5a5d',
Expand Down Expand Up @@ -1125,6 +1135,7 @@ export function getBidResponsesFromAPI() {
'pbAg': '5.90',
'size': '300x250',
'auctionId': 654321,
'requestId': '6d11aa2d5b3659',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'pubmatic',
'hb_adid': '28f4039c636b6a7',
Expand Down Expand Up @@ -1155,6 +1166,7 @@ export function getBidResponsesFromAPI() {
'pbAg': '2.70',
'size': '300x600',
'auctionId': 654321,
'requestId': '96aff279720d39',
'adserverTargeting': convertTargetingsFromOldToNew({
'hb_bidder': 'rubicon',
'hb_adid': '29019e2ab586a5a',
Expand Down Expand Up @@ -1434,7 +1446,7 @@ export function getCurrencyRates() {
};
}

export function createBidReceived({bidder, cpm, auctionId, responseTimestamp, adUnitCode, adId, status, ttl}) {
export function createBidReceived({bidder, cpm, auctionId, responseTimestamp, adUnitCode, adId, status, ttl, requestId}) {
let bid = {
'bidderCode': bidder,
'width': '300',
Expand All @@ -1448,6 +1460,7 @@ export function createBidReceived({bidder, cpm, auctionId, responseTimestamp, ad
'requestTimestamp': 1454535718610,
'responseTimestamp': responseTimestamp,
'auctionId': auctionId,
'requestId': requestId,
'timeToRespond': 123,
'pbLg': '0.50',
'pbMg': '0.50',
Expand Down
8 changes: 4 additions & 4 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2466,10 +2466,10 @@ describe('Unit: Prebid Module', function () {

it('should return prebid auction winning bids', function () {
let bidsReceived = [
createBidReceived({bidder: 'appnexus', cpm: 7, auctionId: 1, responseTimestamp: 100, adUnitCode: 'code-0', adId: 'adid-1', status: 'targetingSet'}),
createBidReceived({bidder: 'rubicon', cpm: 6, auctionId: 1, responseTimestamp: 101, adUnitCode: 'code-1', adId: 'adid-2'}),
createBidReceived({bidder: 'appnexus', cpm: 6, auctionId: 2, responseTimestamp: 102, adUnitCode: 'code-0', adId: 'adid-3'}),
createBidReceived({bidder: 'rubicon', cpm: 6, auctionId: 2, responseTimestamp: 103, adUnitCode: 'code-1', adId: 'adid-4'}),
createBidReceived({bidder: 'appnexus', cpm: 7, auctionId: 1, responseTimestamp: 100, adUnitCode: 'code-0', adId: 'adid-1', status: 'targetingSet', requestId: 'reqid-1'}),
createBidReceived({bidder: 'rubicon', cpm: 6, auctionId: 1, responseTimestamp: 101, adUnitCode: 'code-1', adId: 'adid-2', requestId: 'reqid-2'}),
createBidReceived({bidder: 'appnexus', cpm: 6, auctionId: 2, responseTimestamp: 102, adUnitCode: 'code-0', adId: 'adid-3', requestId: 'reqid-3'}),
createBidReceived({bidder: 'rubicon', cpm: 6, auctionId: 2, responseTimestamp: 103, adUnitCode: 'code-1', adId: 'adid-4', requestId: 'reqid-4'}),
];
auctionManagerStub.returns(bidsReceived)
let bids = $$PREBID_GLOBAL$$.getAllPrebidWinningBids();
Expand Down