Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

645 B
Raw Blame
import { useApi } from '../useApi';

export function useSessionActivityQuery(
  websiteId: string,
  sessionId: string,
  startDate: Date,
  endDate: Date,
  distinctId?: string,
) {
  const { get, useQuery } = useApi();

  return useQuery({
    queryKey: ['session:activity', { websiteId, sessionId, startDate, endDate, distinctId }],
    queryFn: () => {
      return get(`/websites/${websiteId}/sessions/${sessionId}/activity`, {
        startAt: +new Date(startDate),
        endAt: +new Date(endDate),
        ...(distinctId && { distinctId }),
      });
    },
    enabled: Boolean(websiteId && sessionId && startDate && endDate),
  });
}