--- a/browser/components/touchbar/MacTouchBar.js
+++ b/browser/components/touchbar/MacTouchBar.js
@@ -6,17 +6,20 @@ ChromeUtils.import("resource://gre/modul
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
});
-function execCommand(aCommandName) {
+function execCommand(aCommandName, aTelemetryKey) {
+ let telemetry =
+ Services.telemetry.getHistogramById("TOUCHBAR_BUTTON_PRESSES");
+ telemetry.add(aTelemetryKey);
let win = BrowserWindowTracker.getTopWindow();
let command = win.document.getElementById(aCommandName);
if (command) {
command.doCommand();
}
}
/**
@@ -37,84 +40,84 @@ TouchBarHelper.prototype = {
/**
* An object containing all implemented TouchBarInput objects.
*/
_implementedInputs: {
"Back": {
title: "back",
image: "back.pdf",
type: "button",
- callback: () => execCommand("Browser:Back")
+ callback: () => execCommand("Browser:Back", "Back")
},
"Forward": {
title: "forward",
image: "forward.pdf",
type: "button",
- callback: () => execCommand("Browser:Forward"),
+ callback: () => execCommand("Browser:Forward", "Forward"),
},
"Reload": {
title: "reload",
image: "refresh.pdf",
type: "button",
- callback: () => execCommand("Browser:Reload"),
+ callback: () => execCommand("Browser:Reload", "Reload"),
},
"Home": {
title: "home",
image: "home.pdf",
type: "button",
- callback: () => execCommand("Browser:Home"),
+ callback: () => execCommand("Browser:Home", "Home"),
},
"Fullscreen": {
title: "fullScreen",
image: "fullscreen.pdf",
type: "button",
- callback: () => execCommand("View:FullScreen"),
+ callback: () => execCommand("View:FullScreen", "Fullscreen"),
},
"Find": {
title: "find",
image: "search.pdf",
type: "button",
- callback: () => execCommand("cmd_find"),
+ callback: () => execCommand("cmd_find", "Find"),
},
"NewTab": {
title: "newTab",
image: "new.pdf",
type: "button",
- callback: () => execCommand("cmd_newNavigatorTabNoEvent"),
+ callback: () => execCommand("cmd_newNavigatorTabNoEvent", "NewTab"),
},
"Sidebar": {
title: "openBookmarksSidebar",
image: "sidebar-left.pdf",
type: "button",
- callback: () => execCommand("viewBookmarksSidebar"),
+ callback: () => execCommand("viewBookmarksSidebar", "Sidebar"),
},
"AddBookmark": {
title: "addBookmark",
image: "bookmark.pdf",
type: "button",
- callback: () => execCommand("Browser:AddBookmarkAs"),
+ callback: () => execCommand("Browser:AddBookmarkAs", "AddBookmark"),
},
"ReaderView": {
title: "readerView",
image: "reader-mode.pdf",
type: "button",
- callback: () => execCommand("View:ReaderView"),
+ callback: () => execCommand("View:ReaderView", "ReaderView"),
disabled: true, // Updated when the page is found to be Reader View-able
},
"OpenLocation": {
title: "openLocation",
image: "search.pdf",
type: "mainButton",
- callback: () => execCommand("Browser:OpenLocation"),
+ callback: () => execCommand("Browser:OpenLocation", "OpenLocation"),
},
"Focus": {
title: "focus",
image: "private-browsing.pdf",
type: "mainButton",
- callback: () => execCommand("cmd_closeWindow"),
+ callback: () => execCommand("cmd_closeWindow", "Focus"),
color: "#8000D7",
context: () => {
let name;
if (PrivateBrowsingUtils.isWindowPrivate(
BrowserWindowTracker.getTopWindow())) {
name = "Focus";
}
return name;
@@ -134,17 +137,17 @@ TouchBarHelper.prototype = {
},
},
// This is a special-case `type: "scrubber"` element.
// Scrubbers are not yet generally implemented.
"Share": {
title: "share",
type: "scrubber",
image: "share.pdf",
- callback: () => execCommand("cmd_share"),
+ callback: () => execCommand("cmd_share", "Share"),
},
},
get activeTitle() {
let tabbrowser = this.window.ownerGlobal.gBrowser;
let activeTitle;
if (tabbrowser) {
activeTitle = tabbrowser.selectedBrowser.contentTitle;
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -13891,10 +13891,20 @@
"record_in_processes": ["main", "gpu"],
"alert_emails": ["kgupta@mozilla.com"],
"bug_numbers": [1470901],
"expires_in_version": "never",
"kind": "exponential",
"high": 1000,
"n_buckets": 50,
"description": "WebRender render time in milliseconds"
+ },
+ "TOUCHBAR_BUTTON_PRESSES": {
+ "record_in_processes": ["main"],
+ "alert_emails": ["htwyford@mozilla.com"],
+ "bug_numbers": [1313429],
+ "expires_in_version": "65",
+ "kind": "categorical",
+ "labels": ["Back", "Forward", "Reload", "Home", "Fullscreen", "Find", "NewTab", "ReaderView", "AddBookmark", "OpenLocation", "Focus", "Share", "Sidebar"],
+ "releaseChannelCollection": "opt-out",
+ "description": "What buttons are pressed most often on the Mac Touch Bar?"
}
}