Bug 1396811 - Add new telemetry probe collecting the current theme; r=chutten,ochameau,liuche
MozReview-Commit-ID: KlUHlc7YEx9
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -7,16 +7,17 @@
const SOURCE_MAP_WORKER = "resource://devtools/client/shared/source-map/worker.js";
const MAX_ORDINAL = 99;
const SPLITCONSOLE_ENABLED_PREF = "devtools.toolbox.splitconsoleEnabled";
const SPLITCONSOLE_HEIGHT_PREF = "devtools.toolbox.splitconsoleHeight";
const DISABLE_AUTOHIDE_PREF = "ui.popup.disable_autohide";
const HOST_HISTOGRAM = "DEVTOOLS_TOOLBOX_HOST";
const SCREENSIZE_HISTOGRAM = "DEVTOOLS_SCREEN_RESOLUTION_ENUMERATED_PER_USER";
+const CURRENT_THEME_SCALAR = "devtools.current_theme";
const HTML_NS = "http://www.w3.org/1999/xhtml";
var {Ci, Cu, Cc} = require("chrome");
var promise = require("promise");
var defer = require("devtools/shared/defer");
var Services = require("Services");
var {Task} = require("devtools/shared/task");
var {gDevTools} = require("devtools/client/framework/devtools");
@@ -645,16 +646,21 @@ Toolbox.prototype = {
},
_pingTelemetry: function () {
this._telemetry.toolOpened("toolbox");
this._telemetry.logOncePerBrowserVersion(SCREENSIZE_HISTOGRAM,
system.getScreenDimensions());
this._telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId());
+
+ // Log current theme. The question we want to answer is:
+ // "What proportion of users use which themes?"
+ let currentTheme = Services.prefs.getCharPref("devtools.theme");
+ this._telemetry.logKeyedScalar(CURRENT_THEME_SCALAR, currentTheme, 1);
},
/**
* Create a simple object to store the state of a toolbox button. The checked state of
* a button can be updated arbitrarily outside of the scope of the toolbar and its
* controllers. In order to simplify this interaction this object emits an
* "updatechecked" event any time the isChecked value is updated, allowing any consuming
* components to listen and respond to updates.
--- a/devtools/client/shared/telemetry.js
+++ b/devtools/client/shared/telemetry.js
@@ -12,16 +12,18 @@
const TOOLS_OPENED_PREF = "devtools.telemetry.tools.opened.version";
function Telemetry() {
// Bind pretty much all functions so that callers do not need to.
this.toolOpened = this.toolOpened.bind(this);
this.toolClosed = this.toolClosed.bind(this);
this.log = this.log.bind(this);
+ this.logScalar = this.logScalar.bind(this);
+ this.logKeyedScalar = this.logKeyedScalar.bind(this);
this.logOncePerBrowserVersion = this.logOncePerBrowserVersion.bind(this);
this.destroy = this.destroy.bind(this);
this._timers = new Map();
}
module.exports = Telemetry;
@@ -305,16 +307,46 @@ Telemetry.prototype = {
Services.telemetry.scalarSet(scalarId, value);
} catch (e) {
dump(`Warning: An attempt was made to write to the ${scalarId} ` +
`scalar, which is not defined in Scalars.yaml\n`);
}
},
/**
+ * Log a value to a keyed count scalar.
+ *
+ * @param {String} scalarId
+ * Scalar in which the data is to be stored.
+ * @param {String} key
+ * The key within the scalar.
+ * @param value
+ * Value to store.
+ */
+ logKeyedScalar: function (scalarId, key, value) {
+ if (!scalarId) {
+ return;
+ }
+
+ try {
+ if (isNaN(value)) {
+ dump(`Warning: An attempt was made to write a non-numeric value ` +
+ `${value} to the ${scalarId} scalar. Only numeric values are ` +
+ `allowed.`);
+
+ return;
+ }
+ Services.telemetry.keyedScalarAdd(scalarId, key, value);
+ } catch (e) {
+ dump(`Warning: An attempt was made to write to the ${scalarId} ` +
+ `scalar, which is not defined in Scalars.yaml\n`);
+ }
+ },
+
+ /**
* Log a value to a keyed histogram.
*
* @param {String} histogramId
* Histogram in which the data is to be stored.
* @param {String} key
* The key within the single histogram.
* @param [value]
* Optional value to store.
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -770,16 +770,31 @@ devtools.grid.showInfiniteLines:
expires: never
kind: uint
notification_emails:
- dev-developer-tools@lists.mozilla.org
release_channel_collection: opt-out
record_in_processes:
- 'main'
+devtools:
+ current_theme:
+ bug_numbers:
+ - 1396811
+ description: >
+ Number of times DevTools was opened, keyed by theme.
+ expires: never
+ kind: uint
+ keyed: true
+ notification_emails:
+ - dev-developer-tools@lists.mozilla.org
+ release_channel_collection: opt-out
+ record_in_processes:
+ - 'main'
+
navigator.storage:
estimate_count:
bug_numbers:
- 1359708
description: >
Number of times navigator.storage.estimate has been used.
expires: "60"
kind: uint