You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2019/10/20 11:49:15 UTC

[cordova-cli] branch master updated: fix: argument filtering in telemetry.track (#472)

This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new 0bb1083  fix: argument filtering in telemetry.track (#472)
0bb1083 is described below

commit 0bb108384b447033990b2020bc37e5e3538626df
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Sun Oct 20 13:49:07 2019 +0200

    fix: argument filtering in telemetry.track (#472)
    
    Note that this will change what is being tracked
---
 spec/telemetry.spec.js |  3 +--
 src/telemetry.js       | 11 +++--------
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/spec/telemetry.spec.js b/spec/telemetry.spec.js
index e3349a9..ed0360f 100644
--- a/spec/telemetry.spec.js
+++ b/spec/telemetry.spec.js
@@ -122,8 +122,7 @@ describe('telemetry', () => {
             expect(insight.track).toHaveBeenCalledWith(...args);
         });
 
-        // FIXME filtering is currently broken
-        xit('filters falsy and empty arguments [T010]', () => {
+        it('filters falsy and empty arguments [T010]', () => {
             const args = [null, [23], [], 42, ''];
             telemetry.track(...args);
             expect(insight.track).toHaveBeenCalledWith([23], 42);
diff --git a/src/telemetry.js b/src/telemetry.js
index 46cce1e..55765f7 100644
--- a/src/telemetry.js
+++ b/src/telemetry.js
@@ -50,15 +50,10 @@ function showPrompt () {
     });
 }
 
-function track () {
+function track (...args) {
     // Remove empty, null or undefined strings from arguments
-    for (var property in arguments) {
-        var val = arguments[property];
-        if (!val || val.length === 0) {
-            delete arguments.property;
-        }
-    }
-    insight.track.apply(insight, arguments);
+    const filteredArgs = args.filter(val => val && val.length !== 0);
+    insight.track(...filteredArgs);
 }
 
 function turnOn () {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org