Skip to content

Commit 0d7738b

Browse files
Merge pull request prebid#4 from pm-priyanka-deshmane/UOE-11611
Merging targeting keys issue in floors
2 parents d17df3b + b08648a commit 0d7738b

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

src/targeting.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,7 @@ export function newTargeting(auctionManager) {
207207
});
208208
};
209209

210-
function addBidToTargeting(bids, bidderLevelTargetingEnabled = false, deals = false) {
211-
if (!bidderLevelTargetingEnabled) return [];
212-
210+
function addBidToTargeting(bids, enableSendAllBids = false, deals = false) {
213211
const standardKeys = FEATURES.NATIVE ? TARGETING_KEYS_ARR.concat(NATIVE_TARGETING_KEYS) : TARGETING_KEYS_ARR.slice();
214212
const allowSendAllBidsTargetingKeys = config.getConfig('targetingControls.allowSendAllBidsTargetingKeys');
215213

@@ -218,7 +216,7 @@ export function newTargeting(auctionManager) {
218216
: standardKeys;
219217

220218
return bids.reduce((result, bid) => {
221-
if ((!deals || bid.dealId)) {
219+
if (enableSendAllBids || (deals && bid.dealId)) {
222220
const targetingValue = getTargetingMap(bid, standardKeys.filter(
223221
key => typeof bid.adserverTargeting[key] !== 'undefined' &&
224222
(deals || allowedSendAllBidTargeting.indexOf(key) !== -1)));
@@ -233,8 +231,8 @@ export function newTargeting(auctionManager) {
233231

234232
function getBidderTargeting(bids) {
235233
const alwaysIncludeDeals = config.getConfig('targetingControls.alwaysIncludeDeals');
236-
const bidderLevelTargetingEnabled = config.getConfig('enableSendAllBids') || alwaysIncludeDeals;
237-
return addBidToTargeting(bids, bidderLevelTargetingEnabled, alwaysIncludeDeals);
234+
const enableSendAllBids = config.getConfig('enableSendAllBids');
235+
return addBidToTargeting(bids, enableSendAllBids, alwaysIncludeDeals);
238236
}
239237

240238
/**

test/spec/unit/core/targeting_spec.js

+45
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,51 @@ describe('targeting tests', function () {
861861
});
862862
});
863863

864+
describe('targetingControls.alwaysIncludeDeals with enableSendAllBids', function () {
865+
beforeEach(function() {
866+
enableSendAllBids = true;
867+
});
868+
869+
it('includes bids w/o deal when enableSendAllBids and alwaysIncludeDeals set to true', function () {
870+
config.setConfig({
871+
enableSendAllBids: true,
872+
targetingControls: {
873+
alwaysIncludeDeals: true
874+
}
875+
});
876+
877+
let bid5 = utils.deepClone(bid1);
878+
bid5.adserverTargeting = {
879+
hb_pb: '3.0',
880+
hb_adid: '111111',
881+
hb_bidder: 'pubmatic',
882+
foobar: '300x250'
883+
};
884+
bid5.bidder = bid5.bidderCode = 'pubmatic';
885+
bid5.cpm = 3.0; // winning bid!
886+
delete bid5.dealId; // no deal with winner
887+
bidsReceived.push(bid5);
888+
889+
const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
890+
891+
// Pubmatic wins but no deal. But enableSendAllBids is true.
892+
// So Pubmatic is passed through
893+
expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({
894+
'hb_bidder': 'pubmatic',
895+
'hb_adid': '111111',
896+
'hb_pb': '3.0',
897+
'foobar': '300x250',
898+
'hb_pb_pubmatic': '3.0',
899+
'hb_adid_pubmatic': '111111',
900+
'hb_bidder_pubmatic': 'pubmatic',
901+
'hb_deal_rubicon': '1234',
902+
'hb_pb_rubicon': '0.53',
903+
'hb_adid_rubicon': '148018fe5e',
904+
'hb_bidder_rubicon': 'rubicon'
905+
});
906+
});
907+
});
908+
864909
it('selects the top bid when enableSendAllBids true', function () {
865910
enableSendAllBids = true;
866911
let targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);

0 commit comments

Comments
 (0)