Bug 1341282 - Write the telemetry session id to the .extra file during a crash; r?Ted draft
authorGabriele Svelto <gsvelto@mozilla.com>
Tue, 21 Feb 2017 15:23:58 +0100
changeset 487867 d4682b4265a07b9666fbb3cea1f26e5d0c4e19e9
parent 487616 92e4960c4fb1b62dcbc04995d01edaba10ba5ab2
child 546595 6d1d93c6213a4b0dee78a58b752830ef56328a73
push id46379
push usergsvelto@mozilla.com
push dateWed, 22 Feb 2017 09:42:58 +0000
reviewersTed
bugs1341282
milestone54.0a1
Bug 1341282 - Write the telemetry session id to the .extra file during a crash; r?Ted MozReview-Commit-ID: 3xltHwV7L5x
toolkit/crashreporter/nsExceptionHandler.cpp
toolkit/crashreporter/test/unit/test_crashreporter_crash.js
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -1108,17 +1108,17 @@ bool MinidumpCallback(
       OpenAPIData(apiData, descriptor.path());
 #else
       OpenAPIData(apiData, dump_path, minidump_id);
 #endif
       apiData.WriteBuffer(crashReporterAPIData->get(), crashReporterAPIData->Length());
     }
 
     if (currentSessionId) {
-      WriteAnnotation(apiData, "TelemetrySessionId", crashTimeString);
+      WriteAnnotation(apiData, "TelemetrySessionId", currentSessionId);
       WriteAnnotation(eventFile, "TelemetrySessionId", currentSessionId);
     }
 
     WriteAnnotation(apiData, "CrashTime", crashTimeString);
     WriteAnnotation(eventFile, "CrashTime", crashTimeString);
 
     WriteAnnotation(apiData, "UptimeTS", uptimeTSString);
     WriteAnnotation(eventFile, "UptimeTS", uptimeTSString);
--- a/toolkit/crashreporter/test/unit/test_crashreporter_crash.js
+++ b/toolkit/crashreporter/test/unit/test_crashreporter_crash.js
@@ -40,11 +40,15 @@ function run_test() {
              let scope = {};
              Components.utils.import("resource://gre/modules/TelemetryController.jsm", scope);
              scope.TelemetryController.testSetup();
            },
            function(mdump, extra) {
              do_check_eq(extra.TestKey, "TestValue");
              do_check_eq(extra["\u2665"], "\u{1F4A9}");
              do_check_eq(extra.Notes, "JunkMoreJunk");
-             do_check_true("TelemetrySessionId" in extra);
+             const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
+             Assert.ok("TelemetrySessionId" in extra,
+                       "The TelemetrySessionId field is present in the extra file");
+             Assert.ok(UUID_REGEX.test(extra.TelemetrySessionId),
+                       "The TelemetrySessionId is a UUID");
            });
 }