Bug 1539257 - Show Origin Telemetry in about:telemetry l10n-r?flod r=janerik,flod
authorChris H-C <chutten@mozilla.com>
Tue, 09 Apr 2019 16:53:09 +0000
changeset 468596 382518bd8029480395692ca5c724c2b10cf205a1
parent 468595 09338587b68ec81fce358678fd79c558bc8f5ea8
child 468597 9c62f06c8c6a719bf0cb82c6a49ac5e2a1029904
push id35843
push usernbeleuzu@mozilla.com
push dateTue, 09 Apr 2019 22:08:13 +0000
treeherdermozilla-central@a31032a16330 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanerik, flod
bugs1539257
milestone68.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 1539257 - Show Origin Telemetry in about:telemetry l10n-r?flod r=janerik,flod Differential Revision: https://phabricator.services.mozilla.com/D26715
toolkit/content/aboutTelemetry.js
toolkit/content/aboutTelemetry.xhtml
toolkit/locales/en-US/toolkit/about/aboutTelemetry.ftl
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -389,16 +389,20 @@ var PingPicker = {
     // augment ping payload with event telemetry
     let eventSnapshot = Telemetry.snapshotEvents(Telemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
     for (let process of Object.keys(eventSnapshot)) {
       if (process in ping.payload.processes) {
         ping.payload.processes[process].events = eventSnapshot[process].filter(e => !e[1].startsWith("telemetry.test"));
       }
     }
 
+    // augment "current ping payload" with origin telemetry
+    const originSnapshot = Telemetry.getOriginSnapshot(false /* clear */);
+    ping.payload.origins = originSnapshot;
+
     displayPingData(ping, true);
   },
 
   _updateArchivedPingData() {
     let id = this._getSelectedPingId();
     let res = Promise.resolve();
     if (id) {
       res = TelemetryArchive.promiseArchivedPingById(id)
@@ -1827,38 +1831,71 @@ var Events = {
         "about-telemetry-extra-header",
       ];
       const table = GenericTable.render(events, headings);
       eventsSection.appendChild(table);
     }
   },
 };
 
+var Origins = {
+  render(aOrigins) {
+    let originSection = document.getElementById("origins");
+    removeAllChildNodes(originSection);
+
+    const headings = [
+      "about-telemetry-origin-origin",
+      "about-telemetry-origin-count",
+    ];
+
+    let hasData = false;
+    for (let [metric, origins] of Object.entries(aOrigins || {})) {
+      if (!Object.entries(origins).length) {
+        continue;
+      }
+      hasData = true;
+      const metricHeader = document.createElement("caption");
+      metricHeader.appendChild(document.createTextNode(metric));
+
+      const table = GenericTable.render(Object.entries(origins), headings);
+      table.appendChild(metricHeader);
+      originSection.appendChild(table);
+    }
+
+    setHasData("origin-telemetry-section", hasData);
+  },
+};
+
 /**
  * Helper function for showing either the toggle element or "No data collected" message for a section
  *
  * @param aSectionID ID of the section element that needs to be changed
  * @param aHasData true (default) indicates that toggle should be displayed
  */
 function setHasData(aSectionID, aHasData) {
   let sectionElement = document.getElementById(aSectionID);
   sectionElement.classList[aHasData ? "add" : "remove"]("has-data");
 
   // Display or Hide the section in the sidebar
   let sectionCategory = document.querySelector(".category[value=" + aSectionID + "]");
   sectionCategory.classList[aHasData ? "add" : "remove"]("has-data");
 }
 
 /**
- * Sets the text of the page header based on a config pref + bundle strings
+ * Sets l10n attributes based on the Telemetry Server Owner pref.
  */
