Skip to content
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
22 changes: 22 additions & 0 deletions src/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,31 @@ export function auctionCallbacks(auctionDone, auctionInstance) {
}
}

function getBidReferrer(bidderRequest) {
const bids = bidderRequest.bids;
const NO_REFERRER = 'no-referrer';
const NO_REFERRER_LOG = 'Bid with no referrer';

if (!bids || bids.length < 1) {
console.warn(NO_REFERRER_LOG);
return NO_REFERRER;
}

const bid = bids[0];

if (bid && bid.params && bid.params.referrer) {
return bid.params.referrer;
} else {
console.warn(NO_REFERRER_LOG);
return NO_REFERRER;
}
}

function addBidResponse(adUnitCode, bid) {
let bidderRequest = this;

bid.referrer = getBidReferrer(bidderRequest);

bidResponseMap[bid.requestId] = true;

outstandingBidsAdded++;
Expand Down
8 changes: 3 additions & 5 deletions src/targeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { getLastLocation } from './marfeelTools';
const utils = require('./utils.js');
var CONSTANTS = require('./constants.json');

const bidsByReferrer = {};

var pbTargetingKeys = [];

const MAX_DFP_KEYLENGTH = 20;
Expand Down Expand Up @@ -344,8 +346,6 @@ export function newTargeting(auctionManager) {
return auctionManager.getAdUnitCodes() || [];
}

const bidsByReferrer = {};

/**
* bid caching done with all bids specifically for Marfeel purposes due to its own configuration
*/
Expand All @@ -361,9 +361,7 @@ export function newTargeting(auctionManager) {
} else {
const lastLocation = getLastLocation();

bidsReceived.forEach(function (bidReceived) {
bidsByReferrer[lastLocation] = (bidsByReferrer[lastLocation]) ? [...bidsByReferrer[lastLocation], bidReceived] : [bidReceived];
});
bidsByReferrer[lastLocation] = bidsReceived.filter(bid => bid.referrer === lastLocation);

bidsToProcess = bidsByReferrer[lastLocation] || filterBidsByAdUnit(bidsReceived);
}
Expand Down