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

fix(bidcaching):remove teads from bidcaching #54

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions src/marfeelTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

const utils = require('./utils.js');
const CONSTANTS = require('./constants.json');
const { auctionManager } = require('./auctionManager');

var lastLocation;
Expand Down Expand Up @@ -80,3 +81,7 @@ function add1x1IfAllowed(auctionSizes) {
export function getAllowedSizes() {
return add1x1IfAllowed(getCurrentAuctionSizes())
}

export const isBidCached = (bid) => bid[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING][CONSTANTS.TARGETING_KEYS.CACHED];

export const getBidName = (bid) => bid[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING][CONSTANTS.TARGETING_KEYS.BIDDER];
6 changes: 4 additions & 2 deletions src/targeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { auctionManager } from './auctionManager';
import { sizeSupported } from './sizeMapping';
import { ADPOD } from './mediaTypes';
import includes from 'core-js/library/fn/array/includes';
import { getLastLocation, getAllowedSizes, isBidSizeAllowed } from './marfeelTools';
import { getLastLocation, getBidName, isBidCached, getAllowedSizes, isBidSizeAllowed } from './marfeelTools';

const utils = require('./utils.js');
var CONSTANTS = require('./constants.json');
Expand Down Expand Up @@ -374,7 +374,9 @@ export function newTargeting(auctionManager) {
const bidsToFilter = bidsByReferrer[lastLocation] || filterBidsByAdUnit(bidsReceived);
const allowedSizes = getAllowedSizes();

bidsToProcess = bidsToFilter.filter(bid => isBidSizeAllowed(bid, allowedSizes));
bidsToProcess = bidsToFilter
.filter(bid => isBidSizeAllowed(bid, allowedSizes))
.filter(bid => !(isBidCached(bid) && getBidName(bid) === 'teads'));

Choose a reason for hiding this comment

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

I would set an array of blacklisted bidders in order to make it easier add new ones to the black list if we don't want to perform bid caching on them. Moreover, what do you think to gather it on a different function? Something like:

isBidAllowed = () => !(isBidCached(bid) && blacklistedCacheBidders.includes(getBidName(bid)))

Choose a reason for hiding this comment

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

Besides that, we could add a test to cover it.

Copy link
Author

Choose a reason for hiding this comment

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

Cool!

}

bidsToProcess = bidsToProcess
Expand Down