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";
|
|
|
|
|
2015-04-13 19:51:31 +03:00
|
|
|
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
2014-01-13 18:20:09 +04:00
|
|
|
|
2015-01-07 00:48:03 +03:00
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
2014-01-13 18:20:09 +04:00
|
|
|
|
2015-06-03 14:45:24 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryController",
|
|
|
|
"resource://gre/modules/TelemetryController.jsm");
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryEnvironment",
|
|
|
|
"resource://gre/modules/TelemetryEnvironment.jsm");
|
|
|
|
|
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() {
|
|
|
|
}
|
|
|
|
|
|
|
|
TelemetryStartup.prototype.classID = Components.ID("{117b219f-92fe-4bd2-a21b-95a342a9d474}");
|
2015-04-13 19:51:31 +03:00
|
|
|
TelemetryStartup.prototype.QueryInterface = XPCOMUtils.generateQI([Components.interfaces.nsIObserver]);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TelemetryStartup]);
|