Bug 1086252 - Show stable client id in about:telemetry. r=froydnj
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Thu, 23 Oct 2014 15:42:04 +0200
changeset 228161 710ca80bb1d7eb4b8ee503c4e139b319efc06981
parent 228160 87433694df019680550e698e2e9ddfbccba0e8ef
child 228162 6b1c21afbce3fd9edc13099a16e3f17ad8c99504
push id7326
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:58:42 +0000
treeherdermozilla-aurora@d3a3b2a0f2f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1086252
milestone36.0a1
Bug 1086252 - Show stable client id in about:telemetry. r=froydnj
toolkit/components/telemetry/TelemetryPing.jsm
toolkit/content/aboutTelemetry.js
toolkit/content/aboutTelemetry.xhtml
toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
--- a/toolkit/components/telemetry/TelemetryPing.jsm
+++ b/toolkit/components/telemetry/TelemetryPing.jsm
@@ -222,17 +222,26 @@ this.TelemetryPing = Object.freeze({
   getMetadata: function(reason) {
     return Impl.getMetadata(reason);
   },
   /**
    * Send a notification.
    */
   observe: function (aSubject, aTopic, aData) {
     return Impl.observe(aSubject, aTopic, aData);
-  }
+  },
+
+  /**
+   * The client id send with the telemetry ping.
+   *
+   * @return The client id as string, or null.
+   */
+   get clientID() {
+    return Impl.clientID;
+   },
 });
 
 let Impl = {
   _histograms: {},
   _initialized: false,
   _prevValues: {},
   // Generate a unique id once per session so the server can cope with
   // duplicate submissions.
@@ -1142,9 +1151,13 @@ let Impl = {
       if (Telemetry.canSend) {
         let ping = this.getSessionPayloadAndSlug("saved-session");
         TelemetryFile.savePing(ping, true);
       }
       break;
 #endif
     }
   },
+
+  get clientID() {
+    return this._clientID;
+  },
 };
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -103,16 +103,58 @@ let observer = {
     } else {
       enabledElement.classList.add("hidden");
       disabledElement.classList.remove("hidden");
       toggleElement.innerHTML = this.enableTelemetry;
     }
   }
 };
 
+let GeneralData = {
+  /**
+   * Renders the general data
+   */
+  render: function() {
+    setHasData("general-data-section", true);
+
+    let table = document.createElement("table");
+
+    let caption = document.createElement("caption");
+    caption.appendChild(document.createTextNode("General data\n"));
+    table.appendChild(caption);
+
+    let headings = document.createElement("tr");
+    this.appendColumn(headings, "th", bundle.GetStringFromName("generalDataHeadingName") + "\t");
+    this.appendColumn(headings, "th", bundle.GetStringFromName("generalDataHeadingValue") + "\t");
+    table.appendChild(headings);
+
+    let row = document.createElement("tr");
+    this.appendColumn(row, "td", "Client ID\t");
+    this.appendColumn(row, "td", TelemetryPing.clientID + "\t");
+    table.appendChild(row);
+
+    let dataDiv = document.getElementById("general-data");
+    dataDiv.appendChild(table);
+  },
+
+  /**
+   * Helper function for appending a column to the data table.
+   *
+   * @param aRowElement Parent row element
+   * @param aColType Column's tag name
+   * @param aColText Column contents
+   */
+  appendColumn: function(aRowElement, aColType, aColText) {
+    let colElement = document.createElement(aColType);
+    let colTextElement = document.createTextNode(aColText);
+    colElement.appendChild(colTextElement);
+    aRowElement.appendChild(colElement);
+  },
+};
+
 let SlowSQL = {
 
   slowSqlHits: bundle.GetStringFromName("slowSqlHits"),
 
   slowSqlAverage: bundle.GetStringFromName("slowSqlAverage"),
 
   slowSqlStatement: bundle.GetStringFromName("slowSqlStatement"),
 
@@ -921,16 +963,19 @@ function onLoad() {
   window.removeEventListener("load", onLoad);
 
   // Set the text in the page header
   setupPageHeader();
 
   // Set up event listeners
   setupListeners();
 
+  // Show general data.
+  GeneralData.render();
+
   // Show slow SQL stats
   SlowSQL.render();
 
   // Show chrome hang stacks
   ChromeHangs.render();
 
   // Show thread hang stats
   ThreadHangStats.render();
--- a/toolkit/content/aboutTelemetry.xhtml
+++ b/toolkit/content/aboutTelemetry.xhtml
@@ -30,16 +30,25 @@
       <h2 id="page-subtitle"></h2>
 
       <p id="description-enabled">&aboutTelemetry.telemetryEnabled;</p>
       <p id="description-disabled">&aboutTelemetry.telemetryDisabled;</p>
 
       <button id="toggle-telemetry" type="button"/>
     </header>
 
+    <section id="general-data-section" class="data-section">
+      <input type="checkbox" class="statebox"/>
+      <h1 class="section-name">&aboutTelemetry.generalDataSection;</h1>
+      <span class="toggle-caption">&aboutTelemetry.toggle;</span>
+      <span class="empty-caption">&aboutTelemetry.emptySection;</span>
+      <div id="general-data" class="data">
+      </div>
+    </section>
+
     <section id="slow-sql-section" class="data-section">
       <input type="checkbox" class="statebox"/>
       <h1 class="section-name">&aboutTelemetry.slowSqlSection;</h1>
       <span class="toggle-caption">&aboutTelemetry.toggle;</span>
       <span class="empty-caption">&aboutTelemetry.emptySection;</span>
       <div id="slow-sql-tables" class="data">
         <p id="sql-warning" class="hidden">&aboutTelemetry.fullSqlWarning;</p>
       </div>
--- a/toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
+++ b/toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
@@ -7,16 +7,20 @@
 <!ENTITY aboutTelemetry.telemetryEnabled "
   Telemetry is <span>enabled</span>.
 ">
 
 <!ENTITY aboutTelemetry.telemetryDisabled "
   Telemetry is <span>disabled</span>.
 ">
 
+<!ENTITY aboutTelemetry.generalDataSection "
+  General Data
+">
+
 <!ENTITY aboutTelemetry.slowSqlSection "
   Slow SQL Statements
 ">
 
 <!ENTITY aboutTelemetry.chromeHangsSection "
   Browser Hangs
 ">
 
--- a/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
+++ b/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
@@ -2,16 +2,20 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # Note to translators:
 # - %1$S will be replaced by brandFullName
 # - %2$S will be replaced with the value of the toolkit.telemetry.server_owner preference
 pageSubtitle = This page shows the information about performance, hardware, usage and customizations collected by Telemetry. This information is submitted to %1$S to help improve %2$S.
 
+generalDataHeadingName = Name
+
+generalDataHeadingValue = Value
+
 slowSqlMain = Slow SQL Statements on Main Thread
 
 slowSqlOther = Slow SQL Statements on Helper Threads
 
 slowSqlHits = Hits
 
 slowSqlAverage = Avg. Time (ms)