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

greenbids Analytics Adapter: fix double sampling bug #11090

Merged
merged 2 commits into from
Feb 14, 2024
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
9 changes: 5 additions & 4 deletions modules/greenbidsAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {deepClone, generateUUID, logError, logInfo, logWarn} from '../src/utils.

const analyticsType = 'endpoint';

export const ANALYTICS_VERSION = '2.0.0';
export const ANALYTICS_VERSION = '2.1.0';

const ANALYTICS_SERVER = 'https://a.greenbids.ai';

Expand All @@ -33,7 +33,6 @@ export const isSampled = function(greenbidsId, samplingRate) {
return true;
}
const hashInt = parseInt(greenbidsId.slice(-4), 16);

return hashInt < samplingRate * (0xFFFF + 1);
}

Expand All @@ -59,8 +58,6 @@ export const greenbidsAnalyticsAdapter = Object.assign(adapter({ANALYTICS_SERVER
if (typeof analyticsOptions.options.sampling === 'number') {
logWarn('"options.sampling" is deprecated, please use "greenbidsSampling" instead.');
analyticsOptions.options.greenbidsSampling = analyticsOptions.options.sampling;
// Set sampling to null to prevent prebid analytics integrated sampling to happen
analyticsOptions.options.sampling = null;
}

/**
Expand Down Expand Up @@ -228,6 +225,10 @@ greenbidsAnalyticsAdapter.originEnableAnalytics = greenbidsAnalyticsAdapter.enab

greenbidsAnalyticsAdapter.enableAnalytics = function(config) {
this.initConfig(config);
if (typeof config.options.sampling === 'number') {
// Set sampling to 1 to prevent prebid analytics integrated sampling to happen
config.options.sampling = 1;
}
logInfo('loading greenbids analytics');
greenbidsAnalyticsAdapter.originEnableAnalytics(config);
};
Expand Down