Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(telemetry): measure menu clicks #9918

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions client/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export const BANNER_AI_HELP_CLICK = "banner_ai_help_click";
export const PLAYGROUND = "play_action";
export const AI_EXPLAIN = "ai_explain";

export const MENU = Object.freeze({
CLICK_MENU: "menu_click_menu",
CLICK_SUBMENU: "menu_click_submenu",
});

export const PLUS_COLLECTIONS = Object.freeze({
ACTIONS_NOTE_ADD: "collections_actions_note_add",
ACTIONS_NOTE_EDIT: "collections_actions_note_edit",
Expand Down
11 changes: 9 additions & 2 deletions client/src/ui/molecules/menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { MENU } from "../../../telemetry/constants";
import { useGleanClick } from "../../../telemetry/glean-context";
import { MenuEntry, Submenu } from "../submenu";
import "./index.scss";

Expand All @@ -8,6 +10,8 @@ interface MenuProps {
}

export const Menu = ({ menu, isOpen, toggle }: MenuProps) => {
const gleanClick = useGleanClick();

const buttonId = `${menu.id}-button`;
const submenuId = `${menu.id}-menu`;

Expand Down Expand Up @@ -35,8 +39,11 @@ export const Menu = ({ menu, isOpen, toggle }: MenuProps) => {
<a
href={menu.to}
className="top-level-entry"
// @ts-ignore
onClick={() => document?.activeElement?.blur()}
onClick={() => {
gleanClick(`${MENU.CLICK_MENU}: ${menu.id} -> ${menu.to}`);
// @ts-ignore
document?.activeElement?.blur();
}}
>
{menu.label}
</a>
Expand Down
8 changes: 8 additions & 0 deletions client/src/ui/molecules/submenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { MENU } from "../../../telemetry/constants";
import { useGleanClick } from "../../../telemetry/glean-context";
import "./index.scss";

export type SubmenuItem = {
Expand Down Expand Up @@ -32,6 +34,7 @@ export const Submenu = ({
submenuId?: string;
extraClasses?: string;
}) => {
const gleanClick = useGleanClick();
return (
<ul
id={submenuId}
Expand All @@ -58,6 +61,11 @@ export const Submenu = ({
className={`submenu-item ${
item.url.startsWith("https://") ? "external" : ""
}`}
onClick={() =>
gleanClick(
`${MENU.CLICK_SUBMENU}: ${menuEntry.id} -> ${item.url}`
)
}
>
{item.hasIcon && <div className={item.iconClasses} />}
{item.dot && (
Expand Down