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

update targeting's getBidsReceived to not include adpod bids #3558

Merged
merged 1 commit into from
Feb 27, 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
4 changes: 3 additions & 1 deletion src/targeting.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { uniques, isGptPubadsDefined, getHighestCpm, getOldestHighestCpmBid, groupBy, isAdUnitCodeMatchingSlot, timestamp } from './utils';
import { uniques, isGptPubadsDefined, getHighestCpm, getOldestHighestCpmBid, groupBy, isAdUnitCodeMatchingSlot, timestamp, deepAccess } from './utils';
import { config } from './config';
import { NATIVE_TARGETING_KEYS } from './native';
import { auctionManager } from './auctionManager';
import { sizeSupported } from './sizeMapping';
import { ADPOD } from './mediaTypes';
import includes from 'core-js/library/fn/array/includes';

const utils = require('./utils.js');
Expand Down Expand Up @@ -220,6 +221,7 @@ export function newTargeting(auctionManager) {
}

bidsReceived = bidsReceived
.filter(bid => deepAccess(bid, 'video.context') !== ADPOD)
.filter(bid => bid.mediaType !== 'banner' || sizeSupported([bid.width, bid.height]))
.filter(filters.isUnusedBid)
.filter(filters.isBidNotExpired)
Expand Down
11 changes: 11 additions & 0 deletions test/spec/unit/core/targeting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ describe('targeting tests', function () {
// expect the winning CPM to be equal to the sendAllBidCPM
expect(targeting['/123456/header-bid-tag-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_rubicon']).to.deep.equal(targeting['/123456/header-bid-tag-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]);
});

it('does not include adpod type bids in the getBidsReceived results', function () {
let adpodBid = utils.deepClone(bid1);
adpodBid.video = { context: 'adpod', durationSeconds: 15, durationBucket: 15 };
adpodBid.cpm = 5;
bidsReceived.push(adpodBid);

const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
expect(targeting['/123456/header-bid-tag-0']).to.contain.keys('hb_deal', 'hb_adid', 'hb_bidder');
expect(targeting['/123456/header-bid-tag-0']['hb_adid']).to.equal(bid1.adId);
});
}); // end getAllTargeting tests

describe('getAllTargeting without bids return empty object', function () {
Expand Down