зеркало из https://github.com/mozilla/pjs.git
Bug 666538 - Use Telemetry to collect Panorama usage/perf data. r=ttaubert
This commit is contained in:
Родитель
148d7c765b
Коммит
a0e9a879fc
|
@ -214,6 +214,8 @@ let TabView = {
|
|||
|
||||
this._isFrameLoading = true;
|
||||
|
||||
TelemetryStopwatch.start("PANORAMA_INITIALIZATION_TIME_MS");
|
||||
|
||||
// ___ find the deck
|
||||
this._deck = document.getElementById("tab-view-deck");
|
||||
|
||||
|
@ -229,6 +231,8 @@ let TabView = {
|
|||
window.addEventListener("tabviewframeinitialized", function onInit() {
|
||||
window.removeEventListener("tabviewframeinitialized", onInit, false);
|
||||
|
||||
TelemetryStopwatch.finish("PANORAMA_INITIALIZATION_TIME_MS");
|
||||
|
||||
self._isFrameLoading = false;
|
||||
self._window = self._iframe.contentWindow;
|
||||
self._setBrowserKeyHandlers();
|
||||
|
|
|
@ -73,4 +73,5 @@ let AllTabs = {
|
|||
#include drag.js
|
||||
#include trench.js
|
||||
#include search.js
|
||||
#include telemetry.js
|
||||
#include ui.js
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/* 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/. */
|
||||
|
||||
/**
|
||||
* Collects telemetry data for Tabview.
|
||||
*/
|
||||
let Telemetry = {
|
||||
TOPIC_GATHER_TELEMETRY: "gather-telemetry",
|
||||
|
||||
/**
|
||||
* Initializes the object.
|
||||
*/
|
||||
init: function Telemetry_init() {
|
||||
Services.obs.addObserver(this, this.TOPIC_GATHER_TELEMETRY, false);
|
||||
},
|
||||
|
||||
/**
|
||||
* Uninitializes the object.
|
||||
*/
|
||||
uninit: function Telemetry_uninit() {
|
||||
Services.obs.removeObserver(this, this.TOPIC_GATHER_TELEMETRY);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds telemetry values to gather usage statistics.
|
||||
*/
|
||||
_collect: function Telemetry_collect() {
|
||||
let stackedGroupsCount = 0;
|
||||
let childCounts = [];
|
||||
|
||||
GroupItems.groupItems.forEach(function (groupItem) {
|
||||
if (!groupItem.isEmpty()) {
|
||||
childCounts.push(groupItem.getChildren().length);
|
||||
|
||||
if (groupItem.isStacked())
|
||||
stackedGroupsCount++;
|
||||
}
|
||||
});
|
||||
|
||||
function addTelemetryValue(aId, aValue) {
|
||||
Services.telemetry.getHistogramById("PANORAMA_" + aId).add(aValue);
|
||||
}
|
||||
function median(aChildCounts) {
|
||||
aChildCounts.sort(function(x, y) { return x - y; });
|
||||
let middle = Math.floor(aChildCounts.length / 2);
|
||||
return aChildCounts[middle];
|
||||
}
|
||||
|
||||
addTelemetryValue("GROUPS_COUNT", GroupItems.groupItems.length);
|
||||
addTelemetryValue("STACKED_GROUPS_COUNT", stackedGroupsCount);
|
||||
addTelemetryValue("MEDIAN_TABS_IN_GROUPS_COUNT", median(childCounts));
|
||||
},
|
||||
|
||||
/**
|
||||
* Observes for gather telemetry topic.
|
||||
*/
|
||||
observe: function Telemetry_observe(aSubject, aTopic, aData) {
|
||||
if (!gPrivateBrowsing.privateBrowsingEnabled)
|
||||
this._collect();
|
||||
}
|
||||
}
|
||||
|
|
@ -171,6 +171,8 @@ let UI = {
|
|||
// ___ search
|
||||
Search.init();
|
||||
|
||||
Telemetry.init();
|
||||
|
||||
// ___ currentTab
|
||||
this._currentTab = gBrowser.selectedTab;
|
||||
|
||||
|
@ -312,6 +314,7 @@ let UI = {
|
|||
GroupItems.uninit();
|
||||
FavIcons.uninit();
|
||||
Storage.uninit();
|
||||
Telemetry.uninit();
|
||||
|
||||
this._removeTabActionHandlers();
|
||||
this._currentTab = null;
|
||||
|
|
|
@ -451,6 +451,14 @@ 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.")
|
||||
|
||||
/**
|
||||
* Panorama telemetry.
|
||||
*/
|
||||
HISTOGRAM(PANORAMA_INITIALIZATION_TIME_MS, 1, 10000, 15, EXPONENTIAL, "Time it takes to initialize Panorama (ms)")
|
||||
HISTOGRAM(PANORAMA_GROUPS_COUNT, 1, 25, 15, EXPONENTIAL, "Number of groups in Panorama")
|
||||
HISTOGRAM(PANORAMA_STACKED_GROUPS_COUNT, 1, 25, 15, EXPONENTIAL, "Number of stacked groups in Panorama")
|
||||
HISTOGRAM(PANORAMA_MEDIAN_TABS_IN_GROUPS_COUNT, 1, 100, 15, EXPONENTIAL, "Median of tabs in groups in Panorama")
|
||||
|
||||
/**
|
||||
* Native Fennec Telemetry
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче