mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-27 17:00:37 +00:00
Hygiene: i13n: Return false over not sampling
Previously, if the browser didn't support the Beacon API, then instrumentation/eventLogging#isEnabled would bucket the user with a sampling rate of 0, which is equivalent to returning false. This change simply does the latter. Additional changes: * Update the documented module names of the instrumentation/eventLogging and statsv modules. Bug: T168847 Change-Id: I7ae5c10da42ca614b5b1a6619f9555e5665344cf
This commit is contained in:
parent
6ef2816fbd
commit
ba3c0b7f76
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map
vendored
BIN
resources/dist/index.js.map
vendored
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @module schema
|
||||
* @module instrumentation/eventLogging
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ exports.isEnabled = function isEnabled( user, config, experiments, window ) {
|
|||
!window.navigator ||
|
||||
!$.isFunction( window.navigator.sendBeacon )
|
||||
) {
|
||||
samplingRate = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return experiments.weightedBoolean(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @module statsvInstrumentation
|
||||
* @module instrumentation/statsv
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,15 +57,10 @@ QUnit.test( 'it should use wgPopupsSchemaSamplingRate as the sampling rate', fun
|
|||
);
|
||||
} );
|
||||
|
||||
QUnit.test( 'it should use a 0 bucketing rate when sendBeacon isn\'t supported', function ( assert ) {
|
||||
QUnit.test( 'it should return false when sendBeacon isn\'t supported', function ( assert ) {
|
||||
var window = {};
|
||||
|
||||
isEnabled( this.user, this.config, this.experiments, window );
|
||||
|
||||
assert.deepEqual(
|
||||
this.experiments.weightedBoolean.getCall( 0 ).args[ 1 ],
|
||||
/* trueWeight = */ 0
|
||||
);
|
||||
assert.notOk( isEnabled( this.user, this.config, this.experiments, window ) );
|
||||
|
||||
// ---
|
||||
|
||||
|
@ -73,12 +68,7 @@ QUnit.test( 'it should use a 0 bucketing rate when sendBeacon isn\'t supported',
|
|||
sendBeacon: 'NOT A FUNCTION'
|
||||
};
|
||||
|
||||
isEnabled( this.user, this.config, this.experiments, window );
|
||||
|
||||
assert.deepEqual(
|
||||
this.experiments.weightedBoolean.getCall( 1 ).args[ 1 ],
|
||||
/* trueWeight = */ 0
|
||||
);
|
||||
assert.notOk( isEnabled( this.user, this.config, this.experiments, window ) );
|
||||
} );
|
||||
|
||||
QUnit.test( 'it should return the weighted boolean', function ( assert ) {
|
||||
|
|
Loading…
Reference in a new issue