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 #10091

Merged
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
20 changes: 7 additions & 13 deletions modules/greenbidsAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export const greenbidsAnalyticsAdapter = Object.assign(adapter({ANALYTICS_SERVER
logError('"options.pbuid" is required.');
return false;
}
analyticsOptions.sampled = true;
if (typeof config.options.sampling === 'number') {
analyticsOptions.sampled = Math.random() < parseFloat(config.options.sampling);
}

analyticsOptions.pbuid = config.options.pbuid
analyticsOptions.server = ANALYTICS_SERVER;
Expand Down Expand Up @@ -149,15 +145,13 @@ export const greenbidsAnalyticsAdapter = Object.assign(adapter({ANALYTICS_SERVER
});
},
track({eventType, args}) {
if (analyticsOptions.sampled) {
switch (eventType) {
case BID_TIMEOUT:
this.handleBidTimeout(args);
break;
case AUCTION_END:
this.handleAuctionEnd(args);
break;
}
switch (eventType) {
case BID_TIMEOUT:
this.handleBidTimeout(args);
break;
case AUCTION_END:
this.handleAuctionEnd(args);
break;
}
},
getAnalyticsOptions() {
Expand Down
15 changes: 0 additions & 15 deletions test/spec/modules/greenbidsAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ describe('Greenbids Prebid AnalyticsAdapter Testing', function () {
it('should parse config correctly with optional values', function () {
expect(greenbidsAnalyticsAdapter.getAnalyticsOptions().options).to.deep.equal(configOptions);
expect(greenbidsAnalyticsAdapter.getAnalyticsOptions().pbuid).to.equal(configOptions.pbuid);
expect(greenbidsAnalyticsAdapter.getAnalyticsOptions().sampled).to.equal(false);
});

it('should not enable Analytics when pbuid is missing', function () {
Expand All @@ -400,19 +399,5 @@ describe('Greenbids Prebid AnalyticsAdapter Testing', function () {
const validConfig = greenbidsAnalyticsAdapter.initConfig(configOptions);
expect(validConfig).to.equal(false);
});
it('should fall back to default value when sampling factor is not number', function () {
const configOptions = {
options: {
pbuid: pbuid,
sampling: 'string',
}
};
greenbidsAnalyticsAdapter.enableAnalytics({
provider: 'greenbidsAnalytics',
options: configOptions
});

expect(greenbidsAnalyticsAdapter.getAnalyticsOptions().sampled).to.equal(false);
});
});
});