From ba3c0b7f76aaaa3e2aa497b27477631ae63a56d5 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 3 Jul 2017 13:05:00 +0100 Subject: [PATCH] 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 --- resources/dist/index.js | Bin 35612 -> 35609 bytes resources/dist/index.js.map | Bin 285839 -> 285865 bytes src/instrumentation/eventLogging.js | 4 ++-- src/instrumentation/statsv.js | 2 +- .../instrumentation/eventLogging.test.js | 16 +++------------- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/resources/dist/index.js b/resources/dist/index.js index 5caeab087b099cbe99f1c0f82e7d3a8829ac3752..ff6dfe62ca713ec11aeabcaec2d03c80af0a9940 100644 GIT binary patch delta 48 zcmbO;jcMjIrVYP+1r;?Ei}dmm%QDjwOY)0qY7{4P`l&E$s;Nyj_4Ao*<R delta 50 zcmbO^jcLv_rVYP+`8103@)FB3(-TYbi`3L6^Z2Q7)YNEX+8Su;OlI_#n;ht;x4F)5 GwhaK%MGngESLMGsEO$bF);#WD864$qyN&HukM73y}#PLpk9 i_@~#uViKSJp_W+y#^agpu!%_))xKR!+kqMw?*jnQ&RQM- delta 264 zcmZ3vQ?P%h;DiK`WMiWwOG|^46hn(dLvvFjbHh}V$qyN&HukM7Nu>Io_Ms~*OO1+Gt5M|G*m=7^c|D(nzy`6C-qx&&OLq%0O~1X4$#i?vB&M{-MA$YRXxohGIX9V%rrT68*P&W__#pr^t6yvY diff --git a/src/instrumentation/eventLogging.js b/src/instrumentation/eventLogging.js index bbd885863..635cbeb15 100644 --- a/src/instrumentation/eventLogging.js +++ b/src/instrumentation/eventLogging.js @@ -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( diff --git a/src/instrumentation/statsv.js b/src/instrumentation/statsv.js index 747ff78f4..eac68a361 100644 --- a/src/instrumentation/statsv.js +++ b/src/instrumentation/statsv.js @@ -1,5 +1,5 @@ /** - * @module statsvInstrumentation + * @module instrumentation/statsv */ /** diff --git a/tests/node-qunit/instrumentation/eventLogging.test.js b/tests/node-qunit/instrumentation/eventLogging.test.js index d78ac32a9..4b2801032 100644 --- a/tests/node-qunit/instrumentation/eventLogging.test.js +++ b/tests/node-qunit/instrumentation/eventLogging.test.js @@ -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 ) {