Bug 1530997 - Record additional extras in devtools.main runtime_connected event;r=daisuke,janerik
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 01 Mar 2019 19:58:23 +0000
changeset 519891 bb39584f96d000078eea0659b8f2b89528337638
parent 519890 0c13462c5416fc2973cfcf6f1856f5e19d194c40
child 519892 e254496ff95b683df29479a41341f3f2fa6a71f4
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke, janerik
bugs1530997
milestone67.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 1530997 - Record additional extras in devtools.main runtime_connected event;r=daisuke,janerik Differential Revision: https://phabricator.services.mozilla.com/D21373
devtools/client/aboutdebugging-new/src/actions/runtimes.js
devtools/client/aboutdebugging-new/src/middleware/event-recording.js
devtools/client/aboutdebugging-new/src/modules/client-wrapper.js
devtools/client/aboutdebugging-new/src/types/runtime.js
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_telemetry_runtime_connected_details.js
toolkit/components/telemetry/Events.yaml
--- a/devtools/client/aboutdebugging-new/src/actions/runtimes.js
+++ b/devtools/client/aboutdebugging-new/src/actions/runtimes.js
@@ -98,16 +98,17 @@ function connectRuntime(id) {
         clientWrapper,
         compatibilityReport,
         connectionPromptEnabled,
         extensionDebugEnabled,
         info: {
           deviceName: deviceDescription.deviceName,
           icon,
           name: deviceDescription.name,
+          os: deviceDescription.os,
           type: runtime.type,
           version: deviceDescription.version,
         },
         isMultiE10s: deviceDescription.isMultiE10s,
         serviceWorkersAvailable,
       };
 
       const deviceFront = await clientWrapper.getFront("device");
--- a/devtools/client/aboutdebugging-new/src/middleware/event-recording.js
+++ b/devtools/client/aboutdebugging-new/src/middleware/event-recording.js
@@ -69,17 +69,21 @@ function onConnectRuntimeSuccess(action,
     return;
   }
   // When we just connected to a runtime, the runtimeDetails are not in the store yet,
   // so we merge it here to retrieve the expected telemetry data.
   const storeRuntime = findRuntimeById(action.runtime.id, store.getState().runtimes);
   const runtime = Object.assign({}, storeRuntime, {
     runtimeDetails: action.runtime.runtimeDetails,
   });
