Bug 1463080 - Instrument inspection of "Edit HTML" in Inspector with event telemetry r=yulia
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Wed, 23 May 2018 14:31:16 +0100
changeset 801206 d2e3e0b253d2ea32bedebd41944e99d81c6cd370
parent 801205 10244430b1013f34609078289e88ae6558ae6778
child 801207 36333bc2fb034e12cfbdeb153ea08d6e15fb8606
push id111603
push usermozilla@kaply.com
push dateTue, 29 May 2018 22:12:07 +0000
reviewersyulia
bugs1463080
milestone62.0a1
Bug 1463080 - Instrument inspection of "Edit HTML" in Inspector with event telemetry r=yulia MozReview-Commit-ID: 156CmWuHOf1
devtools/client/inspector/markup/markup.js
toolkit/components/telemetry/Events.yaml
--- a/devtools/client/inspector/markup/markup.js
+++ b/devtools/client/inspector/markup/markup.js
@@ -65,16 +65,17 @@ function MarkupView(inspector, frame, co
   EventEmitter.decorate(this);
 
   this.inspector = inspector;
   this.walker = this.inspector.walker;
   this._frame = frame;
   this.win = this._frame.contentWindow;
   this.doc = this._frame.contentDocument;
   this._elt = this.doc.querySelector("#root");
+  this.telemetry = this.inspector.telemetry;
 
   this.maxChildren = Services.prefs.getIntPref("devtools.markup.pagesize",
                                                DEFAULT_MAX_CHILDREN);
 
   this.collapseAttributes = Services.prefs.getBoolPref(ATTR_COLLAPSE_ENABLED_PREF);
   this.collapseAttributeLength = Services.prefs.getIntPref(ATTR_COLLAPSE_LENGTH_PREF);
 
   // Creating the popup to be used to show CSS suggestions.
@@ -1522,24 +1523,31 @@ MarkupView.prototype = {
         return;
       }
       // Load load and create HTML Editor as it is rarely used and fetch complex deps
       if (!this.htmlEditor) {
         let HTMLEditor = require("devtools/client/inspector/markup/views/html-editor");
         this.htmlEditor = new HTMLEditor(this.doc);
       }
       this.htmlEditor.show(container.tagLine, oldValue);
+      const start = this.telemetry.msSystemNow();
       this.htmlEditor.once("popuphidden", (commit, value) => {
         // Need to focus the <html> element instead of the frame / window
         // in order to give keyboard focus back to doc (from editor).
         this.doc.documentElement.focus();
 
         if (commit) {
           this.updateNodeOuterHTML(node, value, oldValue);
         }
+
+        const end = this.telemetry.msSystemNow();
+        this.telemetry.recordEvent("devtools.main", "edit_html", "inspector", null, {
+          "made_changes": commit,
+          "time_open": end - start
+        });
       });
 
       this.emit("begin-editing");
     });
   },
 
   /**
    * Expand or collapse the given node.
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -266,8 +266,19 @@ devtools.main:
     notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
     record_in_processes: ["main"]
     description: User deactivates the responsive_design or split_console in the devtools toolbox.
     release_channel_collection: opt-out
     expiry_version: never
     extra_keys:
       host: "Toolbox host (positioning): bottom, side, window or other."
       width: Toolbox width rounded up to the nearest 50px.
+  edit_html:
+    objects: ["inspector"]
+    bug_numbers: [1463080]
+    notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
+    record_in_processes: ["main"]
+    description: User is editing HTML via the context menu item in the markup view.
+    release_channel_collection: opt-out
+    expiry_version: never
+    extra_keys:
+      made_changes: Indicates whether changes were made.
+      time_open: The amount of time in ms that the HTML editor was open.