useTransaction.tsx 806 B

1234567891011121314151617181920212223242526272829
  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 {
  5. TraceTree,
  6. TraceTreeNode,
  7. } from 'sentry/views/performance/newTraceDetails/traceModels/traceTree';
  8. interface UseTransactionProps {
  9. node: TraceTreeNode<TraceTree.Transaction> | null;
  10. organization: Organization;
  11. }
  12. export function useTransaction(props: UseTransactionProps) {
  13. return useApiQuery<EventTransaction>(
  14. [
  15. `/organizations/${props.organization.slug}/events/${props.node?.value?.project_slug}:${props?.node?.value.event_id}/`,
  16. {
  17. query: {
  18. referrer: 'trace-details-summary',
  19. },
  20. },
  21. ],
  22. {
  23. staleTime: 0,
  24. enabled: !!props.node,
  25. }
  26. );
  27. }