Skip to content

Commit

Permalink
Fixed metrics search.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed May 4, 2024
1 parent 8be95e3 commit 43907bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "umami",
"version": "2.11.3",
"version": "2.12.0",
"description": "A simple, fast, privacy-focused alternative to Google Analytics.",
"author": "Umami Software, Inc. <hello@umami.is>",
"license": "MIT",
Expand Down
11 changes: 4 additions & 7 deletions src/components/hooks/queries/useWebsiteMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { useFilterParams } from '../useFilterParams';

export function useWebsiteMetrics(
websiteId: string,
type: string,
limit: number,
query: { type: string; limit: number; search: string },
options?: Omit<UseQueryOptions & { onDataLoad?: (data: any) => void }, 'queryKey' | 'queryFn'>,
) {
const { get, useQuery } = useApi();
Expand All @@ -17,19 +16,17 @@ export function useWebsiteMetrics(
{
websiteId,
...params,
type,
limit,
...query,
},
],
queryFn: async () => {
const filters = { ...params };

filters[type] = undefined;
filters[query.type] = undefined;

const data = await get(`/websites/${websiteId}/metrics`, {
...filters,
type,
limit,
...query,
});

options?.onDataLoad?.(data);
Expand Down
12 changes: 8 additions & 4 deletions src/components/metrics/MetricsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ export function MetricsTable({
const { formatMessage, labels } = useMessages();
const { dir } = useLocale();

const { data, isLoading, isFetched, error } = useWebsiteMetrics(websiteId, type, limit, {
retryDelay: delay || DEFAULT_ANIMATION_DURATION,
onDataLoad,
});
const { data, isLoading, isFetched, error } = useWebsiteMetrics(
websiteId,
{ type, limit, search },
{
retryDelay: delay || DEFAULT_ANIMATION_DURATION,
onDataLoad,
},
);

const filteredData = useMemo(() => {
if (data) {
Expand Down

0 comments on commit 43907bd

Please sign in to comment.