mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Backed out 3 changesets (bug 1529232) for xpcshell failures on test_TelemetryController.js CLOSED TREE
Backed out changeset f2935b75f9dc (bug 1529232) Backed out changeset 8ca8be52ca57 (bug 1529232) Backed out changeset ed20a4120896 (bug 1529232)
This commit is contained in:
parent
ab09637b22
commit
8869433083
@ -1541,12 +1541,6 @@ pref("toolkit.telemetry.updatePing.enabled", true);
|
||||
pref("toolkit.telemetry.bhrPing.enabled", true);
|
||||
// Enables using Hybrid Content Telemetry from Mozilla privileged pages.
|
||||
pref("toolkit.telemetry.hybridContent.enabled", true);
|
||||
// Whether to enable Ecosystem Telemetry, requires a restart.
|
||||
#ifdef NIGHTLY_BUILD
|
||||
pref("toolkit.telemetry.ecosystemtelemetry.enabled", true);
|
||||
#else
|
||||
pref("toolkit.telemetry.ecosystemtelemetry.enabled", false);
|
||||
#endif
|
||||
|
||||
// Ping Centre Telemetry settings.
|
||||
pref("browser.ping-centre.telemetry", true);
|
||||
|
@ -98,7 +98,6 @@ browser.engagement:
|
||||
total_uri_count:
|
||||
bug_numbers:
|
||||
- 1271313
|
||||
- 1529232
|
||||
description: >
|
||||
The count of the total non-unique http(s) URIs visited in a subsession, including
|
||||
page reloads, after the session has been restored. This does not include background
|
||||
@ -107,13 +106,9 @@ browser.engagement:
|
||||
kind: uint
|
||||
notification_emails:
|
||||
- rweiss@mozilla.com
|
||||
- loines@mozilla.com
|
||||
release_channel_collection: opt-out
|
||||
record_in_processes:
|
||||
- 'main'
|
||||
record_into_store:
|
||||
- 'main'
|
||||
- 'pre-account'
|
||||
|
||||
unfiltered_uri_count:
|
||||
bug_numbers:
|
||||
|
@ -64,7 +64,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
UpdatePing: "resource://gre/modules/UpdatePing.jsm",
|
||||
TelemetryHealthPing: "resource://gre/modules/HealthPing.jsm",
|
||||
TelemetryEventPing: "resource://gre/modules/EventPing.jsm",
|
||||
EcosystemTelemetry: "resource://gre/modules/EcosystemTelemetry.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
});
|
||||
|
||||
@ -727,7 +726,6 @@ var Impl = {
|
||||
}
|
||||
|
||||
TelemetryEventPing.startup();
|
||||
EcosystemTelemetry.startup();
|
||||
|
||||
this._delayedInitTaskDeferred.resolve();
|
||||
} catch (e) {
|
||||
@ -788,7 +786,6 @@ var Impl = {
|
||||
UpdatePing.shutdown();
|
||||
|
||||
TelemetryEventPing.shutdown();
|
||||
EcosystemTelemetry.shutdown();
|
||||
|
||||
// Stop the datachoices infobar display.
|
||||
TelemetryReportingPolicy.shutdown();
|
||||
|
@ -57,9 +57,6 @@ var TelemetryUtils = {
|
||||
EventPingMinimumFrequency: "toolkit.telemetry.eventping.minimumFrequency",
|
||||
EventPingMaximumFrequency: "toolkit.telemetry.eventping.maximumFrequency",
|
||||
|
||||
// Ecosystem Telemetry Preferences
|
||||
EcosystemTelemetryEnabled: "toolkit.telemetry.ecosystemtelemetry.enabled",
|
||||
|
||||
// Log Preferences
|
||||
LogLevel: "toolkit.telemetry.log.level",
|
||||
LogDump: "toolkit.telemetry.log.dump",
|
||||
|
@ -1,119 +0,0 @@
|
||||
Ecosystem Telemetry
|
||||
===================
|
||||
|
||||
This module transmits Ecosystem Telemetry from Firefox Desktop.
|
||||
It consists of two ping types: "pre-account" and "post-account".
|
||||
|
||||
.. note::
|
||||
|
||||
The "pre-account" ping is not yet fully implemented and lacks some data to be included. Don't rely on any submitted data yet!
|
||||
The "post-account" ping is not yet implemented.
|
||||
See `bug 1522664 <https://bugzilla.mozilla.org/show_bug.cgi?id=1522664>`_ for pending work.
|
||||
|
||||
The client id is **not** submitted with either ping.
|
||||
A reduced Telemetry environment is submitted in these pings.
|
||||
|
||||
Environment
|
||||
-----------
|
||||
|
||||
This is a subset of the :doc:`environment`, due to privacy concerns.
|
||||
Similar dimensions will be available on other products.
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
settings: {
|
||||
locale: <string>, // e.g. "it", null on failure
|
||||
},
|
||||
system: {
|
||||
memoryMB: <number>,
|
||||
os: {
|
||||
name: <string>, // e.g. "Windows_NT", null on failure
|
||||
version: <string>, // e.g. "6.1", null on failure
|
||||
kernelVersion: <string>, // android only or null on failure
|
||||
servicePackMajor: <number>, // windows only or null on failure
|
||||
servicePackMinor: <number>, // windows only or null on failure
|
||||
windowsBuildNumber: <number>, // windows only or null on failure
|
||||
windowsUBR: <number>, // windows 10 only or null on failure
|
||||
installYear: <number>, // windows only or null on failure
|
||||
locale: <string>, // "en" or null on failure
|
||||
},
|
||||
cpu: {
|
||||
speedMHz: <number>, // cpu clock speed in MHz
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
creationDate: <integer>, // integer days since UNIX epoch, e.g. 16446
|
||||
firstUseDate: <integer>, // integer days since UNIX epoch, e.g. 16446 - optional
|
||||
}
|
||||
}
|
||||
|
||||
Pre-account ping
|
||||
----------------
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
"type": "pre-account",
|
||||
... common ping data
|
||||
"environment": { ... }, // as above
|
||||
"payload": {
|
||||
"reason": <string>, // Why the ping was submitted
|
||||
"ecosystemClientId": <string>, // Specific ecosystem client ID, not associated with regular client ID
|
||||
"uid": <string>, // Hashed account ID, for pings with reason "login" only
|
||||
"duration": <number>, // duration since ping was last sent or since the beginning of the Firefox session in seconds
|
||||
"histograms": {...},
|
||||
"keyedHistograms": {...},
|
||||
"scalars": {...},
|
||||
"keyedScalars": {...},
|
||||
}
|
||||
}
|
||||
|
||||
.. note::
|
||||
|
||||
This ping does not yet submit a valid ``uid`` or ``ecosystemClientId``.
|
||||
See `bug 1530655 <https://bugzilla.mozilla.org/show_bug.cgi?id=1530655>`_.
|
||||
|
||||
reason
|
||||
~~~~~~
|
||||
The ``reason`` field contains the information about why the "pre-account" ping was submitted:
|
||||
|
||||
* ``periodic`` - Sent roughly every 24 hours during idle periods
|
||||
* ``shutdown`` - Sent on shutdown
|
||||
* ``login`` - Sent when a user logs in
|
||||
* ``logout`` - Sent when the user logs out
|
||||
|
||||
histograms and keyedHistograms
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
This section contains the :doc:`../collection/histograms` that are valid for the pre-account ping, per process.
|
||||
The recorded histograms are described in `Histograms.json <https://searchfox.org/mozilla-central/source/toolkit/components/telemetry/Histograms.json>`_, marked with the `pre-account` store.
|
||||
|
||||
scalars and keyedScalars
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
This section contains the :doc:`../collection/scalars` that are valid for the pre-account ping, per process.
|
||||
Scalars are only submitted if data was added to them.
|
||||
The recorded scalars are described in `Scalars.yaml <https://searchfox.org/mozilla-central/source/toolkit/components/telemetry/Scalars.yml>`_, marked with the `pre-account` store.
|
||||
|
||||
Send behavior
|
||||
-------------
|
||||
|
||||
Without an account
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A *pre-account* ping is submitted.
|
||||
This ping is submitted roughly every 24 hours during idle periods with reason *periodic*.
|
||||
On shutdown this ping is submitted with reason *shutdown*.
|
||||
|
||||
When a user logs into Firefox Accounts, this ping is submitted with reason *login*.
|
||||
If the user logs out and disconnects the account, this ping is submitted with reason *logout*.
|
||||
|
||||
With an account
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
.. note::
|
||||
|
||||
Not yet implemented. See `Bug 1530654 <https://bugzilla.mozilla.org/show_bug.cgi?id=1530654>`_.
|
||||
|
||||
A *post-account* ping is submitted.
|
||||
This ping is submitted roughly every 24 hours during idle periods with reason *periodic*.
|
||||
On shutdown this ping is submitted with reason *shutdown*.
|
@ -17,6 +17,5 @@ Data documentation
|
||||
anonymous-ping
|
||||
first-shutdown-ping
|
||||
*-ping
|
||||
ecosystem-telemetry
|
||||
|
||||
The `mozilla-pipeline-schemas repository <https://github.com/mozilla-services/mozilla-pipeline-schemas/>`_ contains schemas for some of the pings.
|
||||
|
@ -163,11 +163,6 @@ Preferences
|
||||
The maximum frequency at which an :doc:`../data/event-ping` will be sent.
|
||||
Default is 10 (minutes).
|
||||
|
||||
``toolkit.telemetry.ecosystemtelemetry.enabled``
|
||||
|
||||
Whether :doc:`../data/ecosystem-telemetry` is enabled.
|
||||
Default is false. Change requires restart.
|
||||
|
||||
``toolkit.telemetry.overrideUpdateChannel``
|
||||
|
||||
Override the ``channel`` value that is reported via Telemetry.
|
||||
|
@ -112,7 +112,6 @@ EXTRA_JS_MODULES += [
|
||||
'other/GCTelemetry.jsm',
|
||||
'other/UITelemetry.jsm',
|
||||
'pings/CoveragePing.jsm',
|
||||
'pings/EcosystemTelemetry.jsm',
|
||||
'pings/EventPing.jsm',
|
||||
'pings/HealthPing.jsm',
|
||||
'pings/ModulesPing.jsm',
|
||||
|
@ -1,324 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
/*
|
||||
* This module sends the Telemetry Ecosystem pings periodically:
|
||||
* https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/data/ecosystem-ping.html
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = [
|
||||
"EcosystemTelemetry",
|
||||
];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Weave: "resource://services-sync/main.js",
|
||||
ONLOGIN_NOTIFICATION: "resource://gre/modules/FxAccountsCommon.js",
|
||||
ONLOGOUT_NOTIFICATION: "resource://gre/modules/FxAccountsCommon.js",
|
||||
TelemetryController: "resource://gre/modules/TelemetryController.jsm",
|
||||
TelemetryUtils: "resource://gre/modules/TelemetryUtils.jsm",
|
||||
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.jsm",
|
||||
Log: "resource://gre/modules/Log.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetters(this, {
|
||||
Telemetry: ["@mozilla.org/base/telemetry;1", "nsITelemetry"],
|
||||
});
|
||||
|
||||
const LOGGER_NAME = "Toolkit.Telemetry";
|
||||
const LOGGER_PREFIX = "EcosystemTelemetry::";
|
||||
|
||||
var Policy = {
|
||||
sendPing: (type, payload, options) => TelemetryController.submitExternalPing(type, payload, options),
|
||||
monotonicNow: () => TelemetryUtils.monotonicNow(),
|
||||
fxaUid: () => {
|
||||
try {
|
||||
return Weave.Service.identity.hashedUID();
|
||||
} catch (ex) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
isClientConfigured: () => Weave.Status.checkSetup() !== Weave.CLIENT_NOT_CONFIGURED,
|
||||
};
|
||||
|
||||
var EcosystemTelemetry = {
|
||||
Reason: Object.freeze({
|
||||
PERIODIC: "periodic", // Send the ping in regular intervals
|
||||
SHUTDOWN: "shutdown", // Send the ping on shutdown
|
||||
LOGIN: "login", // Send after FxA login
|
||||
LOGOUT: "logout", // Send after FxA logout
|
||||
}),
|
||||
PingType: Object.freeze({
|
||||
PRE: "pre-account",
|
||||
// TODO(bug 1530654): Implement post-account ping
|
||||
POST: "post-account",
|
||||
}),
|
||||
METRICS_STORE: "pre-account",
|
||||
_logger: null,
|
||||
_lastSendTime: 0,
|
||||
// The current ping type to send, one of PingType
|
||||
_pingType: null,
|
||||
// Indicates if we saw a login event and the UID is pending
|
||||
_uidPending: false,
|
||||
// Indicates that the Ecosystem ping is configured and ready to send pings
|
||||
_initialized: false,
|
||||
|
||||
enabled() {
|
||||
// Never enabled when not Unified Telemetry (e.g. not enabled on Fennec)
|
||||
if (!Services.prefs.getBoolPref(TelemetryUtils.Preferences.Unified, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Services.prefs.getBoolPref(TelemetryUtils.Preferences.EcosystemTelemetryEnabled, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* On startup, register all observers.
|
||||
*/
|
||||
startup() {
|
||||
if (!this.enabled()) {
|
||||
return;
|
||||
}
|
||||
this._log.trace("Starting up.");
|
||||
this._addObservers();
|
||||
|
||||
// Always start with a pre-account ping.
|
||||
// We switch to post-account if we detect a sync/login
|
||||
// On short sessions, when we don't see a login/sync, we always send a pre-account ping.
|
||||
this._pingType = this.PingType.PRE;
|
||||
this._initialized = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Shutdown this ping.
|
||||
*
|
||||
* This will send a final ping with the SHUTDOWN reason.
|
||||
*/
|
||||
shutdown() {
|
||||
if (!this.enabled()) {
|
||||
return;
|
||||
}
|
||||
this._log.trace("Shutting down.");
|
||||
this._submitPing(this._pingType, this.Reason.SHUTDOWN);
|
||||
|
||||
this._removeObservers();
|
||||
},
|
||||
|
||||
EVENT_TOPICS: [
|
||||
ONLOGIN_NOTIFICATION, // FxA login
|
||||
ONLOGOUT_NOTIFICATION, // FxA logout
|
||||
"weave:service:ready", // FxA/Sync - initialized and knows if client configured
|
||||
"weave:service:login:change", // FxA/Sync - done, uid might be available
|
||||
"idle-daily", // Get informed roughly every 24h when idle (TODO(bug 1535336): reliable scheduling)
|
||||
],
|
||||
|
||||
_addObservers() {
|
||||
for (let topic of this.EVENT_TOPICS) {
|
||||
Services.obs.addObserver(this, topic);
|
||||
}
|
||||
},
|
||||
|
||||
_removeObservers() {
|
||||
for (let topic of this.EVENT_TOPICS) {
|
||||
try {
|
||||
// removeObserver may throw, which could interrupt shutdown.
|
||||
Services.obs.removeObserver(this, topic);
|
||||
} catch (ex) {}
|
||||
}
|
||||
},
|
||||
|
||||
observe(subject, topic, data) {
|
||||
this._log.trace(`observe, topic: ${topic}`);
|
||||
|
||||
switch (topic) {
|
||||
case ONLOGIN_NOTIFICATION:
|
||||
// On new login, we will switch pings once UID is available
|
||||
this._uidPending = true;
|
||||
break;
|
||||
|
||||
case ONLOGOUT_NOTIFICATION:
|
||||
// On logout we switch to pre-account again
|
||||
this._uidPending = false;
|
||||
this._pingType = this.PingType.PRE;
|
||||
this._submitPing(this._pingType, this.Reason.LOGOUT);
|
||||
break;
|
||||
|
||||
case "weave:service:login:change":
|
||||
let uid = Policy.fxaUid();
|
||||
if (this._uidPending && uid) {
|
||||
// When we saw a login before and have a UID we switch to post-account
|
||||
this._submitPing(this._pingType, this.Reason.LOGIN);
|
||||
this._pingType = this.PingType.POST;
|
||||
this._uidPending = false;
|
||||
} else if (!this._uidPending && uid) {
|
||||
// We didn't see a login before, but have a UID.
|
||||
// This can only be true after a process restart and when the first sync happened
|
||||
// Next interval will be a post-account ping.
|
||||
this._pingType = this.PingType.POST;
|
||||
} else if (!uid) {
|
||||
// No uid means we keep sending in pre-account pings
|
||||
this._pingType = this.PingType.PRE;
|
||||
}
|
||||
break;
|
||||
|
||||
case "weave:service:ready":
|
||||
// If client is configured, we send post-account pings
|
||||
if (Policy.isClientConfigured()) {
|
||||
this._pingType = this.PingType.POST;
|
||||
} else {
|
||||
// Otherwise we keep sending pre-account pings
|
||||
this._pingType = this.PingType.PRE;
|
||||
}
|
||||
break;
|
||||
|
||||
case "idle-daily":
|
||||
this.periodicPing();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
periodicPing() {
|
||||
this._submitPing(this._pingType, this.Reason.PERIODIC);
|
||||
},
|
||||
|
||||
/**
|
||||
* Submit an ecosystem ping.
|
||||
*
|
||||
* It will not send a ping if Ecosystem Telemetry is disabled
|
||||
* the module is not fully initialized or if the ping type is missing.
|
||||
*
|
||||
* It will automatically assemble the right payload and clear out Telemetry stores.
|
||||
*
|
||||
* @param {String} pingType The ping type to send. One of TelemetryEcosystemPing.PingType.
|
||||
* @param {String} reason The reason we're sending the ping. One of TelemetryEcosystemPing.Reason.
|
||||
*/
|
||||
_submitPing(pingType, reason) {
|
||||
if (!this.enabled()) {
|
||||
this._log.trace(`_submitPing was called, but ping is not enabled. Bug?`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._initialized || !pingType) {
|
||||
this._log.trace(`Not initialized or ping type undefined when sending. Bug?`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pingType == this.PingType.POST) {
|
||||
// TODO(bug 1530654): Implement post-account ping
|
||||
this._log.trace(`Post-account ping not implemented yet. Sending pre-account instead.`);
|
||||
pingType = this.PingType.PRE;
|
||||
}
|
||||
|
||||
this._log.trace(`_submitPing, ping type: ${pingType}, reason: ${reason}`);
|
||||
|
||||
let now = Policy.monotonicNow();
|
||||
// Duration in seconds
|
||||
let duration = Math.round((now - this._lastSendTime) / 1000);
|
||||
this._lastSendTime = now;
|
||||
|
||||
let payload = this._payload(reason, duration);
|
||||
|
||||
// Never include the client ID.
|
||||
// We provide our own environment.
|
||||
const options = {
|
||||
addClientId: false,
|
||||
addEnvironment: true,
|
||||
overrideEnvironment: this._environment(),
|
||||
usePingSender: reason === this.Reason.SHUTDOWN,
|
||||
};
|
||||
|
||||
Policy.sendPing(pingType, payload, options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Assemble payload for a new ping
|
||||
*
|
||||
* @param {String} reason The reason we're sending the ping. One of TelemetryEcosystemPing.Reason.
|
||||
* @param {Number} duration The duration since ping was last send in seconds.
|
||||
*/
|
||||
_payload(reason, duration) {
|
||||
let payload = {
|
||||
reason,
|
||||
ecosystemClientId: this._ecosystemClientId(),
|
||||
duration,
|
||||
|
||||
scalars: Telemetry.getSnapshotForScalars(this.METRICS_STORE, /* clear */ true, /* filter test */ true),
|
||||
keyedScalars: Telemetry.getSnapshotForKeyedScalars(this.METRICS_STORE, /* clear */ true, /* filter test */ true),
|
||||
histograms: Telemetry.getSnapshotForHistograms(this.METRICS_STORE, /* clear */ true, /* filter test */ true),
|
||||
keyedHistograms: Telemetry.getSnapshotForKeyedHistograms(this.METRICS_STORE, /* clear */ true, /* filter test */ true),
|
||||
};
|
||||
|
||||
// UID is only allowed on post-account or login pings
|
||||
if (this._pingType == this.PingType.POST || reason == this.Reason.LOGIN) {
|
||||
let uid = Policy.fxaUid();
|
||||
if (uid) {
|
||||
// after additional data-review, we include the real uid.
|
||||
payload.uid = "00000000000000000000000000000000";
|
||||
}
|
||||
}
|
||||
|
||||
return payload;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the current ecosystem client ID
|
||||
*
|
||||
* TODO(bug 1530655): Replace by actual persisted ecosystem client ID as per spec
|
||||
*/
|
||||
_ecosystemClientId() {
|
||||
return "unknown";
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the minimal environment to include in the ping
|
||||
*/
|
||||
_environment() {
|
||||
let currentEnv = TelemetryEnvironment.currentEnvironment;
|
||||
let environment = {
|
||||
settings: {
|
||||
locale: currentEnv.settings.locale,
|
||||
},
|
||||
system: {
|
||||
memoryMB: currentEnv.system.memoryMB,
|
||||
os: currentEnv.system.os,
|
||||
cpu: {
|
||||
speedMHz: currentEnv.system.cpu.speedMHz,
|
||||
},
|
||||
},
|
||||
profile: { }, // added conditionally
|
||||
};
|
||||
|
||||
if (currentEnv.profile.creationDate) {
|
||||
environment.profile.creationDate = currentEnv.profile.creationDate;
|
||||
}
|
||||
|
||||
if (currentEnv.profile.firstUseDate) {
|
||||
environment.profile.firstUseDate = currentEnv.profile.firstUseDate;
|
||||
}
|
||||
|
||||
return environment;
|
||||
},
|
||||
|
||||
testReset() {
|
||||
this._initialized = false;
|
||||
this._lastSendTime = 0;
|
||||
this.startup();
|
||||
},
|
||||
|
||||
get _log() {
|
||||
if (!this._logger) {
|
||||
this._logger = Log.repository.getLoggerWithMessagePrefix(LOGGER_NAME, LOGGER_PREFIX);
|
||||
}
|
||||
|
||||
return this._logger;
|
||||
},
|
||||
};
|
@ -420,10 +420,6 @@ if (runningInParent) {
|
||||
// Ensure we're not in a GeckoView-like environment by default
|
||||
Services.prefs.setBoolPref("toolkit.telemetry.isGeckoViewMode", false);
|
||||
|
||||
// Make sure ecosystem telemetry is disabled, no matter which build
|
||||
// Individual tests will enable it when appropriate
|
||||
Services.prefs.setBoolPref(TelemetryUtils.Preferences.EcosystemTelemetryEnabled, false);
|
||||
|
||||
// Non-unified Telemetry (e.g. Fennec on Android) needs the preference to be set
|
||||
// in order to enable Telemetry.
|
||||
if (Services.prefs.getBoolPref(TelemetryUtils.Preferences.Unified, false)) {
|
||||
|
@ -1,183 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/TelemetryController.jsm", this);
|
||||
ChromeUtils.import("resource://gre/modules/TelemetryUtils.jsm", this);
|
||||
ChromeUtils.import("resource://gre/modules/Preferences.jsm", this);
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
ONLOGIN_NOTIFICATION: "resource://gre/modules/FxAccountsCommon.js",
|
||||
ONLOGOUT_NOTIFICATION: "resource://gre/modules/FxAccountsCommon.js",
|
||||
});
|
||||
ChromeUtils.defineModuleGetter(this, "EcosystemTelemetry",
|
||||
"resource://gre/modules/EcosystemTelemetry.jsm");
|
||||
|
||||
const WEAVE_EVENT = "weave:service:login:change";
|
||||
const TEST_PING_TYPE = "test-ping-type";
|
||||
|
||||
function checkPingStructure(ping, type, reason) {
|
||||
Assert.equal(ping.type, type, "Should be an ecosystem ping.");
|
||||
|
||||
Assert.ok(!("clientId" in ping), "Ping must not contain a client ID.");
|
||||
Assert.ok("environment" in ping, "Ping must contain an environment.");
|
||||
let environment = ping.environment;
|
||||
|
||||
// Check that the environment is indeed minimal
|
||||
const ALLOWED_ENVIRONMENT_KEYS = ["settings", "system", "profile"];
|
||||
Assert.deepEqual(ALLOWED_ENVIRONMENT_KEYS, Object.keys(environment), "Environment should only contain limited set of keys.");
|
||||
|
||||
// Check that fields of the environment are indeed minimal
|
||||
Assert.deepEqual(["locale"], Object.keys(environment.settings), "Settings environment should only contain locale");
|
||||
Assert.deepEqual(["cpu", "memoryMB", "os"], Object.keys(environment.system).sort(),
|
||||
"System environment should contain limit set of keys");
|
||||
|
||||
// Check the payload for required fields.
|
||||
let payload = ping.payload;
|
||||
Assert.equal(payload.reason, reason, "Ping reason must match.");
|
||||
Assert.ok(payload.duration >= 0, "Payload must have a duration greater or equal to 0");
|
||||
Assert.ok("ecosystemClientId" in payload, "Payload must contain the ecosystem client ID");
|
||||
|
||||
Assert.ok("scalars" in payload, "Payload must contain scalars");
|
||||
Assert.ok("keyedScalars" in payload, "Payload must contain keyed scalars");
|
||||
Assert.ok("histograms" in payload, "Payload must contain histograms");
|
||||
Assert.ok("keyedHistograms" in payload, "Payload must contain keyed histograms");
|
||||
}
|
||||
|
||||
function sendPing() {
|
||||
return TelemetryController.submitExternalPing(TEST_PING_TYPE, {}, {});
|
||||
}
|
||||
|
||||
function fakeFxaUid(fn) {
|
||||
const m = ChromeUtils.import("resource://gre/modules/EcosystemTelemetry.jsm", null);
|
||||
let oldFn = m.Policy.fxaUid;
|
||||
m.Policy.fxaUid = fn;
|
||||
return oldFn;
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
PingServer.stop();
|
||||
});
|
||||
|
||||
add_task(async function setup() {
|
||||
// Trigger a proper telemetry init.
|
||||
do_get_profile(true);
|
||||
// Make sure we don't generate unexpected pings due to pref changes.
|
||||
await setEmptyPrefWatchlist();
|
||||
|
||||
// Start the local ping server and setup Telemetry to use it during the tests.
|
||||
PingServer.start();
|
||||
Preferences.set(TelemetryUtils.Preferences.Server, "http://localhost:" + PingServer.port);
|
||||
TelemetrySend.setServer("http://localhost:" + PingServer.port);
|
||||
|
||||
await TelemetryController.testSetup();
|
||||
});
|
||||
|
||||
// We make absolute sure the Ecosystem ping is never triggered on Fennec/Non-unified Telemetry
|
||||
add_task({
|
||||
skip_if: () => !gIsAndroid,
|
||||
}, async function test_no_ecosystem_ping_on_fennec() {
|
||||
// Force preference to true, we should have an additional check on Android/Unified Telemetry
|
||||
Preferences.set(TelemetryUtils.Preferences.EcosystemTelemetryEnabled, true);
|
||||
EcosystemTelemetry.testReset();
|
||||
|
||||
// This is invoked in regular intervals by the timer.
|
||||
// Would trigger ping sending.
|
||||
EcosystemTelemetry.periodicPing();
|
||||
// Let's send a test ping to ensure we receive _something_.
|
||||
sendPing();
|
||||
|
||||
let ping = await PingServer.promiseNextPing();
|
||||
Assert.equal(ping.type, TEST_PING_TYPE, "Should be a test ping.");
|
||||
});
|
||||
|
||||
add_task({
|
||||
skip_if: () => gIsAndroid,
|
||||
}, async function test_nosending_if_disabled() {
|
||||
Preferences.set(TelemetryUtils.Preferences.EcosystemTelemetryEnabled, false);
|
||||
EcosystemTelemetry.testReset();
|
||||
|
||||
// This is invoked in regular intervals by the timer.
|
||||
// Would trigger ping sending.
|
||||
EcosystemTelemetry.periodicPing();
|
||||
// Let's send a test ping to ensure we receive _something_.
|
||||
sendPing();
|
||||
|
||||
let ping = await PingServer.promiseNextPing();
|
||||
Assert.equal(ping.type, TEST_PING_TYPE, "Should be a test ping.");
|
||||
});
|
||||
|
||||
add_task({
|
||||
skip_if: () => gIsAndroid,
|
||||
}, async function test_simple_send() {
|
||||
Preferences.set(TelemetryUtils.Preferences.EcosystemTelemetryEnabled, true);
|
||||
EcosystemTelemetry.testReset();
|
||||
|
||||
// This is invoked in regular intervals by the timer.
|
||||
EcosystemTelemetry.periodicPing();
|
||||
|
||||
let ping = await PingServer.promiseNextPing();
|
||||
checkPingStructure(ping, "pre-account", "periodic");
|
||||
});
|
||||
|
||||
add_task({
|
||||
skip_if: () => gIsAndroid,
|
||||
}, async function test_login_workflow() {
|
||||
// Fake the whole login/logout workflow by triggering the events directly.
|
||||
|
||||
Preferences.set(TelemetryUtils.Preferences.EcosystemTelemetryEnabled, true);
|
||||
EcosystemTelemetry.testReset();
|
||||
|
||||
let originalFxaUid = fakeFxaUid(() => null);
|
||||
let ping;
|
||||
|
||||
// 1. No user, timer invoked
|
||||
EcosystemTelemetry.periodicPing();
|
||||
ping = await PingServer.promiseNextPing();
|
||||
checkPingStructure(ping, "pre-account", "periodic");
|
||||
Assert.ok(!("uid" in ping.payload), "Ping should not contain a UID");
|
||||
|
||||
// 2. User logs in, no uid available.
|
||||
// No ping will be generated.
|
||||
EcosystemTelemetry.observe(null, ONLOGIN_NOTIFICATION, null);
|
||||
sendPing();
|
||||
ping = await PingServer.promiseNextPing();
|
||||
Assert.equal(ping.type, TEST_PING_TYPE, "Should be a test ping.");
|
||||
|
||||
// 3. uid becomes available, weave syncs.
|
||||
fakeFxaUid(() => "hashed-id");
|
||||
EcosystemTelemetry.observe(null, WEAVE_EVENT, null);
|
||||
ping = await PingServer.promiseNextPing();
|
||||
checkPingStructure(ping, "pre-account", "login");
|
||||
Assert.ok("uid" in ping.payload, "Ping should contain hashed ID");
|
||||
|
||||
// 4. User is logged in, timer invokes different ping
|
||||
EcosystemTelemetry.periodicPing();
|
||||
ping = await PingServer.promiseNextPing();
|
||||
checkPingStructure(ping, "pre-account", "periodic");
|
||||
Assert.ok("uid" in ping.payload, "Ping should contain hashed ID");
|
||||
|
||||
// 5. User disconnects account, no uid available
|
||||
fakeFxaUid(() => null);
|
||||
EcosystemTelemetry.observe(null, ONLOGOUT_NOTIFICATION, null);
|
||||
ping = await PingServer.promiseNextPing();
|
||||
checkPingStructure(ping, "pre-account", "logout");
|
||||
Assert.ok(!("uid" in ping.payload), "Ping should not contain a UID");
|
||||
|
||||
// 6. No user, timer invoked
|
||||
EcosystemTelemetry.periodicPing();
|
||||
ping = await PingServer.promiseNextPing();
|
||||
checkPingStructure(ping, "pre-account", "periodic");
|
||||
Assert.ok(!("uid" in ping.payload), "Ping should not contain a UID");
|
||||
|
||||
// 7. Shutdown
|
||||
EcosystemTelemetry.shutdown();
|
||||
ping = await PingServer.promiseNextPing();
|
||||
checkPingStructure(ping, "pre-account", "shutdown");
|
||||
Assert.ok(!("uid" in ping.payload), "Ping should not contain a UID");
|
||||
|
||||
// Reset policy.
|
||||
fakeFxaUid(originalFxaUid);
|
||||
});
|
@ -95,7 +95,6 @@ skip-if = (os == "android") || (os == "linux" && bits == 32)
|
||||
[test_TelemetryUtils.js]
|
||||
[test_UntrustedModulesPing.js]
|
||||
run-if = nightly_build && (os == 'win')
|
||||
[test_EcosystemTelemetry.js]
|
||||
[test_EventPing.js]
|
||||
[test_EventPing_disabled.js]
|
||||
tags = coverage
|
||||
|
Loading…
Reference in New Issue
Block a user