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.

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

interface ReplayQueryOptions {
  until?: number;
  chunkIndex?: number;
  eventIndex?: number;
}

export function useReplayQuery(
  websiteId: string,
  replayId: string,
  options: ReplayQueryOptions = {},
) {
  const { get, useQuery } = useApi();
  const { until, chunkIndex, eventIndex } = options;

  return useQuery({
    queryKey: ['replay', { websiteId, replayId, until, chunkIndex, eventIndex }],
    queryFn: () => {
      return get(`/websites/${websiteId}/replays/${replayId}`, { until, chunkIndex, eventIndex });
    },
    enabled: Boolean(websiteId && replayId),
  });
}