2014-01-13 18:20:09 +04:00
|
|
|
/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2018-01-30 08:17:48 +03:00
|
|
|
ChromeUtils.defineModuleGetter(
|
|
|
|
this,
|
|
|
|
"TelemetryController",
|
|
|
|
"resource://gre/modules/TelemetryController.jsm"
|
|
|
|
);
|
|
|
|
ChromeUtils.defineModuleGetter(
|
|
|
|
this,
|
|
|
|
"TelemetryEnvironment",
|
|
|
|
"resource://gre/modules/TelemetryEnvironment.jsm"
|
|
|
|
);
|
2015-06-03 14:45:24 +03:00
|
|
|
|
2014-01-13 18:20:09 +04:00
|
|
|
/**
|
|
|
|
* TelemetryStartup is needed to forward the "profile-after-change" notification
|
2015-04-27 19:07:58 +03:00
|
|
|
* to TelemetryController.jsm.
|
2014-01-13 18:20:09 +04:00
|
|
|
*/
|
|
|
|
function TelemetryStartup() {}
|
|
|
|
|
2015-04-13 19:51:31 +03:00
|
|
|
TelemetryStartup.prototype.QueryInterface = ChromeUtils.generateQI([
|
Bug 1649221: Update ChromeUtils.generateQI callers to pass strings. r=mccr8,remote-protocol-reviewers,marionette-reviewers,perftest-reviewers,webcompat-reviewers,geckoview-reviewers,preferences-reviewers,agi,whimboo,Bebe,twisniewski
Differential Revision: https://phabricator.services.mozilla.com/D81594
2020-07-11 02:58:28 +03:00
|
|
|
"nsIObserver",
|
2015-04-13 19:51:31 +03:00
|
|
|
]);
|
2015-01-07 00:48:03 +03:00
|
|
|
TelemetryStartup.prototype.observe = function(aSubject, aTopic, aData) {
|
2017-04-12 01:13:30 +03:00
|
|
|
if (aTopic == "profile-after-change") {
|
|
|
|
// In the content process, this is done in ContentProcessSingleton.js.
|
2015-04-27 19:07:58 +03:00
|
|
|
TelemetryController.observe(null, aTopic, null);
|
2014-01-13 18:20:09 +04:00
|
|
|
}
|
2015-04-13 19:51:31 +03:00
|
|
|
if (aTopic == "profile-after-change") {
|
|
|
|
annotateEnvironment();
|
|
|
|
TelemetryEnvironment.registerChangeListener(
|
|
|
|
"CrashAnnotator",
|
|
|
|
annotateEnvironment
|
|
|
|
);
|
|
|
|
TelemetryEnvironment.onInitialized().then(() => annotateEnvironment());
|
|
|
|
}
|
2017-10-15 21:50:30 +03:00
|
|
|
};
|
2015-04-13 19:51:31 +03:00
|
|
|
|
|
|
|
function annotateEnvironment() {
|
|
|
|
try {
|
2016-03-23 13:24:41 +03:00
|
|
|
let cr = Cc["@mozilla.org/toolkit/crash-reporter;1"];
|
|
|
|
if (cr) {
|
|
|
|
let env = JSON.stringify(TelemetryEnvironment.currentEnvironment);
|
|
|
|
cr.getService(Ci.nsICrashReporter).annotateCrashReport(
|
|
|
|
"TelemetryEnvironment",
|
|
|
|
env
|
|
|
|
);
|
|
|
|
}
|
2015-04-13 19:51:31 +03:00
|
|
|
} catch (e) {
|
|
|
|
// crash reporting not built or disabled? Ignore errors
|
|
|
|
}
|
2014-01-13 18:20:09 +04:00
|
|
|
}
|
|
|
|
|
2019-01-30 08:29:25 +03:00
|
|
|
var EXPORTED_SYMBOLS = ["TelemetryStartup"];
|