Bug 1352115 - Add scalars for toolbareyedropper, copyuniquecssselector and copyfullcssselector r=bsmedberg,pbro
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Wed, 19 Apr 2017 13:04:12 +0100
changeset 402163 7ab7f74c36a233444da15a80448e7045b086ad5b
parent 402162 032d23aaffe3a22a2b158e2d30bc26183799bed0
child 402164 e8babe547652de8cfb5aa274487151f848fab093
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, pbro
bugs1352115
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1352115 - Add scalars for toolbareyedropper, copyuniquecssselector and copyfullcssselector r=bsmedberg,pbro MozReview-Commit-ID: CeqtJ22GM6M
devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
devtools/client/shared/telemetry.js
devtools/client/shared/test/browser_telemetry_button_eyedropper.js
toolkit/components/telemetry/Scalars.yaml
--- a/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
@@ -1,16 +1,18 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 // Test that the various copy items in the context menu works correctly.
 
 const TEST_URL = URL_ROOT + "doc_inspector_menu.html";
+const SELECTOR_UNIQUE = "devtools.copy.unique.css.selector.opened";
+const SELECTOR_FULL = "devtools.copy.full.css.selector.opened";
 const COPY_ITEMS_TEST_DATA = [
   {
     desc: "copy inner html",
     id: "node-menu-copyinner",
     selector: "[data-id=\"copy\"]",
     text: "Paragraph for testing copy",
   },
   {
@@ -21,35 +23,65 @@ const COPY_ITEMS_TEST_DATA = [
   },
   {
     desc: "copy unique selector",
     id: "node-menu-copyuniqueselector",
     selector: "[data-id=\"copy\"]",
     text: "body > div:nth-child(1) > p:nth-child(2)",
   },
   {
-    desc: "copy css path",
+    desc: "copy CSS path",
     id: "node-menu-copycsspath",
     selector: "[data-id=\"copy\"]",
     text: "html body div p",
   },
   {
     desc: "copy image data uri",
     id: "node-menu-copyimagedatauri",
     selector: "#copyimage",
     text: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABC" +
       "AAAAAA6fptVAAAACklEQVQYV2P4DwABAQEAWk1v8QAAAABJRU5ErkJggg==",
   },
 ];
 
 add_task(function* () {
+  let Telemetry = loadTelemetryAndRecordLogs();
   let { inspector } = yield openInspectorForURL(TEST_URL);
+
   for (let {desc, id, selector, text} of COPY_ITEMS_TEST_DATA) {
     info("Testing " + desc);
     yield selectNode(selector, inspector);
 
     let allMenuItems = openContextMenuAndGetAllItems(inspector);
     let item = allMenuItems.find(i => i.id === id);
     ok(item, "The popup has a " + desc + " menu item.");
 
     yield waitForClipboardPromise(() => item.click(), text);
   }
+
+  checkTelemetryResults(Telemetry);
+  stopRecordingTelemetryLogs(Telemetry);
 });
+
+function checkTelemetryResults(Telemetry) {
+  let data = Telemetry.prototype.telemetryInfo;
+  let results = new Map();
+
+  for (let key in data) {
+    if (key.toLowerCase() === key) {
+      let pings = data[key].length;
+
+      results.set(key, pings);
+    }
+  }
+
+  is(results.size, 2, "The correct number of scalars were logged");
+
+  let pings = checkPings(SELECTOR_UNIQUE, results);
+  is(pings, 1, `${SELECTOR_UNIQUE} has just 1 ping`);
+
+  pings = checkPings(SELECTOR_FULL, results);
+  is(pings, 1, `${SELECTOR_FULL} has just 1 ping`);
+}
+
+function checkPings(scalarId, results) {
+  return results.get(scalarId);
+}
--- a/devtools/client/shared/telemetry.js
+++ b/devtools/client/shared/telemetry.js
@@ -133,23 +133,23 @@ Telemetry.prototype = {
     },
     menueyedropper: {
       histogram: "DEVTOOLS_MENU_EYEDROPPER_OPENED_COUNT",
     },
     pickereyedropper: {
       histogram: "DEVTOOLS_PICKER_EYEDROPPER_OPENED_COUNT",
     },
     toolbareyedropper: {
-      histogram: "DEVTOOLS_TOOLBAR_EYEDROPPER_OPENED_COUNT",
+      scalar: "devtools.toolbar.eyedropper.opened",
     },
     copyuniquecssselector: {
-      histogram: "DEVTOOLS_COPY_UNIQUE_CSS_SELECTOR_OPENED_COUNT",
+      scalar: "devtools.copy.unique.css.selector.opened",
     },
     copyfullcssselector: {
-      histogram: "DEVTOOLS_COPY_FULL_CSS_SELECTOR_OPENED_COUNT",
+      scalar: "devtools.copy.full.css.selector.opened",
     },
     developertoolbar: {
       histogram: "DEVTOOLS_DEVELOPERTOOLBAR_OPENED_COUNT",
       timerHistogram: "DEVTOOLS_DEVELOPERTOOLBAR_TIME_ACTIVE_SECONDS"
     },
     aboutdebugging: {
       histogram: "DEVTOOLS_ABOUTDEBUGGING_OPENED_COUNT",
       timerHistogram: "DEVTOOLS_ABOUTDEBUGGING_TIME_ACTIVE_SECONDS"
--- a/devtools/client/shared/test/browser_telemetry_button_eyedropper.js
+++ b/devtools/client/shared/test/browser_telemetry_button_eyedropper.js
@@ -1,14 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf-8," +
   "<p>browser_telemetry_button_eyedropper.js</p><div>test</div>";
+const EYEDROPPER_OPENED = "devtools.toolbar.eyedropper.opened";
 
 add_task(function* () {
   yield addTab(TEST_URI);
   let Telemetry = loadTelemetryAndRecordLogs();
 
   let target = TargetFactory.forTab(gBrowser.selectedTab);
   let toolbox = yield gDevTools.showToolbox(target, "inspector");
   info("inspector opened");
@@ -22,31 +23,32 @@ add_task(function* () {
 });
 
 function* testButton(toolbox, Telemetry) {
   info("Calling the eyedropper button's callback");
   // We call the button callback directly because we don't need to test the UI here, we're
   // only concerned about testing the telemetry probe.
   yield toolbox.getPanel("inspector").showEyeDropper();
 
-  checkResults("_EYEDROPPER_", Telemetry);
+  checkTelemetryResults(Telemetry);
 }
 
-function checkResults(histIdFocus, Telemetry) {
-  let result = Telemetry.prototype.telemetryInfo;
+function checkTelemetryResults(Telemetry) {
+  let data = Telemetry.prototype.telemetryInfo;
+  let results = new Map();
 
-  for (let [histId, value] of Object.entries(result)) {
-    if (histId.startsWith("DEVTOOLS_INSPECTOR_") ||
-        !histId.includes(histIdFocus)) {
-      // Inspector stats are tested in
-      // browser_telemetry_toolboxtabs_{toolname}.js so we skip them here
-      // because we only open the inspector once for this test.
-      continue;
-    }
+  for (let key in data) {
+    if (key.toLowerCase() === key) {
+      let pings = data[key].length;
 
-    if (histId.endsWith("OPENED_COUNT")) {
-      is(value.length, 1, histId + " has one entry");
-
-      let okay = value.every(element => element === true);
-      ok(okay, "All " + histId + " entries are === true");
+      results.set(key, pings);
     }
   }
+
+  is(results.size, 1, "The correct number of scalars were logged");
+
+  let pings = checkPings(EYEDROPPER_OPENED, results);
+  is(pings, 1, `${EYEDROPPER_OPENED} has just 1 ping`);
 }
+
+function checkPings(scalarId, results) {
+  return results.get(scalarId);
+}
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -531,8 +531,50 @@ dom.contentprocess:
     expires: "58"
     kind: uint
     notification_emails:
       - benjamin@smedbergs.us
       - mconley@mozilla.com
     release_channel_collection: opt-in
     record_in_processes:
       - 'main'
+
+devtools.toolbar.eyedropper:
+  opened:
+    bug_numbers:
+      - 1247985
+      - 1352115
+    description: Number of times the DevTools Eyedropper has been opened via the inspector toolbar.
+    expires: never
+    kind: uint
+    notification_emails:
+      - dev-developer-tools@lists.mozilla.org
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+
+devtools.copy.unique.css.selector:
+  opened:
+    bug_numbers:
+      - 1323700
+      - 1352115
+    description: Number of times the DevTools copy unique CSS selector has been used.
+    expires: "57"
+    kind: uint
+    notification_emails:
+      - dev-developer-tools@lists.mozilla.org
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+
+devtools.copy.full.css.selector:
+  opened:
+    bug_numbers:
+      - 1323700
+      - 1352115
+    description: Number of times the DevTools copy full CSS selector has been used.
+    expires: "57"
+    kind: uint
+    notification_emails:
+      - dev-developer-tools@lists.mozilla.org
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'