From ba09fc1959dd1362db90ba17f9e89d72dda0796d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Pettit Date: Mon, 12 Jun 2023 12:50:57 +0200 Subject: [PATCH 1/3] fix greenbids analytics double sampling --- modules/greenbidsAnalyticsAdapter.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/modules/greenbidsAnalyticsAdapter.js b/modules/greenbidsAnalyticsAdapter.js index d5aff5ab32a..edc0c9c6c5c 100644 --- a/modules/greenbidsAnalyticsAdapter.js +++ b/modules/greenbidsAnalyticsAdapter.js @@ -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; @@ -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() { From 14e1fcf8b6ea21c07bf88c0c7a803c233023e46e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Pettit Date: Mon, 12 Jun 2023 13:05:02 +0200 Subject: [PATCH 2/3] fix tests --- .../modules/greenbidsAnalyticsAdapter_spec.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/test/spec/modules/greenbidsAnalyticsAdapter_spec.js b/test/spec/modules/greenbidsAnalyticsAdapter_spec.js index b3cbf4c47c2..b1f8cb95909 100644 --- a/test/spec/modules/greenbidsAnalyticsAdapter_spec.js +++ b/test/spec/modules/greenbidsAnalyticsAdapter_spec.js @@ -389,7 +389,7 @@ 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); + expect(greenbidsAnalyticsAdapter.getAnalyticsOptions().sampling).to.equal(0); }); it('should not enable Analytics when pbuid is missing', function () { @@ -400,19 +400,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); - }); }); }); From 9075ba4992b9d3ea1df5bb8e79a9b2822d7d87ae Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Pettit Date: Mon, 12 Jun 2023 13:50:18 +0200 Subject: [PATCH 3/3] fix tests --- test/spec/modules/greenbidsAnalyticsAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/greenbidsAnalyticsAdapter_spec.js b/test/spec/modules/greenbidsAnalyticsAdapter_spec.js index b1f8cb95909..870fbd23870 100644 --- a/test/spec/modules/greenbidsAnalyticsAdapter_spec.js +++ b/test/spec/modules/greenbidsAnalyticsAdapter_spec.js @@ -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().sampling).to.equal(0); }); it('should not enable Analytics when pbuid is missing', function () {