stackTrace.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import EmptyMessage from 'sentry/components/emptyMessage';
  2. import type {StacktraceFilenameQuery} from 'sentry/components/events/interfaces/crashContent/exception/useSourceMapDebug';
  3. import Panel from 'sentry/components/panels/panel';
  4. import {IconWarning} from 'sentry/icons';
  5. import {t} from 'sentry/locale';
  6. import {ExceptionValue, Group, PlatformType} from 'sentry/types';
  7. import {Event} from 'sentry/types/event';
  8. import {StackView} from 'sentry/types/stacktrace';
  9. import {defined} from 'sentry/utils';
  10. import {isNativePlatform} from 'sentry/utils/platform';
  11. import StackTraceContent from '../stackTrace/content';
  12. import {HierarchicalGroupingContent} from '../stackTrace/hierarchicalGroupingContent';
  13. import {NativeContent} from '../stackTrace/nativeContent';
  14. type Props = {
  15. chainedException: boolean;
  16. data: ExceptionValue['stacktrace'];
  17. event: Event;
  18. hasHierarchicalGrouping: boolean;
  19. platform: PlatformType;
  20. stacktrace: ExceptionValue['stacktrace'];
  21. debugFrames?: StacktraceFilenameQuery[];
  22. expandFirstFrame?: boolean;
  23. groupingCurrentLevel?: Group['metadata']['current_level'];
  24. meta?: Record<any, any>;
  25. newestFirst?: boolean;
  26. stackView?: StackView;
  27. threadId?: number;
  28. };
  29. function StackTrace({
  30. stackView,
  31. stacktrace,
  32. chainedException,
  33. debugFrames,
  34. platform,
  35. newestFirst,
  36. groupingCurrentLevel,
  37. hasHierarchicalGrouping,
  38. data,
  39. expandFirstFrame,
  40. event,
  41. meta,
  42. threadId,
  43. }: Props) {
  44. if (!defined(stacktrace)) {
  45. return null;
  46. }
  47. if (
  48. stackView === StackView.APP &&
  49. (stacktrace.frames ?? []).filter(frame => frame.inApp).length === 0 &&
  50. !chainedException
  51. ) {
  52. return (
  53. <Panel dashedBorder>
  54. <EmptyMessage
  55. icon={<IconWarning size="xl" />}
  56. title={
  57. hasHierarchicalGrouping
  58. ? t('No relevant stack trace has been found!')
  59. : t('No app only stack trace has been found!')
  60. }
  61. />
  62. </Panel>
  63. );
  64. }
  65. if (!data) {
  66. return null;
  67. }
  68. const includeSystemFrames =
  69. stackView === StackView.FULL ||
  70. (chainedException && data.frames?.every(frame => !frame.inApp));
  71. /**
  72. * Armin, Markus:
  73. * If all frames are in app, then no frame is in app.
  74. * This normally does not matter for the UI but when chained exceptions
  75. * are used this causes weird behavior where one exception appears to not have a stack trace.
  76. *
  77. * It is easier to fix the UI logic to show a non-empty stack trace for chained exceptions
  78. */
  79. if (isNativePlatform(platform)) {
  80. return (
  81. <NativeContent
  82. data={data}
  83. expandFirstFrame={expandFirstFrame}
  84. includeSystemFrames={includeSystemFrames}
  85. groupingCurrentLevel={groupingCurrentLevel}
  86. platform={platform}
  87. newestFirst={newestFirst}
  88. event={event}
  89. meta={meta}
  90. />
  91. );
  92. }
  93. if (hasHierarchicalGrouping) {
  94. return (
  95. <HierarchicalGroupingContent
  96. data={data}
  97. expandFirstFrame={expandFirstFrame}
  98. includeSystemFrames={includeSystemFrames}
  99. groupingCurrentLevel={groupingCurrentLevel}
  100. platform={platform}
  101. newestFirst={newestFirst}
  102. event={event}
  103. meta={meta}
  104. debugFrames={debugFrames}
  105. />
  106. );
  107. }
  108. return (
  109. <StackTraceContent
  110. data={data}
  111. expandFirstFrame={expandFirstFrame}
  112. includeSystemFrames={includeSystemFrames}
  113. platform={platform}
  114. newestFirst={newestFirst}
  115. event={event}
  116. meta={meta}
  117. debugFrames={debugFrames}
  118. threadId={threadId}
  119. />
  120. );
  121. }
  122. export default StackTrace;