Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

495 B
Raw Blame
import { useQuery } from '@tanstack/react-query';
import { useTRPC } from '@/integrations/trpc/react';

export function useCohorts(
  params: { projectId: string; includeCount?: boolean },
  options?: { enabled?: boolean }
) {
  const trpc = useTRPC();
  const query = useQuery(
    trpc.cohort.list.queryOptions(params, {
      enabled:
        !!params.projectId && typeof options?.enabled !== 'undefined'
          ? options.enabled
          : true,
    })
  );
  return query.data ?? [];
}