Bug 975570 - Measure with telemetry how many times people interact with about:newtab. r=ttaubert

This commit is contained in:
Georg Fritzsche 2014-02-27 18:57:05 +01:00
Родитель 870e68b546
Коммит 86e61c6a1b
2 изменённых файлов: 43 добавлений и 11 удалений

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

@ -163,10 +163,7 @@ Site.prototype = {
this._node.addEventListener("dragstart", this, false);
this._node.addEventListener("dragend", this, false);
this._node.addEventListener("mouseover", this, false);
let controls = this.node.querySelectorAll(".newtab-control");
for (let i = 0; i < controls.length; i++)
controls[i].addEventListener("click", this, false);
this._node.addEventListener("click", this, false);
},
/**
@ -178,19 +175,48 @@ Site.prototype = {
sc.speculativeConnect(uri, null);
},
/**
* Record interaction with site using telemetry.
*/
_recordSiteClicked: function Site_recordSiteClicked(aIndex) {
if (Services.prefs.prefHasUserValue("browser.newtabpage.rows") ||
Services.prefs.prefHasUserValue("browser.newtabpage.columns") ||
aIndex > 8) {
// We only want to get indices for the default configuration, everything
// else goes in the same bucket.
aIndex = 9;
}
Services.telemetry.getHistogramById("NEWTAB_PAGE_SITE_CLICKED")
.add(aIndex);
},
/**
* Handles site click events.
*/
_onClick: function Site_onClick(aEvent) {
let target = aEvent.target;
if (target.classList.contains("newtab-link") ||
target.parentElement.classList.contains("newtab-link")) {
this._recordSiteClicked(this.cell.index);
return;
}
aEvent.preventDefault();
if (aEvent.target.classList.contains("newtab-control-block"))
this.block();
else if (this.isPinned())
this.unpin();
else
this.pin();
},
/**
* Handles all site events.
*/
handleEvent: function Site_handleEvent(aEvent) {
switch (aEvent.type) {
case "click":
aEvent.preventDefault();
if (aEvent.target.classList.contains("newtab-control-block"))
this.block();
else if (this.isPinned())
this.unpin();
else
this.pin();
this._onClick(aEvent);
break;
case "mouseover":
this._node.removeEventListener("mouseover", this, false);

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

@ -4011,6 +4011,12 @@
"kind": "boolean",
"description": "Number of times about:newtab was shown from opening a new tab or window."
},
"NEWTAB_PAGE_SITE_CLICKED": {
"expires_in_version": "35",
"kind": "enumerated",
"n_values": 10,
"description": "Track click count on about:newtab tiles per index (0-8). For non-default row or column configurations all clicks into the '9' bucket."
},
"PANORAMA_INITIALIZATION_TIME_MS": {
"expires_in_version": "never",
"kind": "exponential",