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

Feature : Display counter at Adslot level #2802

Merged
merged 1 commit into from
Jul 30, 2018
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
3 changes: 2 additions & 1 deletion modules/medianetBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ function slotParams(bidRequest) {
let params = {
id: bidRequest.bidId,
ext: {
dfp_id: bidRequest.adUnitCode
dfp_id: bidRequest.adUnitCode,
display_count: bidRequest.displayCount
},
banner: transformSizes(bidRequest.sizes),
all: bidRequest.params
Expand Down
5 changes: 4 additions & 1 deletion src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import { ajaxBuilder } from 'src/ajax';
import { config, RANDOM } from 'src/config';
import includes from 'core-js/library/fn/array/includes';
import find from 'core-js/library/fn/array/find';
import { getGlobal } from './prebidGlobal';

var utils = require('./utils.js');
var CONSTANTS = require('./constants.json');
var events = require('./events');
let s2sTestingModule; // store s2sTesting module if it's loaded
const $$PREBID_GLOBAL$$ = getGlobal();

var _bidderRegistry = {};
exports.bidderRegistry = _bidderRegistry;
Expand Down Expand Up @@ -84,7 +86,8 @@ function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels}) {
sizes: sizes,
bidId: bid.bid_id || utils.getUniqueIdentifierStr(),
bidderRequestId,
auctionId
auctionId,
displayCount: $$PREBID_GLOBAL$$.displayCount[adUnit.code]
}));
}
return bids;
Expand Down
5 changes: 5 additions & 0 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ utils.logInfo('Prebid.js v$prebid.version$ loaded');
// create adUnit array
$$PREBID_GLOBAL$$.adUnits = $$PREBID_GLOBAL$$.adUnits || [];

// store the number of times requestBids has been called per ad Unit
$$PREBID_GLOBAL$$.displayCount = $$PREBID_GLOBAL$$.displayCount || {};

// Allow publishers who enable user sync override to trigger their sync
$$PREBID_GLOBAL$$.triggerUserSyncs = triggerUserSyncs;

Expand Down Expand Up @@ -367,6 +370,8 @@ $$PREBID_GLOBAL$$.requestBids = createHook('asyncSeries', function ({ bidsBackHa
adUnit.bids = adUnit.bids.filter(bid => bid.bidder !== bidder);
}
});
// increment the number of times requestBids has been called for this adUnit
$$PREBID_GLOBAL$$.displayCount[adUnit.code] = ($$PREBID_GLOBAL$$.displayCount[adUnit.code] + 1) || 1;
});

if (!adUnits || adUnits.length === 0) {
Expand Down
36 changes: 24 additions & 12 deletions test/spec/modules/medianetBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ let VALID_BID_REQUEST = [{
'sizes': [[300, 250]],
'bidId': '28f8f8130a583e',
'bidderRequestId': '1e9b1f07797c1c',
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d'
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d',
'displayCount': 1
}, {
'bidder': 'medianet',
'params': {
Expand All @@ -33,7 +34,8 @@ let VALID_BID_REQUEST = [{
'sizes': [[300, 251]],
'bidId': '3f97ca71b1e5c2',
'bidderRequestId': '1e9b1f07797c1c',
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d'
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d',
'displayCount': 1
}],
VALID_BID_REQUEST_INVALID_BIDFLOOR = [{
'bidder': 'medianet',
Expand All @@ -51,7 +53,8 @@ let VALID_BID_REQUEST = [{
'sizes': [[300, 250]],
'bidId': '28f8f8130a583e',
'bidderRequestId': '1e9b1f07797c1c',
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d'
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d',
'displayCount': 1
}, {
'bidder': 'medianet',
'params': {
Expand All @@ -67,7 +70,8 @@ let VALID_BID_REQUEST = [{
'sizes': [[300, 251]],
'bidId': '3f97ca71b1e5c2',
'bidderRequestId': '1e9b1f07797c1c',
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d'
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d',
'displayCount': 1
}],
VALID_AUCTIONDATA = {
'timeout': config.getConfig('bidderTimeout'),
Expand Down Expand Up @@ -103,7 +107,8 @@ let VALID_BID_REQUEST = [{
x: 100,
y: 100
}
}
},
'display_count': 1
},
'banner': [{
'w': 300,
Expand Down Expand Up @@ -133,7 +138,8 @@ let VALID_BID_REQUEST = [{
x: 100,
y: 100
}
}
},
'display_count': 1
},
'banner': [{
'w': 300,
Expand Down Expand Up @@ -181,7 +187,8 @@ let VALID_BID_REQUEST = [{
x: 100,
y: 100
}
}
},
'display_count': 1
},
'banner': [{
'w': 300,
Expand Down Expand Up @@ -210,7 +217,8 @@ let VALID_BID_REQUEST = [{
x: 100,
y: 100
}
}
},
'display_count': 1
},
'banner': [{
'w': 300,
Expand Down Expand Up @@ -372,7 +380,8 @@ let VALID_BID_REQUEST = [{
'sizes': [300, 250],
'bidId': '28f8f8130a583e',
'bidderRequestId': '1e9b1f07797c1c',
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d'
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d',
'displayCount': 1
}, {
'bidder': 'medianet',
'params': {
Expand All @@ -388,7 +397,8 @@ let VALID_BID_REQUEST = [{
'sizes': [300, 251],
'bidId': '3f97ca71b1e5c2',
'bidderRequestId': '1e9b1f07797c1c',
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d'
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d',
'displayCount': 1
}],
VALID_BIDDER_REQUEST_WITH_GDPR = {
'gdprConsent': {
Expand Down Expand Up @@ -429,7 +439,8 @@ let VALID_BID_REQUEST = [{
x: 100,
y: 100
}
}
},
'display_count': 1
},
'banner': [{
'w': 300,
Expand Down Expand Up @@ -458,7 +469,8 @@ let VALID_BID_REQUEST = [{
x: 100,
y: 100
}
}
},
'display_count': 1
},
'banner': [{
'w': 300,
Expand Down