Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(ui): track command menu usage (#8115)

Andrew Huang757fbd3ab8d4
diff --git a/frontend/src/components/v3/generic/Command/GlobalCommandMenu.tsx b/frontend/src/components/v3/generic/Command/GlobalCommandMenu.tsx
index 84ef0f024a..432ba5fb1f 100644
--- a/frontend/src/components/v3/generic/Command/GlobalCommandMenu.tsx
+++ b/frontend/src/components/v3/generic/Command/GlobalCommandMenu.tsx
@@ -56,6 +56,11 @@ export type GlobalCommandMenuProps = {
searchGroups?: GlobalCommandMenuGroup[];
searchStatus?: GlobalCommandMenuSearchStatus;
onSearchChange?: (search: string) => void;
+ onItemSelect?: (
+ item: GlobalCommandMenuItem,
+ context: { mode: "browse" | "search" | "drill-down" }
+ ) => void;
+ onShortcutToggle?: (open: boolean) => void;
isEnabled?: boolean;
open?: boolean;
defaultOpen?: boolean;
@@ -162,6 +167,8 @@ export const GlobalCommandMenu = ({
searchGroups = groups,
searchStatus = { state: "idle" },
onSearchChange,
+ onItemSelect,
+ onShortcutToggle,
isEnabled = true,
open: controlledOpen,
defaultOpen = false,
@@ -180,7 +187,7 @@ export const GlobalCommandMenu = ({
const openRef = React.useRef(open);
const invokerRef = React.useRef<HTMLElement | null>(null);
const activeDrilldown = drilldown.at(-1);
- let mode = "browse";
+ let mode: "browse" | "search" | "drill-down" = "browse";
if (search.trim()) mode = "search";
if (activeDrilldown) mode = "drill-down";
@@ -223,12 +230,14 @@ export const GlobalCommandMenu = ({
event.preventDefault();
event.stopPropagation();
- setOpen(!openRef.current);
+ const nextOpen = !openRef.current;
+ setOpen(nextOpen);
+ onShortcutToggle?.(nextOpen);
};
window.addEventListener("keydown", handleKeyDown, true);
return () => window.removeEventListener("keydown", handleKeyDown, true);
- }, [isEnabled, setOpen]);
+ }, [isEnabled, onShortcutToggle, setOpen]);
const goBack = () => {
updateSearch("");
@@ -326,6 +335,8 @@ export const GlobalCommandMenu = ({
keywords={[item.label, item.breadcrumb, ...(item.keywords ?? [])]}
disabled={item.isDisabled}
onSelect={() => {
+ onItemSelect?.(item, { mode });
+
if (item.children) {
updateSearch("");
setDrilldown((current) => [...current, item]);
diff --git a/frontend/src/components/v3/platform/RootCommandMenu/RootCommandMenu.tsx b/frontend/src/components/v3/platform/RootCommandMenu/RootCommandMenu.tsx
index a0f0281c53..1e5322c3e7 100644
--- a/frontend/src/components/v3/platform/RootCommandMenu/RootCommandMenu.tsx
+++ b/frontend/src/components/v3/platform/RootCommandMenu/RootCommandMenu.tsx
@@ -21,6 +21,7 @@ import {
UsersIcon
} from "lucide-react";
+import Telemetry from "@app/components/utilities/telemetry/Telemetry";
import {
GlobalCommandMenu,
type GlobalCommandMenuGroup,
@@ -82,6 +83,24 @@ type AsyncCommandSearch = {
onSearchChange: (search: string) => void;
};
+const COMMAND_MENU_EVENTS = {
+ Opened: "Command Menu Opened",
+ ActionSelected: "Command Menu Action Selected"
+} as const;
+
+const PRIVATE_ACTION_TYPES = [
+ ["entity-project-", "Project"],
+ ["entity-organization-", "Organization"],
+ ["entity-team-", "Team"],
+ ["project-resource-folder-", "Folder"],
+ ["project-resource-dynamic-", "Dynamic Secret"],
+ ["project-resource-rotation-", "Secret Rotation"],
+ ["project-resource-secret-", "Secret"]
+] as const;
+
+const getCommandMenuAction = ({ id, label }: Pick<GlobalCommandMenuItem, "id" | "label">) =>
+ PRIVATE_ACTION_TYPES.find(([prefix]) => id.startsWith(prefix))?.[1] ?? label;
+
const projectIconClassNames: Record<ProjectType, string> = {
[ProjectType.SecretManager]: "text-product-sm",
[ProjectType.CertificateManager]: "text-product-pki",
@@ -92,28 +111,47 @@ const projectIconClassNames: Record<ProjectType, string> = {
};
const NavigationCommandMenu = ({
+ shell,
browseGroups,
searchGroups,
searchStatus,
asyncSearch
}: CommandContent & {
+ shell: RootCommandMenuShell;
asyncSearch?: AsyncCommandSearch;
-}) => (
- <GlobalCommandMenu
- groups={browseGroups}
- searchGroups={[...searchGroups, ...(asyncSearch?.groups ?? [])]}
- searchStatus={
- [searchStatus, asyncSearch?.searchStatus].find((status) => status?.state === "loading") ??
- [searchStatus, asyncSearch?.searchStatus].find((status) => status?.state === "error")
- }
- onSearchChange={asyncSearch?.onSearchChange}
- title="Search Infisical"
- description="Search pages, projects, organizations, teams, and commands."
- placeholder="Find..."
- emptyMessage="No matching pages or commands."
- showFooter={false}
- />
-);
+}) => {
+ const telemetry = new Telemetry().getInstance();
+
+ return (
+ <GlobalCommandMenu
+ groups={browseGroups}
+ searchGroups={[...searchGroups, ...(asyncSearch?.groups ?? [])]}
+ searchStatus={
+ [searchStatus, asyncSearch?.searchStatus].find((status) => status?.state === "loading") ??
+ [searchStatus, asyncSearch?.searchStatus].find((status) => status?.state === "error")
+ }
+ onSearchChange={asyncSearch?.onSearchChange}
+ onShortcutToggle={(open) => {
+ if (open) {
+ telemetry.capture(COMMAND_MENU_EVENTS.Opened, { shell, source: "keyboard-shortcut" });
+ }
+ }}
+ onItemSelect={(item, { mode }) => {
+ telemetry.capture(COMMAND_MENU_EVENTS.ActionSelected, {
+ shell,
+ mode,
+ action: getCommandMenuAction(item),
+ actionType: item.children ? "drill-down" : "navigation"
+ });
+ }}
+ title="Search Infisical"
+ description="Search pages, projects, organizations, teams, and commands."
+ placeholder="Find..."
+ emptyMessage="No matching pages or commands."
+ showFooter={false}
+ />
+ );
+};
const navigateToProject = (
navigate: ReturnType<typeof useNavigate>,
@@ -353,6 +391,7 @@ const PersonalSettingsCommandMenu = () => {
return (
<NavigationCommandMenu
+ shell="personal-settings"
searchStatus={entityGroups.searchStatus}
browseGroups={[{ heading: "Account", items: accountItems }, nestedGroup]}
searchGroups={[
@@ -407,6 +446,7 @@ const AdminCommandMenu = () => {
return (
<NavigationCommandMenu
+ shell="admin"
searchStatus={entityGroups.searchStatus}
browseGroups={[
{ heading: "Server Console", items: adminItems },
@@ -914,6 +954,7 @@ const CertificateProjectCommandMenu = ({
return (
<NavigationCommandMenu
+ shell="organization"
searchStatus={content.searchStatus}
browseGroups={[
{ heading: currentProject.name, items: projectItems.slice(0, 2) },
@@ -936,6 +977,7 @@ const SecretManagerProjectCommandMenu = ({
return (
<NavigationCommandMenu
+ shell="organization"
searchStatus={content.searchStatus}
browseGroups={[
{ heading: currentProject.name, items: projectItems.slice(0, 2) },
@@ -980,6 +1022,7 @@ const CurrentProjectCommandMenu = ({ content }: { content: CommandContent }) =>
return (
<NavigationCommandMenu
+ shell="organization"
searchStatus={content.searchStatus}
browseGroups={[
{ heading: currentProject.name, items: projectItems.slice(0, 2) },
@@ -1062,7 +1105,7 @@ const OrganizationCommandMenu = () => {
]
};
if (projectId || orgScopedProduct) return <CurrentProjectCommandMenu content={content} />;
- return <NavigationCommandMenu {...content} />;
+ return <NavigationCommandMenu shell="organization" {...content} />;
};
export const RootCommandMenu = ({ shell }: { shell: RootCommandMenuShell }) => {