useTraceRootEvent.tsx 825 B

123456789101112131415161718192021222324252627
  1. import type {EventTransaction} from 'sentry/types/event';
  2. import type {
  3. TraceFullDetailed,
  4. TraceSplitResults,
  5. } from 'sentry/utils/performance/quickTrace/types';
  6. import {useApiQuery} from 'sentry/utils/queryClient';
  7. import useOrganization from 'sentry/utils/useOrganization';
  8. export function useTraceRootEvent(trace: TraceSplitResults<TraceFullDetailed> | null) {
  9. const root = trace?.transactions?.[0] || trace?.orphan_errors?.[0];
  10. const organization = useOrganization();
  11. return useApiQuery<EventTransaction>(
  12. [
  13. `/organizations/${organization.slug}/events/${root?.project_slug}:${root?.event_id}/`,
  14. {
  15. query: {
  16. referrer: 'trace-details-summary',
  17. },
  18. },
  19. ],
  20. {
  21. staleTime: 0,
  22. enabled: !!trace && !!root?.project_slug && !!root?.event_id,
  23. }
  24. );
  25. }