diff --git a/src/renderer/components/button/button.tsx b/src/renderer/components/button/button.tsx index 06ef563e69..1f92f32563 100644 --- a/src/renderer/components/button/button.tsx +++ b/src/renderer/components/button/button.tsx @@ -7,11 +7,12 @@ import "./button.scss"; import type { ButtonHTMLAttributes } from "react"; import React from "react"; import { cssNames } from "../../utils"; +import type { TooltipDecoratorProps } from "../tooltip"; import { withTooltip } from "../tooltip"; import { withInjectables } from "@ogre-tools/injectable-react"; -import trackEventInjectable from "../../telemetry/track-event.injectable"; +import captureMouseEventInjectable from "../../telemetry/capture-mouse-event.injectable"; interface Dependencies { - track: (e: React.MouseEvent) => void; + captureMouseEvent: (e: React.MouseEvent) => void; } export interface ButtonProps extends ButtonHTMLAttributes { @@ -33,7 +34,7 @@ export interface ButtonProps extends ButtonHTMLAttributes { const NonInjectedButton = withTooltip((props: ButtonProps & Dependencies) => { const { waiting, label, primary, accent, plain, hidden, active, big, - round, outlined, light, children, track, ...btnProps + round, outlined, light, children, captureMouseEvent, ...btnProps } = props; if (hidden) return null; @@ -43,7 +44,7 @@ const NonInjectedButton = withTooltip((props: ButtonProps & Dependencies) => { }); const onClick = (e: React.MouseEvent) => { - track(e); + captureMouseEvent(e); if (btnProps.onClick) { btnProps.onClick(e); @@ -73,12 +74,12 @@ const NonInjectedButton = withTooltip((props: ButtonProps & Dependencies) => { }); -export const Button = withInjectables( +export const Button = withInjectables( NonInjectedButton, { getProps: (di, props) => ({ - track: di.inject(trackEventInjectable), + captureMouseEvent: di.inject(captureMouseEventInjectable), ...props, }), }, diff --git a/src/renderer/components/checkbox/checkbox.tsx b/src/renderer/components/checkbox/checkbox.tsx index 7f92f84719..52a2a8decc 100644 --- a/src/renderer/components/checkbox/checkbox.tsx +++ b/src/renderer/components/checkbox/checkbox.tsx @@ -8,7 +8,7 @@ import React from "react"; import type { SingleOrMany } from "../../utils"; import { cssNames, noop } from "../../utils"; import { withInjectables } from "@ogre-tools/injectable-react"; -import trackWithIdInjectable from "../../telemetry/track-with-id.injectable"; +import captureWithIdInjectable from "../../telemetry/capture-with-id.injectable"; export interface CheckboxProps { className?: string; @@ -58,7 +58,7 @@ export const Checkbox = withInjectables( { getProps: (di, props) => ({ - captureClick: di.inject(trackWithIdInjectable), + captureClick: di.inject(captureWithIdInjectable), ...props, }), }, diff --git a/src/renderer/components/hotbar/hotbar-icon.tsx b/src/renderer/components/hotbar/hotbar-icon.tsx index 221e255f9b..3f2541755a 100644 --- a/src/renderer/components/hotbar/hotbar-icon.tsx +++ b/src/renderer/components/hotbar/hotbar-icon.tsx @@ -18,7 +18,7 @@ import { Tooltip } from "../tooltip"; import type { NormalizeCatalogEntityContextMenu } from "../../catalog/normalize-menu-item.injectable"; import { withInjectables } from "@ogre-tools/injectable-react"; import normalizeCatalogEntityContextMenuInjectable from "../../catalog/normalize-menu-item.injectable"; -import trackWithIdInjectable from "../../../renderer/telemetry/track-with-id.injectable"; +import captureWithIdInjectable from "../../telemetry/capture-with-id.injectable"; export interface HotbarIconProps extends AvatarProps { uid: string; @@ -107,6 +107,6 @@ export const HotbarIcon = withInjectables(NonInje getProps: (di, props) => ({ ...props, normalizeMenuItem: di.inject(normalizeCatalogEntityContextMenuInjectable), - capture: di.inject(trackWithIdInjectable), + capture: di.inject(captureWithIdInjectable), }), }); diff --git a/src/renderer/components/item-object-list/content.tsx b/src/renderer/components/item-object-list/content.tsx index 54cc06de78..6a82e9a460 100644 --- a/src/renderer/components/item-object-list/content.tsx +++ b/src/renderer/components/item-object-list/content.tsx @@ -32,7 +32,7 @@ import userStoreInjectable from "../../../common/user-store/user-store.injectabl import pageFiltersStoreInjectable from "./page-filters/store.injectable"; import type { OpenConfirmDialog } from "../confirm-dialog/open.injectable"; import openConfirmDialogInjectable from "../confirm-dialog/open.injectable"; -import trackWithIdInjectable from "../../../renderer/telemetry/track-with-id.injectable"; +import captureWithIdInjectable from "../../telemetry/capture-with-id.injectable"; export interface ItemListLayoutContentProps { getFilters: () => Filter[]; @@ -113,7 +113,9 @@ class NonInjectedItemListLayoutContent< sortItem={item} selected={detailsItem && detailsItem.getId() === item.getId()} onClick={hasDetailsView ? prevDefault(() => { - this.props.capture(this.props.tableId, "Table Row Click"); + if (this.props.tableId) { + this.props.capture(this.props.tableId, "Table Row Click"); + } return onDetails?.(item); }) : undefined} @@ -387,6 +389,6 @@ export const ItemListLayoutContent = withInjectables(props: ItemListLayoutContentProps) => React.ReactElement; diff --git a/src/renderer/components/layout/close-button.tsx b/src/renderer/components/layout/close-button.tsx index 023fa2e7ac..cdad8d6dfa 100644 --- a/src/renderer/components/layout/close-button.tsx +++ b/src/renderer/components/layout/close-button.tsx @@ -9,7 +9,7 @@ import type { HTMLAttributes } from "react"; import React from "react"; import { Icon } from "../icon"; import { withInjectables } from "@ogre-tools/injectable-react"; -import trackWithIdInjectable from "../../telemetry/track-with-id.injectable"; +import captureWithIdInjectable from "../../telemetry/capture-with-id.injectable"; export interface CloseButtonProps extends HTMLAttributes { } @@ -26,7 +26,7 @@ function NonInjectedCloseButton(props: CloseButtonProps & Dependencies) { {...rest} onClick={(e) => { capture(`${window.location.pathname}`, "Close Button Click"); - props?.onClick(e); + props?.onClick?.(e); }}>
( { getProps: (di, props) => ({ - capture: di.inject(trackWithIdInjectable), + capture: di.inject(captureWithIdInjectable), ...props, }), }, diff --git a/src/renderer/components/layout/sidebar-item.tsx b/src/renderer/components/layout/sidebar-item.tsx index 7439255181..25735831f2 100644 --- a/src/renderer/components/layout/sidebar-item.tsx +++ b/src/renderer/components/layout/sidebar-item.tsx @@ -16,7 +16,7 @@ import { withInjectables } from "@ogre-tools/injectable-react"; import type { SidebarStorageState } from "./sidebar-storage/sidebar-storage.injectable"; import sidebarStorageInjectable from "./sidebar-storage/sidebar-storage.injectable"; import type { HierarchicalSidebarItem } from "./sidebar-items.injectable"; -import trackWithIdInjectable from "../../../renderer/telemetry/track-with-id.injectable"; +import captureWithIdInjectable from "../../telemetry/capture-with-id.injectable"; interface Dependencies { sidebarStorage: StorageLayer; @@ -98,7 +98,9 @@ class NonInjectedSidebarItem extends React.Component< event.preventDefault(); event.stopPropagation(); - this.props.capture(this.registration.title.toString(), "Click Side Bar Item"); + if (this.registration.title) { + this.props.capture(this.registration.title.toString(), "Click Side Bar Item"); + } if (this.isExpandable) { this.toggleExpand(); @@ -129,7 +131,7 @@ export const SidebarItem = withInjectables(NonIn getProps: (di, props) => ({ ...props, sidebarStorage: di.inject(sidebarStorageInjectable), - capture: di.inject(trackWithIdInjectable), + capture: di.inject(captureWithIdInjectable), }), }); diff --git a/src/renderer/components/layout/tab-layout-2.tsx b/src/renderer/components/layout/tab-layout-2.tsx index 30d88b256e..c37fd9f272 100644 --- a/src/renderer/components/layout/tab-layout-2.tsx +++ b/src/renderer/components/layout/tab-layout-2.tsx @@ -12,7 +12,7 @@ import { Tab, Tabs } from "../tabs"; import { ErrorBoundary } from "../error-boundary"; import type { HierarchicalSidebarItem } from "./sidebar-items.injectable"; import { withInjectables } from "@ogre-tools/injectable-react"; -import trackWithIdInjectable from "../../../renderer/telemetry/track-with-id.injectable"; +import captureWithIdInjectable from "../../telemetry/capture-with-id.injectable"; interface Dependencies { captureClick: (id: string, action: string) => void; @@ -44,7 +44,9 @@ const NonInjectedTabLayout = observer( return ( { - captureClick(registration.title.toString(), "Tab Click"); + if (registration.title) { + captureClick(registration.title.toString(), "Tab Click"); + } registration.onClick(); }} key={registration.id} @@ -73,7 +75,7 @@ export const TabLayout = withInjectables( { getProps: (di, props) => ({ - captureClick: di.inject(trackWithIdInjectable), + captureClick: di.inject(captureWithIdInjectable), ...props, }), }, diff --git a/src/renderer/components/menu/menu.tsx b/src/renderer/components/menu/menu.tsx index 13dce97582..26c6cfafd7 100644 --- a/src/renderer/components/menu/menu.tsx +++ b/src/renderer/components/menu/menu.tsx @@ -14,7 +14,7 @@ import type { IconProps } from "../icon"; import { Icon } from "../icon"; import isEqual from "lodash/isEqual"; import { withInjectables } from "@ogre-tools/injectable-react"; -import trackWithIdInjectable from "../../../renderer/telemetry/track-with-id.injectable"; +import captureWithIdInjectable from "../../telemetry/capture-with-id.injectable"; export const MenuContext = React.createContext(null); export type MenuContextValue = Menu; @@ -436,7 +436,7 @@ class NonInjectedMenuItem extends React.Component // eslint-disable-next-line @typescript-eslint/no-non-null-assertion onClick!(evt); - const name = this.elem.querySelectorAll(".title")[0]?.textContent; + const name = this.elem?.querySelectorAll(".title")[0]?.textContent; if (name) { const id = `${window.location.pathname.split("/").pop()} ${name}`; @@ -493,7 +493,7 @@ export const MenuItem = withInjectables( { getProps: (di, props) => ({ - captureClick: di.inject(trackWithIdInjectable), + captureClick: di.inject(captureWithIdInjectable), ...props, }), }, diff --git a/src/renderer/components/select/select.tsx b/src/renderer/components/select/select.tsx index b549d72247..eb654f784e 100644 --- a/src/renderer/components/select/select.tsx +++ b/src/renderer/components/select/select.tsx @@ -12,12 +12,12 @@ import type { ObservableSet } from "mobx"; import { action, computed, makeObservable } from "mobx"; import { observer } from "mobx-react"; import ReactSelect, { components, createFilter } from "react-select"; -import type { Props as ReactSelectProps, GroupBase, MultiValue, OptionsOrGroups, PropsValue, SingleValue } from "react-select"; +import type { Props as ReactSelectProps, GroupBase, MultiValue, OptionsOrGroups, PropsValue, SingleValue, OnChangeValue, ActionMeta } from "react-select"; import type { ThemeStore } from "../../themes/store"; import { autoBind, cssNames } from "../../utils"; import { withInjectables } from "@ogre-tools/injectable-react"; import themeStoreInjectable from "../../themes/store.injectable"; -import trackWithIdInjectable from "../../telemetry/track-with-id.injectable"; +import captureWithIdInjectable from "../../telemetry/capture-with-id.injectable"; const { Menu } = components; @@ -230,12 +230,12 @@ class NonInjectedSelect< onKeyDown={this.onKeyDown} className={cssNames("Select", this.themeClass, className)} classNamePrefix="Select" - onChange={action(() => { + onChange={action((newValue: OnChangeValue, actionMeta: ActionMeta