Bug 720785: report update channel in telemetry ping, r=gavin
authorMark Reid <mreid@mozilla.com>
Wed, 25 Jan 2012 12:12:26 -0800
changeset 86593 6afce25c341f8ab035b4ac489e81d0365970eaa2
parent 86592 17e6e596ba287b8fafeefcb5c01d8e7fd78f7e2c
child 86594 a9823c18b423e97718435433866af1597126776e
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs720785
milestone12.0a1
Bug 720785: report update channel in telemetry ping, r=gavin
toolkit/components/telemetry/TelemetryPing.js
--- a/toolkit/components/telemetry/TelemetryPing.js
+++ b/toolkit/components/telemetry/TelemetryPing.js
@@ -132,16 +132,52 @@ function getSimpleMeasurements() {
   for (let p in appTimestamps) {
     if (!(p in ret) && appTimestamps[p])
       ret[p] = appTimestamps[p];
   }
 
   return ret;
 }
 
+/**
+ * Read the update channel from defaults only.  We do this to ensure that
+ * the channel is tightly coupled with the application and does not apply
+ * to other installations of the application that may use the same profile.
+ */
+function getUpdateChannel() {
+  var channel = "default";
+  var prefName;
+  var prefValue;
+
+  var defaults = Services.prefs.getDefaultBranch(null);
+  try {
+    channel = defaults.getCharPref("app.update.channel");
+  } catch (e) {
+    // use default when pref not found
+  }
+
+  try {
+    var partners = Services.prefs.getChildList("app.partner.");
+    if (partners.length) {
+      channel += "-cck";
+      partners.sort();
+
+      for each (prefName in partners) {
+        prefValue = Services.prefs.getCharPref(prefName);
+        channel += "-" + prefValue;
+      }
+    }
+  }
+  catch (e) {
+    Cu.reportError(e);
+  }
+
+  return channel;
+}
+
 function TelemetryPing() {}
 
 TelemetryPing.prototype = {
   _histograms: {},
   _initialized: false,
   _prevValues: {},
   // Generate a unique id once per session so the server can cope with
   // duplicate submissions.
@@ -226,17 +262,18 @@ TelemetryPing.prototype = {
     let ai = Services.appinfo;
     let ret = {
       reason: reason,
       OS: ai.OS,
       appID: ai.ID,
       appVersion: ai.version,
       appName: ai.name,
       appBuildID: ai.appBuildID,
-      platformBuildID: ai.platformBuildID,
+      appUpdateChannel: getUpdateChannel(),
+      platformBuildID: ai.platformBuildID
     };
 
     // sysinfo fields are not always available, get what we can.
     let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
     let fields = ["cpucount", "memsize", "arch", "version", "device", "manufacturer", "hardware",
                   "hasMMX", "hasSSE", "hasSSE2", "hasSSE3",
                   "hasSSSE3", "hasSSE4A", "hasSSE4_1", "hasSSE4_2",
                   "hasEDSP", "hasARMv6", "hasNEON"];