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:
Sam Smith 2017-07-03 13:05:00 +01:00 committed by Jdlrobson
parent 6ef2816fbd
commit ba3c0b7f76
5 changed files with 6 additions and 16 deletions

Binary file not shown.

Binary file not shown.

View file

@ -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(

View file

@ -1,5 +1,5 @@
/**
* @module statsvInstrumentation
* @module instrumentation/statsv
*/
/**

View file

@ -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 ) {