From c4254c3ce9249d307720bde1a4a5152f66a4bfee Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Wed, 16 Jul 2014 19:15:02 -0700 Subject: [PATCH] Bug 1036581 add telemetry probes to social buttons and sidebar, r=dolske --- browser/base/content/browser-social.js | 40 +++++++++++++++++++- browser/base/content/socialmarks.xml | 6 +++ toolkit/components/telemetry/Histograms.json | 29 +++++++++++--- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js index baed8ede2d6..21fb1ad2dfb 100644 --- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -578,12 +578,18 @@ SocialShare = { } }, + _onclick: function() { + Services.telemetry.getHistogramById("SOCIAL_PANEL_CLICKS").add(0); + }, + onShowing: function() { this.anchor.setAttribute("open", "true"); + this.iframe.addEventListener("click", this._onclick, true); }, onHidden: function() { this.anchor.removeAttribute("open"); + this.iframe.removeEventListener("click", this._onclick, true); this.iframe.setAttribute("src", "data:text/plain;charset=utf8,"); this.currentShare = null; }, @@ -704,10 +710,13 @@ SocialShare = { let anchor = document.getAnonymousElementByAttribute(this.anchor, "class", "toolbarbutton-icon"); this.panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false); Social.setErrorListener(iframe, this.setErrorMessage.bind(this)); + Services.telemetry.getHistogramById("SOCIAL_TOOLBAR_BUTTONS").add(0); } }; SocialSidebar = { + _openStartTime: 0, + // Whether the sidebar can be shown for this window. get canShow() { if (!SocialUI.enabled || document.mozFullScreen) @@ -780,6 +789,11 @@ SocialSidebar = { "hidden": broadcaster.hidden, "origin": sidebarOrigin }; + if (broadcaster.hidden) { + Services.telemetry.getHistogramById("SOCIAL_SIDEBAR_OPEN_DURATION").add(Date.now() / 1000 - this._openStartTime); + } else { + this._openStartTime = Date.now() / 1000; + } // Save a global state for users who do not restore state. if (broadcaster.hidden) @@ -877,11 +891,16 @@ SocialSidebar = { this._updateCheckedMenuItems(this.opened && this.provider ? this.provider.origin : null); }, + _onclick: function() { + Services.telemetry.getHistogramById("SOCIAL_PANEL_CLICKS").add(3); + }, + _loadListener: function SocialSidebar_loadListener() { let sbrowser = document.getElementById("social-sidebar-browser"); sbrowser.removeEventListener("load", SocialSidebar._loadListener, true); document.getElementById("social-sidebar-button").removeAttribute("loading"); SocialSidebar.setSidebarVisibilityState(true); + sbrowser.addEventListener("click", SocialSidebar._onclick, true); }, unloadSidebar: function SocialSidebar_unloadSidebar() { @@ -889,6 +908,7 @@ SocialSidebar = { if (!sbrowser.hasAttribute("origin")) return; + sbrowser.removeEventListener("click", SocialSidebar._onclick, true); sbrowser.stop(); sbrowser.removeAttribute("origin"); sbrowser.setAttribute("src", "about:blank"); @@ -989,6 +1009,7 @@ SocialSidebar = { else SocialSidebar.update(); this.saveWindowState(); + Services.telemetry.getHistogramById("SOCIAL_SIDEBAR_STATE").add(true); }, hide: function() { @@ -998,6 +1019,7 @@ SocialSidebar = { this.clearProviderMenus(); SocialSidebar.update(); this.saveWindowState(); + Services.telemetry.getHistogramById("SOCIAL_SIDEBAR_STATE").add(false); }, toggleSidebar: function SocialSidebar_toggle() { @@ -1219,13 +1241,29 @@ SocialStatus = { } }, + _onclose: function() { + let notificationFrameId = "social-status-" + origin; + let frame = document.getElementById(notificationFrameId); + frame.removeEventListener("close", this._onclose, true); + frame.removeEventListener("click", this._onclick, true); + }, + + _onclick: function() { + Services.telemetry.getHistogramById("SOCIAL_PANEL_CLICKS").add(1); + }, + showPopup: function(aToolbarButton) { // attach our notification panel if necessary let origin = aToolbarButton.getAttribute("origin"); let provider = Social._getProviderFromOrigin(origin); PanelFrame.showPopup(window, PanelUI, aToolbarButton, "social", origin, - provider.statusURL, provider.getPageSize("status")); + provider.statusURL, provider.getPageSize("status"), + (frame) => { + frame.addEventListener("close", this._onclose, true); + frame.addEventListener("click", this._onclick, true); + }); + Services.telemetry.getHistogramById("SOCIAL_TOOLBAR_BUTTONS").add(1); }, setPanelErrorMessage: function(aNotificationFrame) { diff --git a/browser/base/content/socialmarks.xml b/browser/base/content/socialmarks.xml index 595885e2596..c3d9c486808 100644 --- a/browser/base/content/socialmarks.xml +++ b/browser/base/content/socialmarks.xml @@ -235,6 +235,7 @@ setTimeout(() => { panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false); }, 0); + Services.telemetry.getHistogramById("SOCIAL_TOOLBAR_BUTTONS").add(2); ]]> @@ -330,6 +331,9 @@ this.setAttribute("image", uri.spec); } break; + case "click": + Services.telemetry.getHistogramById("SOCIAL_PANEL_CLICKS").add(2); + break; } ]]> @@ -338,6 +342,7 @@