Bug 972930 - Clicks (raw number) for tiles [r=adw]

Provide an array of expected directory link types to count how many were clicked.
This commit is contained in:
Ed Lee 2014-03-31 01:51:22 -07:00
parent d848823ffd
commit 81dab972bb
4 changed files with 22 additions and 0 deletions

View File

@ -11,6 +11,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PageThumbs.jsm");
Cu.import("resource://gre/modules/BackgroundPageThumbs.jsm");
Cu.import("resource://gre/modules/DirectoryLinksProvider.jsm");
Cu.import("resource://gre/modules/NewTabUtils.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");

View File

@ -189,6 +189,13 @@ Site.prototype = {
}
Services.telemetry.getHistogramById("NEWTAB_PAGE_SITE_CLICKED")
.add(aIndex);
// Specially count clicks on directory tiles
let typeIndex = DirectoryLinksProvider.linkTypes.indexOf(this.link.type);
if (typeIndex != -1) {
Services.telemetry.getHistogramById("NEWTAB_PAGE_DIRECTORY_TYPE_CLICKED")
.add(typeIndex);
}
},
/**

View File

@ -4041,6 +4041,12 @@
"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."
},
"NEWTAB_PAGE_DIRECTORY_TYPE_CLICKED": {
"expires_in_version": "35",
"kind": "enumerated",
"n_values": 3,
"description": "Track click count on about:newtab directory links per type (sponsored, affiliate, organic)."
},
"PANORAMA_INITIALIZATION_TIME_MS": {
"expires_in_version": "never",
"kind": "exponential",

View File

@ -60,6 +60,12 @@ const PREF_DIRECTORY_SOURCE = "browser.newtabpage.directorySource";
// The frecency of a directory link
const DIRECTORY_FRECENCY = 1000;
const LINK_TYPES = Object.freeze([
"sponsored",
"affiliate",
"organic",
]);
/**
* Singleton that serves as the provider of directory links.
* Directory links are a hard-coded set of links shown if a user's link
@ -89,6 +95,8 @@ let DirectoryLinksProvider = {
return this.__linksURL;
},
get linkTypes() LINK_TYPES,
observe: function DirectoryLinksProvider_observe(aSubject, aTopic, aData) {
if (aTopic == "nsPref:changed") {
if (aData == this._prefs["linksURL"]) {