From c39367f1bb1b47f89f92011e72363b7897ebcf44 Mon Sep 17 00:00:00 2001 From: Marco Salazar Date: Thu, 25 Apr 2024 17:38:40 -0400 Subject: [PATCH] fix test a different way to preserve old behavior --- .../packages/ui-core/src/app/__tests__/analytics.test.tsx | 1 - .../dagster-ui/packages/ui-core/src/app/analytics.tsx | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/app/__tests__/analytics.test.tsx b/js_modules/dagster-ui/packages/ui-core/src/app/__tests__/analytics.test.tsx index abf9aa24c5343..ae559965aeb15 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/app/__tests__/analytics.test.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/app/__tests__/analytics.test.tsx @@ -58,7 +58,6 @@ describe('Analytics', () => { describe('Event tracking', () => { const Page = () => { - useTrackPageView(); const trackEvent = useTrackEvent(); const onClick = () => { trackEvent('thingClick'); diff --git a/js_modules/dagster-ui/packages/ui-core/src/app/analytics.tsx b/js_modules/dagster-ui/packages/ui-core/src/app/analytics.tsx index 191dac2afd217..422ab08e65202 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/app/analytics.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/app/analytics.tsx @@ -76,12 +76,14 @@ export const useTrackPageView = () => { export const useTrackEvent = () => { const analytics = useAnalytics(); - const pathValues = usePageContext(); + const match = useRouteMatch(); + const {pathname: specificPath} = useLocation(); + const {path} = match; return useCallback( (eventName: string, properties?: Record) => { - analytics.track(eventName, {...properties, ...pathValues}); + analytics.track(eventName, {...properties, path, specificPath}); }, - [analytics, pathValues], + [analytics, path, specificPath], ); };