-function setupPageHeader() {
+function setupServerOwnerBranding() {
   let serverOwner = Preferences.get(PREF_TELEMETRY_SERVER_OWNER, "Mozilla");
-  let subtitleElement = document.getElementById("page-subtitle");
-  document.l10n.setAttributes(subtitleElement, "about-telemetry-page-subtitle", {telemetryServerOwner: serverOwner});
+  const elements = [
+    [document.getElementById("page-subtitle"), "about-telemetry-page-subtitle"],
+    [document.getElementById("origins-explanation"), "about-telemetry-origins-explanation"],
+  ];
+  for (const [elt, l10nName] of elements) {
+    document.l10n.setAttributes(elt, l10nName, {telemetryServerOwner: serverOwner});
+  }
 }
 
 function displayProcessesSelector(selectedSection) {
   let whitelist = [
     "scalars-section",
     "keyed-scalars-section",
     "histograms-section",
     "keyed-histograms-section",
@@ -2127,18 +2164,18 @@ function openJsonInFirefoxJsonViewer(jso
     show(document.querySelector(".category[value=raw-payload-section]"));
   }
 }
 
 function onLoad() {
   window.removeEventListener("load", onLoad);
   Telemetry.scalarAdd("telemetry.about_telemetry_pageload", 1);
 
-  // Set the text in the page header
-  setupPageHeader();
+  // Set the text in the page header and elsewhere that needs the server owner.
+  setupServerOwnerBranding();
 
   // Set up event listeners
   setupListeners();
 
   // Render settings.
   Settings.render();
 
   adjustHeaderState();
@@ -2512,13 +2549,16 @@ function displayRichPingData(ping, updat
   // Show event data.
   Events.render(payload);
 
   // Show captured stacks.
   CapturedStacks.render(payload);
 
   LateWritesSingleton.renderLateWrites(payload.lateWrites);
 
+  // Show origin telemetry.
+  Origins.render(payload.origins);
+
   // Show simple measurements
   SimpleMeasurements.render(payload);
 }
 
 window.addEventListener("load", onLoad);
--- a/toolkit/content/aboutTelemetry.xhtml
+++ b/toolkit/content/aboutTelemetry.xhtml
@@ -66,16 +66,19 @@
         <span class="category-name" data-l10n-id="about-telemetry-addon-details-section"></span>
       </div>
       <div class="category" value="captured-stacks-section">
         <span class="category-name" data-l10n-id="about-telemetry-captured-stacks-section"></span>
       </div>
       <div class="category" value="late-writes-section">
         <span class="category-name" data-l10n-id="about-telemetry-late-writes-section"></span>
       </div>
+      <div class="category" value="origin-telemetry-section">
+        <span class="category-name" data-l10n-id="about-telemetry-origin-section"></span>
+      </div>
       <div class="category has-data" value="raw-payload-section">
         <span class="category-name" data-l10n-id="about-telemetry-raw-payload-section"></span>
       </div>
       <div id="category-raw" class="category has-data" value="raw-json-viewer">
           <span class="category-name" data-l10n-id="about-telemetry-raw"></span>
       </div>
     </div>
 
@@ -189,16 +192,24 @@
       </section>
 
       <section id="late-writes-section">
         <a id="late-writes-fetch-symbols" href="" data-l10n-id="about-telemetry-fetch-stack-symbols"></a>
         <a id="late-writes-hide-symbols" href="" data-l10n-id="about-telemetry-hide-stack-symbols"></a>
         <div id="late-writes" class="data"></div>
       </section>
 
+      <section id="origin-telemetry-section">
+        <div id="origins-explanation">
+          <a data-l10n-name="origin-doc-link" href="https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/origin.html"></a>
+          <a data-l10n-name="prio-blog-link" href="https://hacks.mozilla.org/2018/10/testing-privacy-preserving-telemetry-with-prio/"></a>
+        </div>
+        <div id="origins" class="data"></div>
+      </section>
+
       <section id="addon-details-section">
         <div id="addon-details" class="data"></div>
       </section>
 
       <section id="captured-stacks-section">
         <a id="captured-stacks-fetch-symbols" href="" data-l10n-id="about-telemetry-fetch-stack-symbols"></a>
         <a id="captured-stacks-hide-symbols" href="" data-l10n-id="about-telemetry-hide-stack-symbols"></a>
         <div id="captured-stacks" class="data"></div>
--- a/toolkit/locales/en-US/toolkit/about/aboutTelemetry.ftl
+++ b/toolkit/locales/en-US/toolkit/about/aboutTelemetry.ftl
@@ -62,17 +62,17 @@ about-telemetry-upload-type =
 #   $prettyAverage (Integer): average of histogram samples
 #   $sum (Integer): sum of histogram samples
 about-telemetry-histogram-stats = 
     { $sampleCount ->
         [one] { $sampleCount } sample, average = { $prettyAverage }, sum = { $sum }
        *[other] { $sampleCount } samples, average = { $prettyAverage }, sum = { $sum }
     }
 # Variables:
-#   $telemetryServerOwner (String): the value of the toolkit.telemetry.server_owner preference
+#   $telemetryServerOwner (String): the value of the toolkit.telemetry.server_owner preference. Typically "Mozilla"
 about-telemetry-page-subtitle = This page shows the information about performance, hardware, usage and customizations collected by Telemetry. This information is submitted to { $telemetryServerOwner } to help improve { -brand-full-name }.
 about-telemetry-settings-explanation = Telemetry is collecting { about-telemetry-data-type } and upload is <a data-l10n-name="upload-link">{ about-telemetry-upload-type }</a>.
 # Variables:
 #   $name (String): ping name, e.g. “saved-session”
 #   $timeStamp (String): ping localized timestamp, e.g. “2017/07/08 10:40:46”
 about-telemetry-ping-details = Each piece of information is sent bundled into “<a data-l10n-name="ping-link">pings</a>”. You are looking at the { $name }, { $timestamp } ping.
 about-telemetry-ping-details-current = Each piece of information is sent bundled into “<a data-l10n-name="ping-link">pings</a>“. You are looking at the current ping.
 # string used as a placeholder for the search field
@@ -130,8 +130,14 @@ about-telemetry-late-writes-title = Late
 about-telemetry-stack-title = Stack:
 about-telemetry-memory-map-title = Memory map:
 about-telemetry-error-fetching-symbols = An error occurred while fetching symbols. Check that you are connected to the Internet and try again.
 about-telemetry-time-stamp-header = timestamp
 about-telemetry-category-header = category
 about-telemetry-method-header = method
 about-telemetry-object-header = object
 about-telemetry-extra-header = extra
+about-telemetry-origin-section = Origin Telemetry
+about-telemetry-origin-origin = origin
+about-telemetry-origin-count = count
+# Variables:
+#   $telemetryServerOwner (String): the value of the toolkit.telemetry.server_owner preference. Typically "Mozilla"
+about-telemetry-origins-explanation = <a data-l10n-name="origin-doc-link">Firefox Origin Telemetry</a> encodes data before it is sent so that { $telemetryServerOwner } can count things, but not know whether or not any given { -brand-product-name } contributed to that count. (<a data-l10n-name="prio-blog-link">learn more</a>)