[go: up one dir, main page]

Replace empty strings with "n/a" in metrics

This CL fixes the bug where data studio filters out empty strings and
make us unable to draw pie chart effectively.

(cherry picked from commit 23555a5eba7785fde3c6c974a0053b135fe65891)

Bug: 969647
Test: Capture some photos
Change-Id: Ie8714b0709a5d040408905df3bb4c62459fd8b3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1640933
Commit-Queue: Sheng-hao Tsao <shenghao@chromium.org>
Reviewed-by: Wei Lee <wtlee@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#666184}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1652632
Reviewed-by: Sheng-hao Tsao <shenghao@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#208}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/chrome/browser/resources/chromeos/camera/src/js/metrics.js b/chrome/browser/resources/chromeos/camera/src/js/metrics.js
index 9368456..61919b61 100644
--- a/chrome/browser/resources/chromeos/camera/src/js/metrics.js
+++ b/chrome/browser/resources/chromeos/camera/src/js/metrics.js
@@ -101,11 +101,15 @@
  * @private
  */
 cca.metrics.captureType_ = function(facingMode, length, [width, height]) {
-  var condState = (states, cond) => {
+  var condState = (states, cond, strict) => {
     // Return the first existing state among the given states only if there is
     // no gate condition or the condition is met.
     const prerequisite = !cond || cca.state.get(cond);
-    return prerequisite && states.find((state) => cca.state.get(state)) || '';
+    if (strict && !prerequisite) {
+      return '';
+    }
+    return prerequisite && states.find((state) => cca.state.get(state)) ||
+        'n/a';
   };
 
   return cca.metrics.base_.category('capture')
@@ -116,7 +120,7 @@
       .dimen(4, condState(['mirror']))
       .dimen(5, condState(['_3x3', '_4x4', 'golden'], 'grid'))
       .dimen(6, condState(['_3sec', '_10sec'], 'timer'))
-      .dimen(7, condState(['mic'], 'video-mode'))
+      .dimen(7, condState(['mic'], 'video-mode', true))
       .dimen(8, condState(['max-wnd']))
       .dimen(9, condState(['tall']))
       .dimen(10, `${width}x${height}`)