index.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import {Fragment, useMemo} from 'react';
  2. import type {Tag} from 'sentry/actionCreators/events';
  3. import type {ApiResult} from 'sentry/api';
  4. import type {EventTransaction} from 'sentry/types/event';
  5. import type EventView from 'sentry/utils/discover/eventView';
  6. import type {
  7. TraceFullDetailed,
  8. TraceSplitResults,
  9. } from 'sentry/utils/performance/quickTrace/types';
  10. import type {UseApiQueryResult, UseInfiniteQueryResult} from 'sentry/utils/queryClient';
  11. import type RequestError from 'sentry/utils/requestError/requestError';
  12. import {useLocation} from 'sentry/utils/useLocation';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. import {TraceWarnings} from 'sentry/views/performance/newTraceDetails/traceWarnings';
  15. import {isTraceNode} from '../../../guards';
  16. import type {TraceMetaQueryResults} from '../../../traceApi/useTraceMeta';
  17. import type {TraceTree, TraceTreeNode} from '../../../traceModels/traceTree';
  18. import type {TraceType} from '../../../traceType';
  19. import {IssueList} from '../../details/issues/issues';
  20. import {TraceDrawerComponents} from '../../details/styles';
  21. import {GeneralInfo} from './generalInfo';
  22. import {TagsSummary} from './tagsSummary';
  23. type TraceDetailsProps = {
  24. metaResults: TraceMetaQueryResults;
  25. node: TraceTreeNode<TraceTree.NodeValue> | null;
  26. rootEventResults: UseApiQueryResult<EventTransaction, RequestError>;
  27. tagsInfiniteQueryResults: UseInfiniteQueryResult<ApiResult<Tag[]>, unknown>;
  28. traceEventView: EventView;
  29. traceType: TraceType;
  30. traces: TraceSplitResults<TraceFullDetailed> | null;
  31. tree: TraceTree;
  32. };
  33. export function TraceDetails(props: TraceDetailsProps) {
  34. const location = useLocation();
  35. const organization = useOrganization();
  36. const issues = useMemo(() => {
  37. if (!props.node) {
  38. return [];
  39. }
  40. return [...props.node.errors, ...props.node.performance_issues];
  41. // eslint-disable-next-line react-hooks/exhaustive-deps
  42. }, [props.node, props.node?.errors.size, props.node?.performance_issues.size]);
  43. if (!props.node) {
  44. return null;
  45. }
  46. if (!(props.node && isTraceNode(props.node))) {
  47. throw new Error('Expected a trace node');
  48. }
  49. return (
  50. <Fragment>
  51. {props.tree.type === 'trace' ? <TraceWarnings type={props.traceType} /> : null}
  52. <IssueList issues={issues} node={props.node} organization={organization} />
  53. <TraceDrawerComponents.SectionCardGroup>
  54. <GeneralInfo
  55. organization={organization}
  56. traces={props.traces}
  57. tree={props.tree}
  58. node={props.node}
  59. rootEventResults={props.rootEventResults}
  60. metaResults={props.metaResults}
  61. />
  62. <TagsSummary
  63. tagsInfiniteQueryResults={props.tagsInfiniteQueryResults}
  64. organization={organization}
  65. location={location}
  66. eventView={props.traceEventView}
  67. totalValues={props.tree.eventsCount}
  68. />
  69. </TraceDrawerComponents.SectionCardGroup>
  70. </Fragment>
  71. );
  72. }