-  recordEvent("runtime_connected", getRuntimeEventExtras(runtime));
+  const extras = Object.assign({}, getRuntimeEventExtras(runtime), {
+    "runtime_os": action.runtime.runtimeDetails.info.os,
+    "runtime_version": action.runtime.runtimeDetails.info.version,
+  });
+  recordEvent("runtime_connected", extras);
 }
 
 function onDisconnectRuntimeSuccess(action, store) {
   const runtime = findRuntimeById(action.runtime.id, store.getState().runtimes);
   if (runtime.type === RUNTIMES.THIS_FIREFOX) {
     // Only record connection and disconnection events for remote runtimes.
     return;
   }
--- a/devtools/client/aboutdebugging-new/src/modules/client-wrapper.js
+++ b/devtools/client/aboutdebugging-new/src/modules/client-wrapper.js
@@ -79,16 +79,17 @@ class ClientWrapper {
     const deviceFront = await this.getFront("device");
     const description = await deviceFront.getDescription();
     // Only expose a specific set of properties.
     return {
       channel: description.channel,
       deviceName: description.deviceName,
       isMultiE10s: description.isMultiE10s,
       name: description.brandName,
+      os: description.os,
       version: description.version,
     };
   }
 
   async checkVersionCompatibility() {
     return checkVersionCompatibility(this.client);
   }
 
--- a/devtools/client/aboutdebugging-new/src/types/runtime.js
+++ b/devtools/client/aboutdebugging-new/src/types/runtime.js
@@ -14,16 +14,22 @@ const runtimeInfo = {
   deviceName: PropTypes.string,
 
   // icon which represents the kind of runtime
   icon: PropTypes.string.isRequired,
 
   // name of runtime such as "Firefox Nightly"
   name: PropTypes.string.isRequired,
 
+  // operating system on which the runtime runs such as "Android", "Linux"
+  os: PropTypes.string.isRequired,
+
+  // runtime type, for instance "network", "usb" ...
+  type: PropTypes.string.isRequired,
+
   // version of runtime
   version: PropTypes.string.isRequired,
 };
 
 const compatibilityReport = {
   // build ID for the current runtime (date formatted as yyyyMMdd eg "20193101")
   localID: PropTypes.string.isRequired,
 
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -93,15 +93,16 @@ skip-if = (os == 'linux' && bits == 32) 
 [browser_aboutdebugging_stop_adb.js]
 skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638
 [browser_aboutdebugging_system_addons.js]
 [browser_aboutdebugging_tab_favicons.js]
 [browser_aboutdebugging_telemetry_basic.js]
 [browser_aboutdebugging_telemetry_inspect.js]
 [browser_aboutdebugging_telemetry_navigate.js]
 [browser_aboutdebugging_telemetry_runtime_actions.js]
+[browser_aboutdebugging_telemetry_runtime_connected_details.js]
 [browser_aboutdebugging_telemetry_runtime_updates.js]
 [browser_aboutdebugging_telemetry_runtime_updates_multi.js]
 [browser_aboutdebugging_telemetry_runtime_updates_network.js]
 [browser_aboutdebugging_thisfirefox.js]
 [browser_aboutdebugging_thisfirefox_runtime_info.js]
 [browser_aboutdebugging_thisfirefox_worker_inspection.js]
 [browser_aboutdebugging_workers_remote_runtime.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_telemetry_runtime_connected_details.js
@@ -0,0 +1,56 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/* import-globals-from helper-telemetry.js */
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-telemetry.js", this);
+
+const REMOTE_RUNTIME_ID = "remote-runtime";
+const REMOTE_RUNTIME = "Remote Runtime";
+const REMOTE_DEVICE = "Remote Device";
+
+const REMOTE_VERSION = "12.0a1";
+const REMOTE_OS = "SOME_OS";
+
+/**
+ * Runtime connected events will log additional extras about the runtime connection that
+ * was established.
+ */
+add_task(async function() {
+  const mocks = new Mocks();
+
+  const usbClient = mocks.createUSBRuntime(REMOTE_RUNTIME_ID, {
+    deviceName: REMOTE_DEVICE,
+    name: REMOTE_RUNTIME,
+    shortName: REMOTE_RUNTIME,
+  });
+  usbClient.getDeviceDescription = () => {
+    return {
+      os: REMOTE_OS,
+      version: REMOTE_VERSION,
+    };
+  };
+
+  const { document, tab } = await openAboutDebugging();
+
+  mocks.emitUSBUpdate();
+  await connectToRuntime(REMOTE_DEVICE, document);
+  const evts = readAboutDebuggingEvents().filter(e => e.method === "runtime_connected");
+
+  is(evts.length, 1, "runtime_connected event logged when connecting to remote runtime");
+  const {
+    connection_type,
+    device_name,
+    runtime_name,
+    runtime_os,
+    runtime_version,
+  } = evts[0].extras;
+  is(connection_type, "usb", "Expected value for `connection_type` extra");
+  is(device_name, REMOTE_DEVICE, "Expected value for `device_name` extra");
+  is(runtime_name, REMOTE_RUNTIME, "Expected value for `runtime_name` extra");
+  is(runtime_os, REMOTE_OS, "Expected value for `runtime_os` extra");
+  is(runtime_version, REMOTE_VERSION, "Expected value for `runtime_version` extra");
+
+  await removeTab(tab);
+});
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -740,27 +740,29 @@ devtools.main:
     extra_keys:
       connection_type: Connection type
       device_name: Name of the device on which the runtime is running (optional)
       runtime_id: Random id generated to track events related to a single runtime
       runtime_name: Name of the runtime
       session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
   runtime_connected:
     objects: ["aboutdebugging"]
-    bug_numbers: [1521507]
+    bug_numbers: [1521507, 1530997]
     notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
     record_in_processes: ["main"]
     description: Connection was established with a remote runtime in about:debugging
     release_channel_collection: opt-out
     expiry_version: never
     extra_keys:
       connection_type: Connection type
       device_name: Name of the device on which the runtime is running (optional)
       runtime_id: Random id generated to track events related to a single runtime
       runtime_name: Name of the runtime
+      runtime_os: Operating system on which the runtime is running (eg Android or Linux)
+      runtime_version: Version of the runtime (eg 67.0a1)
       session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
   runtime_disconnected:
     objects: ["aboutdebugging"]
     bug_numbers: [1521507]
     notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
     record_in_processes: ["main"]
     description: Connection was lost with a remote runtime in about debugging
     release_channel_collection: opt-out