Bug 1036581 add telemetry probes to social buttons and sidebar, r=dolske

This commit is contained in:
Shane Caraveo 2014-07-16 19:15:02 -07:00
parent d778407bb2
commit c4254c3ce9
3 changed files with 69 additions and 6 deletions

View File

@ -578,12 +578,18 @@ SocialShare = {
} }
}, },
_onclick: function() {
Services.telemetry.getHistogramById("SOCIAL_PANEL_CLICKS").add(0);
},
onShowing: function() { onShowing: function() {
this.anchor.setAttribute("open", "true"); this.anchor.setAttribute("open", "true");
this.iframe.addEventListener("click", this._onclick, true);
}, },
onHidden: function() { onHidden: function() {
this.anchor.removeAttribute("open"); this.anchor.removeAttribute("open");
this.iframe.removeEventListener("click", this._onclick, true);
this.iframe.setAttribute("src", "data:text/plain;charset=utf8,"); this.iframe.setAttribute("src", "data:text/plain;charset=utf8,");
this.currentShare = null; this.currentShare = null;
}, },
@ -704,10 +710,13 @@ SocialShare = {
let anchor = document.getAnonymousElementByAttribute(this.anchor, "class", "toolbarbutton-icon"); let anchor = document.getAnonymousElementByAttribute(this.anchor, "class", "toolbarbutton-icon");
this.panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false); this.panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false);
Social.setErrorListener(iframe, this.setErrorMessage.bind(this)); Social.setErrorListener(iframe, this.setErrorMessage.bind(this));
Services.telemetry.getHistogramById("SOCIAL_TOOLBAR_BUTTONS").add(0);
} }
}; };
SocialSidebar = { SocialSidebar = {
_openStartTime: 0,
// Whether the sidebar can be shown for this window. // Whether the sidebar can be shown for this window.
get canShow() { get canShow() {
if (!SocialUI.enabled || document.mozFullScreen) if (!SocialUI.enabled || document.mozFullScreen)
@ -780,6 +789,11 @@ SocialSidebar = {
"hidden": broadcaster.hidden, "hidden": broadcaster.hidden,
"origin": sidebarOrigin "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. // Save a global state for users who do not restore state.
if (broadcaster.hidden) if (broadcaster.hidden)
@ -877,11 +891,16 @@ SocialSidebar = {
this._updateCheckedMenuItems(this.opened && this.provider ? this.provider.origin : null); this._updateCheckedMenuItems(this.opened && this.provider ? this.provider.origin : null);
}, },
_onclick: function() {
Services.telemetry.getHistogramById("SOCIAL_PANEL_CLICKS").add(3);
},
_loadListener: function SocialSidebar_loadListener() { _loadListener: function SocialSidebar_loadListener() {
let sbrowser = document.getElementById("social-sidebar-browser"); let sbrowser = document.getElementById("social-sidebar-browser");
sbrowser.removeEventListener("load", SocialSidebar._loadListener, true); sbrowser.removeEventListener("load", SocialSidebar._loadListener, true);
document.getElementById("social-sidebar-button").removeAttribute("loading"); document.getElementById("social-sidebar-button").removeAttribute("loading");
SocialSidebar.setSidebarVisibilityState(true); SocialSidebar.setSidebarVisibilityState(true);
sbrowser.addEventListener("click", SocialSidebar._onclick, true);
}, },
unloadSidebar: function SocialSidebar_unloadSidebar() { unloadSidebar: function SocialSidebar_unloadSidebar() {
@ -889,6 +908,7 @@ SocialSidebar = {
if (!sbrowser.hasAttribute("origin")) if (!sbrowser.hasAttribute("origin"))
return; return;
sbrowser.removeEventListener("click", SocialSidebar._onclick, true);
sbrowser.stop(); sbrowser.stop();
sbrowser.removeAttribute("origin"); sbrowser.removeAttribute("origin");
sbrowser.setAttribute("src", "about:blank"); sbrowser.setAttribute("src", "about:blank");
@ -989,6 +1009,7 @@ SocialSidebar = {
else else
SocialSidebar.update(); SocialSidebar.update();
this.saveWindowState(); this.saveWindowState();
Services.telemetry.getHistogramById("SOCIAL_SIDEBAR_STATE").add(true);
}, },
hide: function() { hide: function() {
@ -998,6 +1019,7 @@ SocialSidebar = {
this.clearProviderMenus(); this.clearProviderMenus();
SocialSidebar.update(); SocialSidebar.update();
this.saveWindowState(); this.saveWindowState();
Services.telemetry.getHistogramById("SOCIAL_SIDEBAR_STATE").add(false);
}, },
toggleSidebar: function SocialSidebar_toggle() { 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) { showPopup: function(aToolbarButton) {
// attach our notification panel if necessary // attach our notification panel if necessary
let origin = aToolbarButton.getAttribute("origin"); let origin = aToolbarButton.getAttribute("origin");
let provider = Social._getProviderFromOrigin(origin); let provider = Social._getProviderFromOrigin(origin);
PanelFrame.showPopup(window, PanelUI, aToolbarButton, "social", 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) { setPanelErrorMessage: function(aNotificationFrame) {

View File

@ -235,6 +235,7 @@
setTimeout(() => { setTimeout(() => {
panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false); panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false);
}, 0); }, 0);
Services.telemetry.getHistogramById("SOCIAL_TOOLBAR_BUTTONS").add(2);
]]></body> ]]></body>
</method> </method>
@ -330,6 +331,9 @@
this.setAttribute("image", uri.spec); this.setAttribute("image", uri.spec);
} }
break; break;
case "click":
Services.telemetry.getHistogramById("SOCIAL_PANEL_CLICKS").add(2);
break;
} }
]]></body> ]]></body>
</method> </method>
@ -338,6 +342,7 @@
<handlers> <handlers>
<handler event="popupshowing"><![CDATA[ <handler event="popupshowing"><![CDATA[
this._anchor.setAttribute("open", "true"); this._anchor.setAttribute("open", "true");
this.content.addEventListener("click", this);
]]></handler> ]]></handler>
<handler event="popupshown"><![CDATA[ <handler event="popupshown"><![CDATA[
this.onShown(); this.onShown();
@ -346,6 +351,7 @@
this.dispatchPanelEvent("socialFrameHide"); this.dispatchPanelEvent("socialFrameHide");
this._anchor.removeAttribute("open"); this._anchor.removeAttribute("open");
this.update(); this.update();
this.content.removeEventListener("click", this);
]]></handler> ]]></handler>
<handler event="command"><![CDATA[ <handler event="command"><![CDATA[
this.markCurrentPage(); this.markCurrentPage();

View File

@ -4517,11 +4517,6 @@
"kind": "flag", "kind": "flag",
"description": "Social has been enabled at least once on the current session" "description": "Social has been enabled at least once on the current session"
}, },
"SOCIAL_TOGGLED": {
"expires_in_version": "never",
"kind": "boolean",
"description": "Social has been toggled to on or off"
},
"ENABLE_PRIVILEGE_EVER_CALLED": { "ENABLE_PRIVILEGE_EVER_CALLED": {
"expires_in_version": "never", "expires_in_version": "never",
"kind": "flag", "kind": "flag",
@ -6564,5 +6559,29 @@
"n_buckets": "100", "n_buckets": "100",
"description": "Scaling percentage for the display where the first window is opened (Linux only)", "description": "Scaling percentage for the display where the first window is opened (Linux only)",
"cpp_guard": "XP_LINUX" "cpp_guard": "XP_LINUX"
},
"SOCIAL_SIDEBAR_STATE": {
"expires_in_version": "never",
"kind": "boolean",
"description": "Social Sidebar state 0: closed, 1: opened. Toggling between providers will result in a higher opened rate."
},
"SOCIAL_TOOLBAR_BUTTONS": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 3,
"description": "Social toolbar button has been used (0:share, 1:status, 2:bookmark)"
},
"SOCIAL_PANEL_CLICKS": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 4,
"description": "Social content has been interacted with (0:share, 1:status, 2:bookmark, 3: sidebar)"
},
"SOCIAL_SIDEBAR_OPEN_DURATION": {
"expires_in_version": "never",
"kind": "exponential",
"high": "10000000",
"n_buckets": 10,
"description": "Sidebar showing: seconds that the sidebar has been opened"
} }
} }