exceptionV2.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import {t} from 'sentry/locale';
  2. import {ExceptionType, Group, PlatformType, Project} from 'sentry/types';
  3. import {EntryType, Event} from 'sentry/types/event';
  4. import {STACK_TYPE, STACK_VIEW} from 'sentry/types/stacktrace';
  5. import {PermalinkTitle, TraceEventDataSection} from '../traceEventDataSection';
  6. import CrashContentException from './crashContent/exception';
  7. import NoStackTraceMessage from './noStackTraceMessage';
  8. import {isStacktraceNewestFirst} from './utils';
  9. type Props = {
  10. data: ExceptionType;
  11. event: Event;
  12. hasHierarchicalGrouping: boolean;
  13. projectId: Project['id'];
  14. groupingCurrentLevel?: Group['metadata']['current_level'];
  15. hideGuide?: boolean;
  16. };
  17. function Exception({
  18. event,
  19. data,
  20. projectId,
  21. hasHierarchicalGrouping,
  22. groupingCurrentLevel,
  23. }: Props) {
  24. const eventHasThreads = !!event.entries.some(entry => entry.type === EntryType.THREADS);
  25. /* in case there are threads in the event data, we don't render the
  26. exception block. Instead the exception is contained within the
  27. thread interface. */
  28. if (eventHasThreads) {
  29. return null;
  30. }
  31. const entryIndex = event.entries.findIndex(
  32. eventEntry => eventEntry.type === EntryType.EXCEPTION
  33. );
  34. const meta = event._meta?.entries?.[entryIndex]?.data?.values;
  35. function getPlatform(): PlatformType {
  36. const dataValue = data.values?.find(
  37. value => !!value.stacktrace?.frames?.some(frame => !!frame.platform)
  38. );
  39. if (dataValue) {
  40. const framePlatform = dataValue.stacktrace?.frames?.find(frame => !!frame.platform);
  41. if (framePlatform?.platform) {
  42. return framePlatform.platform;
  43. }
  44. }
  45. return event.platform ?? 'other';
  46. }
  47. const stackTraceNotFound = !(data.values ?? []).length;
  48. const platform = getPlatform();
  49. return (
  50. <TraceEventDataSection
  51. title={<PermalinkTitle>{t('Stack Trace')}</PermalinkTitle>}
  52. type={EntryType.EXCEPTION}
  53. stackType={STACK_TYPE.ORIGINAL}
  54. projectId={projectId}
  55. eventId={event.id}
  56. recentFirst={isStacktraceNewestFirst()}
  57. fullStackTrace={!data.hasSystemFrames}
  58. platform={platform}
  59. hasMinified={!!data.values?.some(value => value.rawStacktrace)}
  60. hasVerboseFunctionNames={
  61. !!data.values?.some(
  62. value =>
  63. !!value.stacktrace?.frames?.some(
  64. frame =>
  65. !!frame.rawFunction &&
  66. !!frame.function &&
  67. frame.rawFunction !== frame.function
  68. )
  69. )
  70. }
  71. hasAbsoluteFilePaths={
  72. !!data.values?.some(
  73. value => !!value.stacktrace?.frames?.some(frame => !!frame.filename)
  74. )
  75. }
  76. hasAbsoluteAddresses={
  77. !!data.values?.some(
  78. value => !!value.stacktrace?.frames?.some(frame => !!frame.instructionAddr)
  79. )
  80. }
  81. hasAppOnlyFrames={
  82. !!data.values?.some(
  83. value => !!value.stacktrace?.frames?.some(frame => frame.inApp !== true)
  84. )
  85. }
  86. hasNewestFirst={
  87. !!data.values?.some(value => (value.stacktrace?.frames ?? []).length > 1)
  88. }
  89. stackTraceNotFound={stackTraceNotFound}
  90. wrapTitle={false}
  91. >
  92. {({recentFirst, display, fullStackTrace}) =>
  93. stackTraceNotFound ? (
  94. <NoStackTraceMessage />
  95. ) : (
  96. <CrashContentException
  97. stackType={
  98. display.includes('minified') ? STACK_TYPE.MINIFIED : STACK_TYPE.ORIGINAL
  99. }
  100. stackView={
  101. display.includes('raw-stack-trace')
  102. ? STACK_VIEW.RAW
  103. : fullStackTrace
  104. ? STACK_VIEW.FULL
  105. : STACK_VIEW.APP
  106. }
  107. projectId={projectId}
  108. newestFirst={recentFirst}
  109. event={event}
  110. platform={platform}
  111. values={data.values}
  112. groupingCurrentLevel={groupingCurrentLevel}
  113. hasHierarchicalGrouping={hasHierarchicalGrouping}
  114. meta={meta}
  115. />
  116. )
  117. }
  118. </TraceEventDataSection>
  119. );
  120. }
  121. export default Exception;