diff --git a/toolkit/components/telemetry/TelemetrySession.jsm b/toolkit/components/telemetry/TelemetrySession.jsm index 2e820392a600..baf103f4a677 100644 --- a/toolkit/components/telemetry/TelemetrySession.jsm +++ b/toolkit/components/telemetry/TelemetrySession.jsm @@ -224,9 +224,10 @@ function toLocalTimeISOString(date) { */ function annotateCrashReport(sessionId) { try { - const cr = Cc["@mozilla.org/toolkit/crash-reporter;1"] - .getService(Ci.nsICrashReporter); - cr.setTelemetrySessionId(sessionId); + const cr = Cc["@mozilla.org/toolkit/crash-reporter;1"]; + if (cr) { + cr.getService(Ci.nsICrashReporter).setTelemetrySessionId(sessionId); + } } catch (e) { // Ignore errors when crash reporting is disabled } diff --git a/toolkit/components/telemetry/TelemetryStartup.js b/toolkit/components/telemetry/TelemetryStartup.js index 38c00612368c..909ce0a87bb4 100644 --- a/toolkit/components/telemetry/TelemetryStartup.js +++ b/toolkit/components/telemetry/TelemetryStartup.js @@ -39,10 +39,11 @@ TelemetryStartup.prototype.observe = function(aSubject, aTopic, aData) { function annotateEnvironment() { try { - let cr = Cc["@mozilla.org/toolkit/crash-reporter;1"] - .getService(Ci.nsICrashReporter); - let env = JSON.stringify(TelemetryEnvironment.currentEnvironment); - cr.annotateCrashReport("TelemetryEnvironment", env); + let cr = Cc["@mozilla.org/toolkit/crash-reporter;1"]; + if (cr) { + let env = JSON.stringify(TelemetryEnvironment.currentEnvironment); + cr.getService(Ci.nsICrashReporter).annotateCrashReport("TelemetryEnvironment", env); + } } catch (e) { // crash reporting not built or disabled? Ignore errors }