Skip to content

Commit 2c27a78

Browse files
authored
fix(telemetry): measure link/button clicks properly (#10707)
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.
1 parent e12a0c4 commit 2c27a78

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: client/src/telemetry/glean-context.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ const gleanAnalytics = glean();
172172
const GleanContext = React.createContext(gleanAnalytics);
173173

174174
function handleButtonClick(ev: MouseEvent, click: (source: string) => void) {
175-
const button = ev?.target;
175+
const button = (ev?.target as HTMLElement | null)?.closest("button");
176176
if (button instanceof HTMLButtonElement && button.dataset.glean) {
177177
click(button.dataset.glean);
178178
}
179179
}
180180

181181
function handleLinkClick(ev: MouseEvent, click: (source: string) => void) {
182-
const anchor = ev?.target;
182+
const anchor = (ev?.target as HTMLElement | null)?.closest("a");
183183
if (anchor instanceof HTMLAnchorElement) {
184184
if (anchor.dataset.glean) {
185185
click(anchor.dataset.glean);

0 commit comments

Comments
 (0)