Bug 1463080 - Instrument inspection of "Edit HTML" in Inspector with event telemetry r?yulia draft
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Wed, 23 May 2018 14:31:16 +0100
changeset 798975 660ea621b911f3d35a3011478861c0c7f813d200
parent 798691 d36cd8bdbc5c0df1d1d7a167f5fedb95c3a3648e
child 799304 d5194faf05cc17def22b29ec97b0a1242de88ffc
push id110906
push usermratcliffe@mozilla.com
push dateWed, 23 May 2018 20:23:49 +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
@@ -265,8 +265,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.