Bug 1373093 - Add operating system information to the desktop Sync ping. r?tcsc
MozReview-Commit-ID: 9ypnosSawxu
--- a/services/sync/modules/telemetry.js
+++ b/services/sync/modules/telemetry.js
@@ -21,16 +21,18 @@ Cu.import("resource://services-common/as
let constants = {};
Cu.import("resource://services-sync/constants.js", constants);
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryController",
"resource://gre/modules/TelemetryController.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryUtils",
"resource://gre/modules/TelemetryUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "TelemetryEnvironment",
+ "resource://gre/modules/TelemetryEnvironment.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "Telemetry",
"@mozilla.org/base/telemetry;1",
"nsITelemetry");
const log = Log.repository.getLogger("Sync.Telemetry");
@@ -421,16 +423,17 @@ class SyncTelemetryImpl {
this.lastDeviceID = undefined;
let sessionStartDate = Services.startup.getStartupInfo().main;
this.sessionStartDate = TelemetryUtils.toLocalTimeISOString(
TelemetryUtils.truncateToHours(sessionStartDate));
}
getPingJSON(reason) {
return {
+ os: TelemetryEnvironment.currentEnvironment["system"]["os"],
why: reason,
discarded: this.discarded || undefined,
version: PING_FORMAT_VERSION,
syncs: this.payloads.slice(),
uid: this.lastUID,
deviceID: this.lastDeviceID,
sessionStartDate: this.sessionStartDate,
events: this.events.length == 0 ? undefined : this.events,
--- a/services/sync/tests/unit/sync_ping_schema.json
+++ b/services/sync/tests/unit/sync_ping_schema.json
@@ -1,16 +1,17 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "schema for Sync pings, documentation avaliable in toolkit/components/telemetry/docs/sync-ping.rst",
"type": "object",
"additionalProperties": false,
"required": ["version", "syncs", "why", "uid"],
"properties": {
"version": { "type": "integer", "minimum": 0 },
+ "os": { "type": "object" },
"discarded": { "type": "integer", "minimum": 1 },
"why": { "enum": ["shutdown", "schedule", "idchange"] },
"uid": {
"type": "string",
"pattern": "^[0-9a-f]{32}$"
},
"deviceID": {
"type": "string",
--- a/services/sync/tests/unit/test_telemetry.js
+++ b/services/sync/tests/unit/test_telemetry.js
@@ -85,17 +85,24 @@ add_task(async function test_basic() {
for (let coll of collections) {
handlers["/1.1/johndoe/storage/" + coll] = upd(coll, new ServerCollection({}, true).handler());
}
let server = httpd_setup(handlers);
await configureIdentity({ username: "johndoe" }, server);
- await sync_and_validate_telem(true);
+ let ping = await sync_and_validate_telem(true, true);
+
+ // Check the "os" block - we can't really check specific values, but can
+ // check it smells sane.
+ ok(ping.os, "there is an OS block");
+ ok("name" in ping.os, "there is an OS name");
+ ok("version" in ping.os, "there is an OS version");
+ ok("locale" in ping.os, "there is an OS locale");
Svc.Prefs.resetBranch("");
await promiseStopServer(server);
});
add_task(async function test_processIncoming_error() {
let engine = new BookmarksEngine(Service);
let store = engine._store;
--- a/toolkit/components/telemetry/docs/data/sync-ping.rst
+++ b/toolkit/components/telemetry/docs/data/sync-ping.rst
@@ -13,16 +13,17 @@ Structure:
.. code-block:: js
{
version: 4,
type: "sync",
... common ping data
payload: {
version: 1,
+ os : { ... }, // os data from the current telemetry environment. OS specific, but typically includes name, version and locale.
discarded: <integer count> // Number of syncs discarded -- left out if zero.
why: <string>, // Why did we submit the ping? Either "shutdown", "schedule", or "idchanged".
uid: <string>, // Hashed FxA unique ID, or string of 32 zeros. If this changes between syncs, the payload is submitted.
deviceID: <string>, // Hashed FxA Device ID, hex string of 64 characters, not included if the user is not logged in. If this changes between syncs, the payload is submitted.
sessionStartDate: <ISO date>, // hourly precision, ISO date in local time
// Array of recorded syncs. The ping is not submitted if this would be empty
syncs: [{
when: <integer milliseconds since epoch>,