useTransaction.tsx 865 B

12345678910111213141516171819202122232425262728
  1. import type {EventTransaction} from 'sentry/types/event';
  2. import type {Organization} from 'sentry/types/organization';
  3. import {useApiQuery} from 'sentry/utils/queryClient';
  4. import type {TraceTree} from '../traceModels/traceTree';
  5. import type {TraceTreeNode} from '../traceModels/traceTreeNode';
  6. interface UseTransactionProps {
  7. node: TraceTreeNode<TraceTree.Transaction> | null;
  8. organization: Organization;
  9. }
  10. export function useTransaction(props: UseTransactionProps) {
  11. return useApiQuery<EventTransaction>(
  12. [
  13. `/organizations/${props.organization.slug}/events/${props.node?.value?.project_slug}:${props?.node?.value.event_id}/`,
  14. {
  15. query: {
  16. referrer: 'trace-details-summary',
  17. },
  18. },
  19. ],
  20. {
  21. staleTime: 0,
  22. enabled: !!props.node?.value?.project_slug && !!props.node?.value.event_id,
  23. }
  24. );
  25. }