traceDataSection.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {t} from 'sentry/locale';
  4. import {space} from 'sentry/styles/space';
  5. import type {Event} from 'sentry/types/event';
  6. import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
  7. import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
  8. import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
  9. import {useHasStreamlinedUI} from 'sentry/views/issueDetails/utils';
  10. import {TraceIssueEvent} from './traceTimeline/traceIssue';
  11. import {TraceLink} from './traceTimeline/traceLink';
  12. import {TraceTimeline} from './traceTimeline/traceTimeline';
  13. import {useTraceTimelineEvents} from './traceTimeline/useTraceTimelineEvents';
  14. export function TraceDataSection({event}: {event: Event}) {
  15. const hasStreamlinedUI = useHasStreamlinedUI();
  16. // This is also called within the TraceTimeline component but caching will save a second call
  17. const {isLoading, oneOtherIssueEvent} = useTraceTimelineEvents({
  18. event,
  19. });
  20. let params: Record<string, boolean> = {};
  21. if (!isLoading && oneOtherIssueEvent !== undefined) {
  22. params = {
  23. has_related_trace_issue: true,
  24. };
  25. }
  26. useRouteAnalyticsParams(params);
  27. if (isLoading) {
  28. return null;
  29. }
  30. const traceContent = (
  31. <Fragment>
  32. <StyledTraceLink>
  33. {/* Used for trace-related issue */}
  34. {oneOtherIssueEvent && (
  35. <span>{t('One other issue appears in the same trace.')}</span>
  36. )}
  37. <TraceLink event={event} />
  38. </StyledTraceLink>
  39. {oneOtherIssueEvent === undefined ? (
  40. <TraceTimeline event={event} />
  41. ) : (
  42. <TraceIssueEvent event={oneOtherIssueEvent} />
  43. )}
  44. </Fragment>
  45. );
  46. return hasStreamlinedUI ? (
  47. <InterimSection title={t('Trace Connections')} type={SectionKey.TRACE}>
  48. {traceContent}
  49. </InterimSection>
  50. ) : (
  51. traceContent
  52. );
  53. }
  54. const StyledTraceLink = styled('div')`
  55. display: flex;
  56. white-space: nowrap;
  57. overflow: hidden;
  58. gap: ${space(0.25)};
  59. `;