Bug 972930 - Clicks (raw number) for tiles [r=adw]
authorEd Lee <edilee@mozilla.com>
Mon, 31 Mar 2014 01:51:22 -0700
changeset 176288 f72dc82b5ee01122269e3b8a04173e05e17fb8de
parent 176287 ae535b7584fd0c14c3487dc0ca4d9de150f33c53
child 176289 d1e2119219830013a34295b13fabadc99d9a2d5f
push id26518
push userkwierso@gmail.com
push dateTue, 01 Apr 2014 03:03:56 +0000
treeherdermozilla-central@4d8323b1389d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs972930
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 972930 - Clicks (raw number) for tiles [r=adw] Provide an array of expected directory link types to count how many were clicked.
browser/base/content/newtab/newTab.js
browser/base/content/newtab/sites.js
toolkit/components/telemetry/Histograms.json
toolkit/modules/DirectoryLinksProvider.jsm
--- a/browser/base/content/newtab/newTab.js
+++ b/browser/base/content/newtab/newTab.js
@@ -6,16 +6,17 @@
 
 let Cu = Components.utils;
 let Ci = Components.interfaces;
 
 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");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Rect",
   "resource://gre/modules/Geometry.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
   "resource://gre/modules/PrivateBrowsingUtils.jsm");
 
--- a/browser/base/content/newtab/sites.js
+++ b/browser/base/content/newtab/sites.js
@@ -184,16 +184,23 @@ Site.prototype = {
         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);
+
+    // 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);
+    }
   },
 
   /**
    * Handles site click events.
    */
   _onClick: function Site_onClick(aEvent) {
     let target = aEvent.target;
     if (target.classList.contains("newtab-link") ||
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -4036,16 +4036,22 @@
     "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."
   },
+  "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",
     "high": "10000",
     "n_buckets": 15,
     "extended_statistics_ok": true,
     "description": "Time it takes to initialize Panorama (ms)"
   },
--- a/toolkit/modules/DirectoryLinksProvider.jsm
+++ b/toolkit/modules/DirectoryLinksProvider.jsm
@@ -55,16 +55,22 @@ const PREF_MATCH_OS_LOCALE = "intl.local
 const PREF_SELECTED_LOCALE = "general.useragent.locale";
 
 // The preference that tells where to obtain directory links
 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
  * inventory is empty.
  */
 let DirectoryLinksProvider = {
 
   __linksURL: null,
@@ -84,16 +90,18 @@ let DirectoryLinksProvider = {
       }
       catch (e) {
         Cu.reportError("Error fetching directory links url from prefs: " + e);
       }
     }
     return this.__linksURL;
   },
 
+  get linkTypes() LINK_TYPES,
+
   observe: function DirectoryLinksProvider_observe(aSubject, aTopic, aData) {
     if (aTopic == "nsPref:changed") {
       if (aData == this._prefs["linksURL"]) {
         delete this.__linksURL;
       }
       this._callObservers("onManyLinksChanged");
     }
   },