mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-27 08:50:33 +00:00
Merge "instrumentation: Avoid user.sessionId()
if possible, since it sets a cookie"
This commit is contained in:
commit
319d1a14f7
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map.json
vendored
BIN
resources/dist/index.js.map.json
vendored
Binary file not shown.
|
@ -17,6 +17,10 @@
|
||||||
*/
|
*/
|
||||||
export function isEnabled( user, config, experiments ) {
|
export function isEnabled( user, config, experiments ) {
|
||||||
const bucketingRate = config.get( 'wgPopupsStatsvSamplingRate', 0 );
|
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(
|
return experiments.weightedBoolean(
|
||||||
'ext.Popups.statsv',
|
'ext.Popups.statsv',
|
||||||
|
|
|
@ -34,11 +34,15 @@ QUnit.test( '#isEnabled', function ( assert ) {
|
||||||
|
|
||||||
config.delete( 'wgPopupsStatsvSamplingRate' );
|
config.delete( 'wgPopupsStatsvSamplingRate' );
|
||||||
|
|
||||||
isEnabled( user, config, experiments );
|
const defaultResult = isEnabled( user, config, experiments );
|
||||||
|
assert.strictEqual(
|
||||||
assert.deepEqual(
|
defaultResult,
|
||||||
weightedBooleanStub.getCall( 1 ).args[ 1 ],
|
false,
|
||||||
0,
|
'The bucketing is disabled by default.'
|
||||||
'The bucketing rate should be 0 by default.'
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
weightedBooleanStub.callCount,
|
||||||
|
1,
|
||||||
|
'The experiments object is not called when bucketing rate is the default 0.'
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in a new issue