Skip to content

Commit

Permalink
update onchange
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithadurai committed Oct 8, 2024
1 parent 5cf214e commit 2eb2c7e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
11 changes: 0 additions & 11 deletions static/app/components/organizations/datePageFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import {updateDateTime} from 'sentry/actionCreators/pageFilters';
import type {TimeRangeSelectorProps} from 'sentry/components/timeRangeSelector';
import {TimeRangeSelector} from 'sentry/components/timeRangeSelector';
import {t} from 'sentry/locale';
import {trackAnalytics} from 'sentry/utils/analytics';
import getRouteStringFromRoutes from 'sentry/utils/getRouteStringFromRoutes';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import useRouter from 'sentry/utils/useRouter';

Expand Down Expand Up @@ -36,7 +33,6 @@ export function DatePageFilter({
const {selection, desyncedFilters, isReady: pageFilterIsReady} = usePageFilters();
const {start, end, period, utc} = selection.datetime;
const desynced = desyncedFilters.has('datetime');
const organization = useOrganization();

return (
<TimeRangeSelector
Expand All @@ -53,13 +49,6 @@ export function DatePageFilter({

onChange?.(timePeriodUpdate);

if (getRouteStringFromRoutes(router.routes).includes('dashboardsId')) {
trackAnalytics('dashboards2.filter.change', {
organization,
filter_type: 'day',
});
}

updateDateTime(newTimePeriod, router, {
save: true,
resetParams: resetParamsOnChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ export function EnvironmentPageFilter({
path: getRouteStringFromRoutes(router.routes),
organization,
});
if (getRouteStringFromRoutes(router.routes).includes('dashboardsId')) {
trackAnalytics('dashboards2.filter.change', {
organization,
filter_type: 'environment',
});
}

// Wait for the menu to close before calling onChange
await new Promise(resolve => setTimeout(resolve, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,6 @@ export function ProjectPageFilter({
organization,
multi: allowMultiple,
});
if (getRouteStringFromRoutes(routes).includes('dashboardsId')) {
trackAnalytics('dashboards2.filter.change', {
organization,
filter_type: 'project',
});
}

// Wait for the menu to close before calling onChange
await new Promise(resolve => setTimeout(resolve, 0));
Expand Down
31 changes: 28 additions & 3 deletions static/app/views/dashboards/filtersBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilt
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {defined} from 'sentry/utils';
import {trackAnalytics} from 'sentry/utils/analytics';
import {ToggleOnDemand} from 'sentry/utils/performance/contexts/onDemandControl';
import {decodeList} from 'sentry/utils/queryString';
import {ReleasesProvider} from 'sentry/utils/releases/releasesProvider';
Expand Down Expand Up @@ -53,9 +54,33 @@ export default function FiltersBar({
return (
<Wrapper>
<PageFilterBar condensed>
<ProjectPageFilter disabled={isEditingDashboard} />
<EnvironmentPageFilter disabled={isEditingDashboard} />
<DatePageFilter disabled={isEditingDashboard} />
<ProjectPageFilter
disabled={isEditingDashboard}
onChange={() => {
trackAnalytics('dashboards2.filter.change', {
organization,
filter_type: 'project',
});
}}
/>
<EnvironmentPageFilter
disabled={isEditingDashboard}
onChange={() => {
trackAnalytics('dashboards2.filter.change', {
organization,
filter_type: 'environment',
});
}}
/>
<DatePageFilter
disabled={isEditingDashboard}
onChange={() => {
trackAnalytics('dashboards2.filter.change', {
organization,
filter_type: 'date',
});
}}
/>
</PageFilterBar>
<Fragment>
<FilterButtons>
Expand Down

0 comments on commit 2eb2c7e

Please sign in to comment.