Bug 1086252 - Show stable client id in about:telemetry. r=froydnj, a=lmandel
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Thu, 23 Oct 2014 15:42:04 +0200
changeset 225904 bda711062d08
parent 225903 efb3c956dfef
child 225905 a4db8f39f372
push id4063
push usergeorg.fritzsche@googlemail.com
push date2014-11-02 23:54 +0000
treeherdermozilla-beta@1ca39da5df9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, lmandel
bugs1086252
milestone34.0
Bug 1086252 - Show stable client id in about:telemetry. r=froydnj, a=lmandel
toolkit/components/telemetry/TelemetryPing.jsm
toolkit/content/aboutTelemetry.js
toolkit/content/aboutTelemetry.xhtml
--- 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", "Name");
+    this.appendColumn(headings, "th", "Value");
+    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">General Data</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>