Skip to content

Commit

Permalink
fix(telemetry): set page props on click
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Dec 4, 2024
1 parent 72fb3c4 commit 784d46d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions client/src/telemetry/glean-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export type ElementClickedProps = {
};

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";
Expand All @@ -79,7 +79,7 @@ function glean(): GleanAnalytics {
//SSR return noop.
return {
page: (page: PageProps) => () => {},
click: (element: ElementClickedProps) => {},
click: (page: PageProps, element: ElementClickedProps) => {},
};
}
const userIsOptedOut = document.cookie
Expand Down Expand Up @@ -137,7 +137,8 @@ function glean(): GleanAnalytics {
updatePageMetrics(page);
return () => pings.page.submit();
},
click: (event: ElementClickedProps) => {
click: (page: PageProps, event: ElementClickedProps) => {
updatePageMetrics(page);
const { source, subscriptionType: subscription_type } = event;
elementMetric.clicked.record({
source,
Expand Down Expand Up @@ -262,12 +263,12 @@ export function useGleanClick() {
console.log({ gleanClick: source });
}

glean.click({
glean.click(getPageProps(userData), {
source,
subscriptionType: userData?.subscriptionType || "none",
});
},
[glean, userData?.subscriptionType]
[glean, userData]
);
}

Expand Down

0 comments on commit 784d46d

Please sign in to comment.