Bug 1465424 - Added 3 histograms to test font editor usage assumptions; r=rcaliman
authorPatrick Brosset <pbrosset@mozilla.com>
Thu, 19 Jul 2018 14:29:40 +0200
changeset 427456 b2f2361ee3175a867335952705274d8d08cc086f
parent 427455 b891899b2036de7b47cf96790c581fb704588c78
child 427457 ab6c2651f8eff6b2846ee89732089c9ca62f6a13
push id34306
push usercsabou@mozilla.com
push dateFri, 20 Jul 2018 21:41:18 +0000
treeherdermozilla-central@d6a5e8aea651 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrcaliman
bugs1465424
milestone63.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 1465424 - Added 3 histograms to test font editor usage assumptions; r=rcaliman MozReview-Commit-ID: BIkqEzp5BNA
devtools/client/inspector/fonts/fonts.js
toolkit/components/telemetry/Histograms.json
--- a/devtools/client/inspector/fonts/fonts.js
+++ b/devtools/client/inspector/fonts/fonts.js
@@ -50,16 +50,20 @@ const REGISTERED_AXES_TO_FONT_PROPERTIES
   "ital": "font-style",
   "opsz": "font-optical-sizing",
   "slnt": "font-style",
   "wdth": "font-stretch",
   "wght": "font-weight",
 };
 const REGISTERED_AXES = Object.keys(REGISTERED_AXES_TO_FONT_PROPERTIES);
 
+const HISTOGRAM_N_FONT_AXES = "DEVTOOLS_FONTEDITOR_N_FONT_AXES";
+const HISTOGRAM_N_FONTS_RENDERED = "DEVTOOLS_FONTEDITOR_N_FONTS_RENDERED";
+const HISTOGRAM_FONT_TYPE_DISPLAYED = "DEVTOOLS_FONTEDITOR_FONT_TYPE_DISPLAYED";
+
 class FontInspector {
   constructor(inspector, window) {
     this.cssProperties = getCssProperties(inspector.toolbox);
     this.document = window.document;
     this.inspector = inspector;
     // Set of unique keyword values supported by designated font properties.
     this.keywordValues = new Set(this.getFontPropertyValueKeywords());
     this.nodeComputedStyle = {};
@@ -597,16 +601,44 @@ class FontInspector {
     return this.inspector &&
            this.inspector.selection.nodeFront &&
            this.inspector.selection.isConnected() &&
            this.inspector.selection.isElementNode() &&
            !this.inspector.selection.isPseudoElementNode();
   }
 
   /**
+   * Upon a new node selection, log some interesting telemetry probes.
+   */
+  logTelemetryProbesOnNewNode() {
+    const { fontData, fontEditor } = this.store.getState();
+    const { telemetry } = this.inspector;
+
+    // Log the number of font faces used to render content of the element.
+    const nbOfFontsRendered = fontData.fonts.length;
+    if (nbOfFontsRendered) {
+      telemetry.getHistogramById(HISTOGRAM_N_FONTS_RENDERED).add(nbOfFontsRendered);
+    }
+
+    // Log data about the currently edited font (if any).
+    // Note that the edited font is always the first one from the fontEditor.fonts array.
+    const editedFont = fontEditor.fonts[0];
+    if (!editedFont) {
+      return;
+    }
+
+    const nbOfAxes = editedFont.variationAxes ? editedFont.variationAxes.length : 0;
+    telemetry.getHistogramById(HISTOGRAM_FONT_TYPE_DISPLAYED).add(
+      !nbOfAxes ? "nonvariable" : "variable");
+    if (nbOfAxes) {
+      telemetry.getHistogramById(HISTOGRAM_N_FONT_AXES).add(nbOfAxes);
+    }
+  }
+
+  /**
    * Sync the Rule view with the latest styles from the page. Called in a debounced way
    * (see constructor) after property changes are applied directly to the CSS style rule
    * on the page circumventing direct TextProperty.setValue() which triggers expensive DOM
    * operations in TextPropertyEditor.update().
    *
    * @param  {String} name
    *         CSS property name
    * @param  {String} value
@@ -681,18 +713,19 @@ class FontInspector {
   }
 
   /**
    * Selection 'new-node' event handler.
    */
   onNewNode() {
     this.ruleView.off("property-value-updated", this.onRulePropertyUpdated);
     if (this.isPanelVisible()) {
-      this.update();
-      this.refreshFontEditor();
+      Promise.all([this.update(), this.refreshFontEditor()]).then(() => {
+        this.logTelemetryProbesOnNewNode();
+      }).catch(e => console.error(e));
     }
   }
 
   /**
    * Handler for change in preview input.
    */
   onPreviewFonts(value) {
     this.store.dispatch(updatePreviewText(value));
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -10150,16 +10150,48 @@
     "expires_in_version": "never",
     "kind": "linear",
     "high": 30,
     "n_buckets": 29,
     "bug_numbers": [1373483],
     "description": "On page load, record the number of CSS Grid elements present on a page when the DevTools is open",
     "releaseChannelCollection": "opt-out"
   },
+  "DEVTOOLS_FONTEDITOR_N_FONT_AXES": {
+    "record_in_processes": ["main"],
+    "alert_emails": ["dev-developer-tools@lists.mozilla.org", "mbalfanz@mozilla.com"],
+    "expires_in_version": "66",
+    "bug_numbers": [1465424],
+    "description": "Indicates the number of variation axes of the variable fonts that are displayed in the font editor UI",
+    "releaseChannelCollection": "opt-out",
+    "kind": "exponential",
+    "high": 100,
+    "n_buckets": 20
+  },
+  "DEVTOOLS_FONTEDITOR_N_FONTS_RENDERED": {
+    "record_in_processes": ["main"],
+    "alert_emails": ["dev-developer-tools@lists.mozilla.org", "mbalfanz@mozilla.com"],
+    "expires_in_version": "66",
+    "bug_numbers": [1465424],
+    "description": "Indicates how many fonts the font editor displayed as being needed to render the selected element's content",
+    "releaseChannelCollection": "opt-out",
+    "kind": "exponential",
+    "high": 50,
+    "n_buckets": 10
+  },
+  "DEVTOOLS_FONTEDITOR_FONT_TYPE_DISPLAYED": {
+    "record_in_processes": ["main"],
+    "alert_emails": ["dev-developer-tools@lists.mozilla.org", "mbalfanz@mozilla.com"],
+    "expires_in_version": "66",
+    "bug_numbers": [1465424],
+    "description": "Indicates if the font editor displayed its UI for a non-variable font or a variable font",
+    "releaseChannelCollection": "opt-out",
+    "kind": "categorical",
+    "labels": ["variable", "nonvariable"]
+  },
   "BROWSER_IS_USER_DEFAULT": {
     "record_in_processes": ["main"],
     "expires_in_version": "never",
     "kind": "boolean",
     "releaseChannelCollection": "opt-out",
     "description": "The result of the startup default desktop browser check."
   },
   "BROWSER_IS_USER_DEFAULT_ERROR": {