Skip to content

Commit 3f6bf3b

Browse files
committed
fix(telemetry): set page props on click
1 parent 72fb3c4 commit 3f6bf3b

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

client/src/telemetry/glean-context.tsx

+8-10
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ export type PageEventProps = {
5252

5353
export type ElementClickedProps = {
5454
source: string;
55-
subscriptionType: string;
5655
};
5756

5857
export type GleanAnalytics = {
59-
page: (arg: PageProps) => () => void;
60-
click: (arg: ElementClickedProps) => void;
58+
page: (page: PageProps) => () => void;
59+
click: (page: PageProps, element: ElementClickedProps) => void;
6160
};
6261

6362
const FIRST_PARTY_DATA_OPT_OUT_COOKIE_NAME = "moz-1st-party-data-opt-out";
@@ -79,7 +78,7 @@ function glean(): GleanAnalytics {
7978
//SSR return noop.
8079
return {
8180
page: (page: PageProps) => () => {},
82-
click: (element: ElementClickedProps) => {},
81+
click: (page: PageProps, element: ElementClickedProps) => {},
8382
};
8483
}
8584
const userIsOptedOut = document.cookie
@@ -137,11 +136,11 @@ function glean(): GleanAnalytics {
137136
updatePageMetrics(page);
138137
return () => pings.page.submit();
139138
},
140-
click: (event: ElementClickedProps) => {
141-
const { source, subscriptionType: subscription_type } = event;
139+
click: (page: PageProps, event: ElementClickedProps) => {
140+
updatePageMetrics(page);
141+
const { source } = event;
142142
elementMetric.clicked.record({
143143
source,
144-
subscription_type,
145144
});
146145
pings.action.submit();
147146
},
@@ -262,12 +261,11 @@ export function useGleanClick() {
262261
console.log({ gleanClick: source });
263262
}
264263

265-
glean.click({
264+
glean.click(getPageProps(userData), {
266265
source,
267-
subscriptionType: userData?.subscriptionType || "none",
268266
});
269267
},
270-
[glean, userData?.subscriptionType]
268+
[glean, userData]
271269
);
272270
}
273271

0 commit comments

Comments
 (0)