diff --git a/resources/dist/index.js b/resources/dist/index.js index a5951087d..7aec822be 100644 Binary files a/resources/dist/index.js and b/resources/dist/index.js differ diff --git a/resources/dist/index.js.map.json b/resources/dist/index.js.map.json index 7a45fe48c..61c3ddf95 100644 Binary files a/resources/dist/index.js.map.json and b/resources/dist/index.js.map.json differ diff --git a/src/instrumentation/statsv.js b/src/instrumentation/statsv.js index 38fd5bb28..a1bd041bb 100644 --- a/src/instrumentation/statsv.js +++ b/src/instrumentation/statsv.js @@ -17,6 +17,10 @@ */ export function isEnabled( user, config, experiments ) { const bucketingRate = config.get( 'wgPopupsStatsvSamplingRate', 0 ); + if ( bucketingRate === 0 || bucketingRate === 1 ) { + // Avoid calling user.sessionId() if possible, since it sets a cookie + return !!bucketingRate; + } return experiments.weightedBoolean( 'ext.Popups.statsv', diff --git a/tests/node-qunit/instrumentation/statsv.test.js b/tests/node-qunit/instrumentation/statsv.test.js index b6741e55d..718e823c9 100644 --- a/tests/node-qunit/instrumentation/statsv.test.js +++ b/tests/node-qunit/instrumentation/statsv.test.js @@ -34,11 +34,15 @@ QUnit.test( '#isEnabled', function ( assert ) { config.delete( 'wgPopupsStatsvSamplingRate' ); - isEnabled( user, config, experiments ); - - assert.deepEqual( - weightedBooleanStub.getCall( 1 ).args[ 1 ], - 0, - 'The bucketing rate should be 0 by default.' + const defaultResult = isEnabled( user, config, experiments ); + assert.strictEqual( + defaultResult, + false, + 'The bucketing is disabled by default.' + ); + assert.strictEqual( + weightedBooleanStub.callCount, + 1, + 'The experiments object is not called when bucketing rate is the default 0.' ); } );