Bug 721020 - [New Tab Page] Add telemetry probes r=ttaubert

This commit is contained in:
Raymond Lee 2012-04-25 09:45:01 +08:00
Родитель 27793b2584
Коммит 7753b719e2
2 изменённых файлов: 51 добавлений и 0 удалений

Просмотреть файл

@ -27,6 +27,9 @@ const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
// The maximum number of results we want to retrieve from history. // The maximum number of results we want to retrieve from history.
const HISTORY_RESULTS_LIMIT = 100; const HISTORY_RESULTS_LIMIT = 100;
// The gather telemetry topic.
const TOPIC_GATHER_TELEMETRY = "gather-telemetry";
/** /**
* Singleton that provides storage functionality. * Singleton that provides storage functionality.
*/ */
@ -585,6 +588,47 @@ let Links = {
Ci.nsISupportsWeakReference]) Ci.nsISupportsWeakReference])
}; };
/**
* Singleton used to collect telemetry data.
*
*/
let Telemetry = {
/**
* Initializes object.
*/
init: function Telemetry_init() {
Services.obs.addObserver(this, TOPIC_GATHER_TELEMETRY, false);
},
/**
* Collects data.
*/
_collect: function Telemetry_collect() {
let probes = [
{ histogram: "NEWTAB_PAGE_ENABLED",
value: AllPages.enabled },
{ histogram: "NEWTAB_PAGE_PINNED_SITES_COUNT",
value: PinnedLinks.links.length },
{ histogram: "NEWTAB_PAGE_BLOCKED_SITES_COUNT",
value: Object.keys(BlockedLinks.links).length }
];
probes.forEach(function Telemetry_collect_forEach(aProbe) {
Services.telemetry.getHistogramById(aProbe.histogram)
.add(aProbe.value);
});
},
/**
* Listens for gather telemetry topic.
*/
observe: function Telemetry_observe(aSubject, aTopic, aData) {
this._collect();
}
};
Telemetry.init();
/** /**
* Singleton that provides the public API of this JSM. * Singleton that provides the public API of this JSM.
*/ */

Просмотреть файл

@ -434,6 +434,13 @@ HISTOGRAM_FLAG(TELEMETRY_TEST_FLAG, "a testing histogram; not meant to be touche
HISTOGRAM_FLAG(STARTUP_CRASH_DETECTED, "Whether there was a crash during the last startup") HISTOGRAM_FLAG(STARTUP_CRASH_DETECTED, "Whether there was a crash during the last startup")
HISTOGRAM_ENUMERATED_VALUES(SAFE_MODE_USAGE, 3, "Whether the user is in safe mode (No, Yes, Forced)") HISTOGRAM_ENUMERATED_VALUES(SAFE_MODE_USAGE, 3, "Whether the user is in safe mode (No, Yes, Forced)")
/**
* New Tab Page telemetry.
*/
HISTOGRAM(NEWTAB_PAGE_ENABLED, 0, 1, 2, BOOLEAN, "New tab page is enabled.")
HISTOGRAM(NEWTAB_PAGE_PINNED_SITES_COUNT, 1, 9, 10, EXPONENTIAL, "Number of pinned sites on the new tab page.")
HISTOGRAM(NEWTAB_PAGE_BLOCKED_SITES_COUNT, 1, 100, 10, EXPONENTIAL, "Number of sites blocked from the new tab page.")
/** /**
* Native Fennec Telemetry * Native Fennec Telemetry
*/ */