diff --git a/src/visits/VisitsStats.tsx b/src/visits/VisitsStats.tsx index c381e300..d2c2a767 100644 --- a/src/visits/VisitsStats.tsx +++ b/src/visits/VisitsStats.tsx @@ -87,13 +87,11 @@ export const VisitsStats: FC = ({ () => processStatsFromVisits(normalizedVisits), [normalizedVisits], ); + const resolvedFilter = useMemo(() => ({ + ...visitsFilter, + excludeBots: visitsFilter.excludeBots ?? settings.visits?.excludeBots, + }), [visitsFilter]); const mapLocations = values(citiesForMap); - const resolvedFilter = useMemo(() => ( - !isFirstLoad.current ? visitsFilter : { - ...visitsFilter, - excludeBots: visitsFilter.excludeBots ?? settings.visits?.excludeBots, - } - ), [visitsFilter]); const setSelectedVisits = (selectedVisits: NormalizedVisit[]) => { selectedBar = undefined; diff --git a/src/visits/helpers/hooks.ts b/src/visits/helpers/hooks.ts index fd647023..1c57d8d7 100644 --- a/src/visits/helpers/hooks.ts +++ b/src/visits/helpers/hooks.ts @@ -6,7 +6,7 @@ import { DateRange, datesToDateRange } from '../../utils/helpers/dateIntervals'; import { OrphanVisitType, VisitsFilter } from '../types'; import { parseQuery, stringifyQuery } from '../../utils/helpers/query'; import { formatIsoDate } from '../../utils/helpers/date'; -import { BooleanString } from '../../utils/utils'; +import { BooleanString, parseBooleanToString } from '../../utils/utils'; interface VisitsQuery { startDate?: string; @@ -47,11 +47,12 @@ export const useVisitsQuery = (): [VisitsFiltering, UpdateFiltering] => { ); const updateFiltering = (extra: DeepPartial) => { const { dateRange, visitsFilter } = mergeDeepRight(filtering, extra); + const { excludeBots, orphanVisitsType } = visitsFilter; const query: VisitsQuery = { startDate: (dateRange?.startDate && formatIsoDate(dateRange.startDate)) || '', endDate: (dateRange?.endDate && formatIsoDate(dateRange.endDate)) || '', - excludeBots: visitsFilter.excludeBots ? 'true' : 'false', - orphanVisitsType: visitsFilter.orphanVisitsType, + excludeBots: excludeBots === undefined ? undefined : parseBooleanToString(excludeBots), + orphanVisitsType, domain: theDomain, }; const stringifiedQuery = stringifyQuery(query);