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

added default sampling/throttle rate to 5% #9

Merged
merged 1 commit into from
Mar 19, 2020
Merged
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
18 changes: 10 additions & 8 deletions modules/openxAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function filterBidsByAdUnit(bids) {

function isValidEvent(eventType, adUnitCode) {
if (checkAdUnitConfig()) {
let validationEvents = [bidAdjustmentConst, bidResponseConst, bidWonConst];
let validationEvents = [bidAdjustmentConst, bidResponseConst, bidWonConst, bidTimeoutConst];
if (
!includes(initOptions.adUnits, adUnitCode) &&
includes(validationEvents, eventType)
Expand Down Expand Up @@ -234,7 +234,6 @@ function removeads(info) {

let openxAdapter = Object.assign(adapter({ urlParam, analyticsType }), {
track({ eventType, args }) {

if (!checkInitOptions()) {
send(eventType, {}, null);
return;
Expand All @@ -246,7 +245,7 @@ let openxAdapter = Object.assign(adapter({ urlParam, analyticsType }), {
info.ad = '';
}

let auctionId = info.auctionId
let auctionId = info.auctionId;
// utils.logInfo('OX: Got auctionId', auctionId);

if (eventType === auctionInitConst) {
Expand All @@ -271,12 +270,12 @@ let openxAdapter = Object.assign(adapter({ urlParam, analyticsType }), {
eventStack,
auctionId
);
delete eventStack[auctionId];
eventStack[auctionId] = null;
// utils.logInfo('OX: Deleted Auction Info for auctionId', auctionId);
}, AUCTION_END_WAIT_TIME);
} else {
setTimeout(function() {
delete eventStack[auctionId];
eventStack[auctionId] = null;
// utils.logInfo('OX: Deleted Auction Info for auctionId', auctionId);
}, AUCTION_END_WAIT_TIME);
}
Expand All @@ -295,6 +294,9 @@ openxAdapter.enableAnalytics = function(config) {
initOptions.testCode = getTestCode();
initOptions.utmTagData = this.buildUtmTagData();
utils.logInfo('OpenX Analytics enabled with config', initOptions);

// set default sampling rate to 5%
config.options.sampling = config.options.sampling || 0.05;
openxAdapter.originEnableAnalytics(config);
};

Expand Down Expand Up @@ -383,10 +385,10 @@ function apiCall(url, MAX_RETRIES, payload) {

function getRandomUrl(failedUrl) {
let urlHead = 'https://';
let urlTail = '.prebid.openx.net/publish/';
let urlTail = '.openx.net/publish/';
let urlList = [
'analytics',
'analytics-2'
'prebid-analytics',
'prebid-analytics-2'
];
let randomIndex = Math.floor(Math.random() * urlList.length);
let randomUrl = urlHead + urlList[randomIndex] + urlTail;
Expand Down