Skip to content

Commit 5b3cae9

Browse files
committed
fix(metrics): distinguish app menu clicks from context menus
Record application menu commands under appMenu.click while retaining UIMenu.click for context menus and menus without an explicit metric type. Inherit the owning menu namespace through nested submenus and compact-menu flyouts so each command is attributed to the menu that invoked it.
1 parent bec4521 commit 5b3cae9

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/command/Menus.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ define(function (require, exports, module) {
455455
*/
456456
function Menu(id) {
457457
this.id = id;
458+
// Submenus inherit their owner's namespace even though they render as context menus.
459+
this._metricsEventType = Metrics.EVENT_TYPE.APP_MENU;
458460
}
459461

460462
Menu.prototype._getMenuItemId = function (commandId) {
@@ -733,7 +735,7 @@ define(function (require, exports, module) {
733735
event.stopPropagation();
734736
return true;
735737
}
736-
Metrics.countEvent(Metrics.EVENT_TYPE.UI_MENU, "click", menuItem._command.getID());
738+
Metrics.countEvent(self._metricsEventType || Metrics.EVENT_TYPE.UI_MENU, "click", menuItem._command.getID());
737739
logger.leaveTrail("UI Menu Click: " + menuItem._command.getID());
738740
MainViewManager.focusActivePane();
739741
const commandId = menuItem._command.getID();
@@ -909,6 +911,7 @@ define(function (require, exports, module) {
909911
}
910912

911913
let menu = new ContextMenu(id);
914+
menu._metricsEventType = this._metricsEventType;
912915
contextMenuMap[id] = menu;
913916

914917
let menuItemID = this.id + "-" + id;
@@ -1544,6 +1547,7 @@ define(function (require, exports, module) {
15441547
*/
15451548
function ContextMenu(id) {
15461549
Menu.apply(this, arguments);
1550+
this._metricsEventType = Metrics.EVENT_TYPE.UI_MENU;
15471551

15481552
let $newMenu = $("<li class='dropdown context-menu' id='" + StringUtils.jQueryIdEscape(id) + "'></li>"),
15491553
$popUp = $("<ul class='dropdown-menu'></ul>"),

‎src/utils/Metrics.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ define(function (require, exports, module) {
9292
* The Type of events that can be specified as an `eventType` in the API calls.
9393
*
9494
* ### Properties
95-
* `PLATFORM`, `PROJECT`, `THEMES`, `EXTENSIONS`, `EXTENSIONS`, `UI`, `UI_DIALOG`, `UI_BOTTOM_PANEL`,
96-
* `UI_SIDE_PANEL`, `LIVE_PREVIEW`, `CODE_HINTS`, `EDITOR`, `SEARCH`, `SHARING`, `PERFORMANCE`, `NEW_PROJECT`
95+
* `PLATFORM`, `PROJECT`, `THEMES`, `EXTENSIONS`, `EXTENSIONS`, `UI`, `APP_MENU`, `UI_MENU`, `UI_DIALOG`,
96+
* `UI_BOTTOM_PANEL`, `UI_SIDE_PANEL`, `LIVE_PREVIEW`, `CODE_HINTS`, `EDITOR`, `SEARCH`, `SHARING`,
97+
* `PERFORMANCE`, `NEW_PROJECT`
9798
* `ERROR`, `USER`, `NODEJS`, `LINT`, `GIT`, `AUTH`, `PRO`, `GUIDE`
9899
*
99100
* @typedef EVENT_TYPE
@@ -106,6 +107,7 @@ define(function (require, exports, module) {
106107
EXTENSIONS: "extensions",
107108
NOTIFICATIONS: "notify",
108109
UI: "UI",
110+
APP_MENU: "appMenu",
109111
UI_MENU: "UIMenu",
110112
UI_DIALOG: "ui-dialog",
111113
UI_BOTTOM_PANEL: "ui-bottomPanel",

0 commit comments

Comments
 (0)