diff --git a/client/src/telemetry/glean-context.tsx b/client/src/telemetry/glean-context.tsx index b7ea335467ed..b72e278a8211 100644 --- a/client/src/telemetry/glean-context.tsx +++ b/client/src/telemetry/glean-context.tsx @@ -172,14 +172,14 @@ const gleanAnalytics = glean(); const GleanContext = React.createContext(gleanAnalytics); function handleButtonClick(ev: MouseEvent, click: (source: string) => void) { - const button = ev?.target; + const button = (ev?.target as HTMLElement | null)?.closest("button"); if (button instanceof HTMLButtonElement && button.dataset.glean) { click(button.dataset.glean); } } function handleLinkClick(ev: MouseEvent, click: (source: string) => void) { - const anchor = ev?.target; + const anchor = (ev?.target as HTMLElement | null)?.closest("a"); if (anchor instanceof HTMLAnchorElement) { if (anchor.dataset.glean) { click(anchor.dataset.glean);