Bug 832007 - Include HG revision URL in the Telemetry packet. r=nfroyd
authorVladan Djeric <vdjeric@mozilla.com>
Wed, 20 Feb 2013 13:46:47 -0500
changeset 122477 2c9557cd695fc11cbef65578ef3fbbca62280a22
parent 122476 1d96b58d9d4b4f00dcca72180668ef4a7b0422ce
child 122478 8fd540d7aa8551f665617e9d1dc355272b555b88
push id24342
push userryanvm@gmail.com
push dateThu, 21 Feb 2013 13:05:06 +0000
treeherdermozilla-central@702d2814efbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs832007
milestone22.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 832007 - Include HG revision URL in the Telemetry packet. r=nfroyd
toolkit/components/telemetry/Makefile.in
toolkit/components/telemetry/TelemetryPing.js
toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
--- a/toolkit/components/telemetry/Makefile.in
+++ b/toolkit/components/telemetry/Makefile.in
@@ -58,16 +58,21 @@ EXTRA_DSO_LDOPTS += \
   $(NULL)
 
 TEST_DIRS += tests
 
 ifdef MOZILLA_OFFICIAL
 DEFINES += -DMOZILLA_OFFICIAL
 endif
 
+MOZ_HISTOGRAMS_VERSION ?= $(shell hg path default)rev/$(shell hg -R $(topsrcdir) parent --template="{node|short}\n" 2>/dev/null)
+ifdef MOZ_HISTOGRAMS_VERSION
+DEFINES += -DHISTOGRAMS_FILE_VERSION="$(MOZ_HISTOGRAMS_VERSION)"
+endif
+
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/config/rules.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 
 histograms_file := $(srcdir)/Histograms.json
 histogram_enum_file := TelemetryHistogramEnums.h
 histogram_data_file := TelemetryHistogramData.inc
 
--- a/toolkit/components/telemetry/TelemetryPing.js
+++ b/toolkit/components/telemetry/TelemetryPing.js
@@ -14,16 +14,20 @@ Cu.import("resource://gre/modules/NetUti
 #ifndef MOZ_WIDGET_GONK
 Cu.import("resource://gre/modules/LightweightThemeManager.jsm");
 #endif
 Cu.import("resource://gre/modules/ctypes.jsm");
 
 // When modifying the payload in incompatible ways, please bump this version number
 const PAYLOAD_VERSION = 1;
 
+// This is the HG changeset of the Histogram.json file, used to associate
+// submitted ping data with its histogram definition (bug 832007)
+#expand const HISTOGRAMS_FILE_VERSION = "__HISTOGRAMS_FILE_VERSION__";
+
 const PREF_SERVER = "toolkit.telemetry.server";
 #ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
 const PREF_ENABLED = "toolkit.telemetry.enabledPreRelease";
 #else
 const PREF_ENABLED = "toolkit.telemetry.enabled";
 #endif
 // Do not gather data more than once a minute
 const TELEMETRY_INTERVAL = 60000;
@@ -354,16 +358,17 @@ TelemetryPing.prototype = {
       reason: reason,
       OS: ai.OS,
       appID: ai.ID,
       appVersion: ai.version,
       appName: ai.name,
       appBuildID: ai.appBuildID,
       appUpdateChannel: UpdateChannel.get(),
       platformBuildID: ai.platformBuildID,
+      revision: HISTOGRAMS_FILE_VERSION,
       locale: getLocale()
     };
 
     // 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", "kernel_version",
                   "device", "manufacturer", "hardware",
                   "hasMMX", "hasSSE", "hasSSE2", "hasSSE3",
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
@@ -151,16 +151,18 @@ function checkPayloadInfo(payload, reaso
 
   for (let f in expected_info) {
     do_check_eq(payload.info[f], expected_info[f]);
   }
 
   do_check_eq(payload.info.reason, reason);
   do_check_true("appUpdateChannel" in payload.info);
   do_check_true("locale" in payload.info);
+  do_check_true("revision" in payload.info);
+  do_check_true(payload.info.revision.startsWith("http"));
 
   try {
     // If we've not got nsIGfxInfoDebug, then this will throw and stop us doing
     // this test.
     var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfoDebug);
     var isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
     var isOSX = ("nsILocalFileMac" in Components.interfaces);