useEventJSON.ts 690 B

123456789101112131415161718192021
  1. import type {RawSpanType} from 'sentry/components/events/interfaces/spans/types';
  2. import type {EventTransaction} from 'sentry/types';
  3. import {useApiQuery} from 'sentry/utils/queryClient';
  4. import useOrganization from 'sentry/utils/useOrganization';
  5. interface RawTransactionEvent {
  6. spans: RawSpanType[];
  7. type: 'transaction';
  8. }
  9. export function useEventJSON(
  10. eventID?: EventTransaction['eventID'],
  11. projectSlug?: string
  12. ) {
  13. const organization = useOrganization();
  14. return useApiQuery<RawTransactionEvent>(
  15. [`/projects/${organization.slug}/${projectSlug}/events/${eventID}/json/`],
  16. {staleTime: Infinity, enabled: Boolean(eventID && projectSlug && organization.slug)}
  17. );
  18. }