Skip to content

Commit

Permalink
fix test a different way to preserve old behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
salazarm committed Apr 25, 2024
1 parent 14cfd1c commit c39367f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ describe('Analytics', () => {

describe('Event tracking', () => {
const Page = () => {
useTrackPageView();
const trackEvent = useTrackEvent();
const onClick = () => {
trackEvent('thingClick');
Expand Down
8 changes: 5 additions & 3 deletions js_modules/dagster-ui/packages/ui-core/src/app/analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>) => {
analytics.track(eventName, {...properties, ...pathValues});
analytics.track(eventName, {...properties, path, specificPath});
},
[analytics, pathValues],
[analytics, path, specificPath],
);
};

0 comments on commit c39367f

Please sign in to comment.