index.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. InfiniteData,
  8. UseApiQueryResult,
  9. UseInfiniteQueryResult,
  10. } 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 type {TraceMetaQueryResults} from '../../../traceApi/useTraceMeta';
  15. import {isTraceNode} from '../../../traceGuards';
  16. import type {TraceShape, TraceTree} from '../../../traceModels/traceTree';
  17. import type {TraceTreeNode} from '../../../traceModels/traceTreeNode';
  18. import {IssueList} from '../../details/issues/issues';
  19. import {TraceDrawerComponents} from '../../details/styles';
  20. import {GeneralInfo} from './generalInfo';
  21. import {TagsSummary} from './tagsSummary';
  22. type TraceDetailsProps = {
  23. meta: TraceMetaQueryResults;
  24. node: TraceTreeNode<TraceTree.NodeValue> | null;
  25. rootEventResults: UseApiQueryResult<EventTransaction, RequestError>;
  26. tagsInfiniteQueryResults: UseInfiniteQueryResult<
  27. InfiniteData<ApiResult<Tag[]>, unknown>,
  28. Error
  29. >;
  30. traceEventView: EventView;
  31. traceType: TraceShape;
  32. tree: TraceTree;
  33. };
  34. export function TraceDetails(props: TraceDetailsProps) {
  35. const location = useLocation();
  36. const organization = useOrganization();
  37. const issues = useMemo(() => {
  38. if (!props.node) {
  39. return [];
  40. }
  41. return [...props.node.errors, ...props.node.performance_issues];
  42. // eslint-disable-next-line react-hooks/exhaustive-deps
  43. }, [props.node, props.node?.errors.size, props.node?.performance_issues.size]);
  44. if (!props.node) {
  45. return null;
  46. }
  47. if (!(props.node && isTraceNode(props.node))) {
  48. throw new Error('Expected a trace node');
  49. }
  50. return (
  51. <Fragment>
  52. <IssueList issues={issues} node={props.node} organization={organization} />
  53. <TraceDrawerComponents.SectionCardGroup>
  54. <GeneralInfo
  55. organization={organization}
  56. tree={props.tree}
  57. node={props.node}
  58. rootEventResults={props.rootEventResults}
  59. meta={props.meta}
  60. />
  61. <TagsSummary
  62. tagsInfiniteQueryResults={props.tagsInfiniteQueryResults}
  63. organization={organization}
  64. location={location}
  65. eventView={props.traceEventView}
  66. totalValues={props.tree.eventsCount}
  67. />
  68. </TraceDrawerComponents.SectionCardGroup>
  69. </Fragment>
  70. );
  71. }