mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Merge remote-tracking branch 'origin/dev' into dev
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run
This commit is contained in:
commit
97ebdc1bab
8 changed files with 67 additions and 70 deletions
|
|
@ -1,34 +1,13 @@
|
|||
import { useTimezone } from '@/components/hooks/useTimezone';
|
||||
import { REALTIME_INTERVAL } from '@/lib/constants';
|
||||
import { useApi } from '../useApi';
|
||||
|
||||
export interface RealtimeData {
|
||||
countries: Record<string, number>;
|
||||
events: any[];
|
||||
pageviews: any[];
|
||||
referrers: Record<string, number>;
|
||||
timestamp: number;
|
||||
series: {
|
||||
views: any[];
|
||||
visitors: any[];
|
||||
};
|
||||
totals: {
|
||||
views: number;
|
||||
visitors: number;
|
||||
events: number;
|
||||
countries: number;
|
||||
};
|
||||
urls: Record<string, number>;
|
||||
visitors: any[];
|
||||
}
|
||||
import { RealtimeData } from '@/lib/types';
|
||||
|
||||
export function useRealtimeQuery(websiteId: string) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { timezone } = useTimezone();
|
||||
const { data, isLoading, error } = useQuery<RealtimeData>({
|
||||
queryKey: ['realtime', { websiteId, timezone }],
|
||||
queryKey: ['realtime', { websiteId }],
|
||||
queryFn: async () => {
|
||||
return get(`/realtime/${websiteId}`, { timezone });
|
||||
return get(`/realtime/${websiteId}`);
|
||||
},
|
||||
enabled: !!websiteId,
|
||||
refetchInterval: REALTIME_INTERVAL,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue