Skip to content

Commit

Permalink
fix(telemetry): measure link/button clicks properly (#10707)
Browse files Browse the repository at this point in the history
We assumed that the click happens on the element with data-glean,
but this is not the case if the click happens on a child of the link/button.
  • Loading branch information
caugner authored Mar 14, 2024
1 parent e12a0c4 commit 2c27a78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/src/telemetry/glean-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2c27a78

Please sign in to comment.