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

Prebid Core: targeting keys issue when enableSendAllBids and alwaysIncludeDeals is true #12518

Merged
merged 2 commits into from
Dec 6, 2024
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
10 changes: 4 additions & 6 deletions src/targeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ export function newTargeting(auctionManager) {
});
};

function addBidToTargeting(bids, bidderLevelTargetingEnabled = false, deals = false) {
if (!bidderLevelTargetingEnabled) return [];

function addBidToTargeting(bids, enableSendAllBids = false, deals = false) {
const standardKeys = FEATURES.NATIVE ? TARGETING_KEYS_ARR.concat(NATIVE_TARGETING_KEYS) : TARGETING_KEYS_ARR.slice();
const allowSendAllBidsTargetingKeys = config.getConfig('targetingControls.allowSendAllBidsTargetingKeys');

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

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

function getBidderTargeting(bids) {
const alwaysIncludeDeals = config.getConfig('targetingControls.alwaysIncludeDeals');
const bidderLevelTargetingEnabled = config.getConfig('enableSendAllBids') || alwaysIncludeDeals;
return addBidToTargeting(bids, bidderLevelTargetingEnabled, alwaysIncludeDeals);
const enableSendAllBids = config.getConfig('enableSendAllBids');
return addBidToTargeting(bids, enableSendAllBids, alwaysIncludeDeals);
}

/**
Expand Down
45 changes: 45 additions & 0 deletions test/spec/unit/core/targeting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,51 @@ describe('targeting tests', function () {
});
});

describe('targetingControls.alwaysIncludeDeals with enableSendAllBids', function () {
beforeEach(function() {
enableSendAllBids = true;
});

it('includes bids w/o deal when enableSendAllBids and alwaysIncludeDeals set to true', function () {
config.setConfig({
enableSendAllBids: true,
targetingControls: {
alwaysIncludeDeals: true
}
});

let bid5 = utils.deepClone(bid1);
bid5.adserverTargeting = {
hb_pb: '3.0',
hb_adid: '111111',
hb_bidder: 'pubmatic',
foobar: '300x250'
};
bid5.bidder = bid5.bidderCode = 'pubmatic';
bid5.cpm = 3.0; // winning bid!
delete bid5.dealId; // no deal with winner
bidsReceived.push(bid5);

const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);

// Pubmatic wins but no deal. But enableSendAllBids is true.
// So Pubmatic is passed through
expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({
'hb_bidder': 'pubmatic',
'hb_adid': '111111',
'hb_pb': '3.0',
'foobar': '300x250',
'hb_pb_pubmatic': '3.0',
'hb_adid_pubmatic': '111111',
'hb_bidder_pubmatic': 'pubmatic',
'hb_deal_rubicon': '1234',
'hb_pb_rubicon': '0.53',
'hb_adid_rubicon': '148018fe5e',
'hb_bidder_rubicon': 'rubicon'
});
});
});

it('selects the top bid when enableSendAllBids true', function () {
enableSendAllBids = true;
let targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
Expand Down
Loading