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

bugfix for targeting not setting for all adslots #2615

Merged
merged 2 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/auctionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ export function newAuctionManager() {
return getStandardBidderSettings()[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING];
};

auctionManager.setStatusForBids = function(adId, status) {
let bid = auctionManager.findBidByAdId(adId);
if (bid) bid.status = status;
}

function _addAuction(auction) {
_auctions.push(auction);
}
Expand Down
8 changes: 8 additions & 0 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ $$PREBID_GLOBAL$$.setTargetingForGPTAsync = function (adUnit) {
// now set new targeting keys
targeting.setTargetingForGPT(targetingSet);

Object.keys(targeting).forEach((key) => {
Object.keys(targeting[key]).forEach((key2) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should name things better :)

if (key2 === 'hb_adid') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we only setting bid_targeting_set for winning bid (top bid) when the default in prebid 1.0 is sendAllBids?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gist.github.com/mkendall07/1ef1b27ed3501d7b03fbd72ec455bab4
A bid picked for targeting (prebid auction win) will be marked bid.status = 'targetingSet' - which indicates it's not eligible for future auctions, until such status is cleared. This will prevent a winning bid to be set in targeting more than 1 time.

auctionManager.setStatusForBids(targeting[key][key2], BID_TARGETING_SET);
}
});
});

// emit event
events.emit(SET_TARGETING, targetingSet);
};
Expand Down
5 changes: 0 additions & 5 deletions src/targeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,6 @@ export function newTargeting(auctionManager) {
*/
function getWinningBidTargeting(adUnitCodes, bidsReceived) {
let winners = targeting.getWinningBids(adUnitCodes, bidsReceived);
winners.forEach((winner) => {
winner.status = BID_TARGETING_SET;
});

// TODO : Add losing bids to pool from here ?
let standardKeys = getStandardKeys();

winners = winners.map(winner => {
Expand Down
5 changes: 3 additions & 2 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,7 @@ describe('Unit: Prebid Module', function () {
let auction;
let ajaxStub;
let cbTimeout = 3000;
let auctionManagerInstance = newAuctionManager();
let targeting = newTargeting(auctionManagerInstance);
let targeting;

let RESPONSE = {
'version': '0.0.1',
Expand Down Expand Up @@ -454,6 +453,8 @@ describe('Unit: Prebid Module', function () {
})

beforeEach(() => {
let auctionManagerInstance = newAuctionManager();
targeting = newTargeting(auctionManagerInstance);
let adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
sizes: [[300, 250], [300, 600]],
Expand Down