From 3f6bf3b2d73a0454a06a678878ca5e11f2779bb0 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Tue, 3 Dec 2024 13:59:31 +0100 Subject: [PATCH] fix(telemetry): set page props on click --- client/src/telemetry/glean-context.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/client/src/telemetry/glean-context.tsx b/client/src/telemetry/glean-context.tsx index e02b70ef9d78..05a0b9d6ef9b 100644 --- a/client/src/telemetry/glean-context.tsx +++ b/client/src/telemetry/glean-context.tsx @@ -52,12 +52,11 @@ export type PageEventProps = { export type ElementClickedProps = { source: string; - subscriptionType: string; }; export type GleanAnalytics = { - page: (arg: PageProps) => () => void; - click: (arg: ElementClickedProps) => void; + page: (page: PageProps) => () => void; + click: (page: PageProps, element: ElementClickedProps) => void; }; const FIRST_PARTY_DATA_OPT_OUT_COOKIE_NAME = "moz-1st-party-data-opt-out"; @@ -79,7 +78,7 @@ function glean(): GleanAnalytics { //SSR return noop. return { page: (page: PageProps) => () => {}, - click: (element: ElementClickedProps) => {}, + click: (page: PageProps, element: ElementClickedProps) => {}, }; } const userIsOptedOut = document.cookie @@ -137,11 +136,11 @@ function glean(): GleanAnalytics { updatePageMetrics(page); return () => pings.page.submit(); }, - click: (event: ElementClickedProps) => { - const { source, subscriptionType: subscription_type } = event; + click: (page: PageProps, event: ElementClickedProps) => { + updatePageMetrics(page); + const { source } = event; elementMetric.clicked.record({ source, - subscription_type, }); pings.action.submit(); }, @@ -262,12 +261,11 @@ export function useGleanClick() { console.log({ gleanClick: source }); } - glean.click({ + glean.click(getPageProps(userData), { source, - subscriptionType: userData?.subscriptionType || "none", }); }, - [glean, userData?.subscriptionType] + [glean, userData] ); }