useIssueCounts.tsx 688 B

1234567891011121314151617181920212223242526272829
  1. import {useApiQuery} from 'sentry/utils/queryClient';
  2. import useOrganization from 'sentry/utils/useOrganization';
  3. export type IssueCounts = {string: number};
  4. export function useIssueCounts(eventView, transactions) {
  5. const organization = useOrganization();
  6. const queryParameters = {
  7. query: transactions,
  8. project: eventView.project,
  9. start: eventView.start,
  10. end: eventView.end,
  11. statsPeriod: eventView.statsPeriod,
  12. };
  13. return useApiQuery<IssueCounts[]>(
  14. [
  15. `/organizations/${organization.slug}/issues-count/`,
  16. {
  17. query: queryParameters,
  18. },
  19. ],
  20. {
  21. staleTime: Infinity,
  22. enabled: transactions.length > 0,
  23. }
  24. );
  25. }