stackTrace.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import {CrashContent} from 'sentry/components/events/interfaces/crashContent';
  2. import {t} from 'sentry/locale';
  3. import {Group, PlatformKey, Project} from 'sentry/types';
  4. import {EntryType, Event} from 'sentry/types/event';
  5. import {StackView} from 'sentry/types/stacktrace';
  6. import {PermalinkTitle, TraceEventDataSection} from '../traceEventDataSection';
  7. import {StackTraceContent} from './crashContent/stackTrace';
  8. import NoStackTraceMessage from './noStackTraceMessage';
  9. import {isStacktraceNewestFirst} from './utils';
  10. type CrashContentProps = React.ComponentProps<typeof CrashContent>;
  11. type Props = Pick<
  12. CrashContentProps,
  13. 'groupingCurrentLevel' | 'hasHierarchicalGrouping'
  14. > & {
  15. data: NonNullable<CrashContentProps['stacktrace']>;
  16. event: Event;
  17. projectSlug: Project['slug'];
  18. groupingCurrentLevel?: Group['metadata']['current_level'];
  19. hideGuide?: boolean;
  20. };
  21. export function StackTrace({
  22. projectSlug,
  23. event,
  24. data,
  25. hasHierarchicalGrouping,
  26. groupingCurrentLevel,
  27. }: Props) {
  28. const entryIndex = event.entries.findIndex(
  29. eventEntry => eventEntry.type === EntryType.STACKTRACE
  30. );
  31. const meta = event._meta?.entries?.[entryIndex]?.data;
  32. function getPlatform(): PlatformKey {
  33. const framePlatform = data.frames?.find(frame => !!frame.platform);
  34. return framePlatform?.platform ?? event.platform ?? 'other';
  35. }
  36. const platform = getPlatform();
  37. const stackTraceNotFound = !(data.frames ?? []).length;
  38. return (
  39. <TraceEventDataSection
  40. type={EntryType.STACKTRACE}
  41. projectSlug={projectSlug}
  42. eventId={event.id}
  43. platform={platform}
  44. stackTraceNotFound={stackTraceNotFound}
  45. recentFirst={isStacktraceNewestFirst()}
  46. fullStackTrace={!data.hasSystemFrames}
  47. title={<PermalinkTitle>{t('Stack Trace')}</PermalinkTitle>}
  48. wrapTitle={false}
  49. hasMinified={false}
  50. hasVerboseFunctionNames={
  51. !!data.frames?.some(
  52. frame =>
  53. !!frame.rawFunction &&
  54. !!frame.function &&
  55. frame.rawFunction !== frame.function
  56. )
  57. }
  58. hasAbsoluteFilePaths={!!data.frames?.some(frame => !!frame.filename)}
  59. hasAbsoluteAddresses={!!data.frames?.some(frame => !!frame.instructionAddr)}
  60. hasAppOnlyFrames={!!data.frames?.some(frame => frame.inApp !== true)}
  61. hasNewestFirst={(data.frames ?? []).length > 1}
  62. >
  63. {({recentFirst, display, fullStackTrace}) =>
  64. stackTraceNotFound ? (
  65. <NoStackTraceMessage />
  66. ) : (
  67. <StackTraceContent
  68. meta={meta}
  69. event={event}
  70. platform={platform}
  71. stackView={
  72. display.includes('raw-stack-trace')
  73. ? StackView.RAW
  74. : fullStackTrace
  75. ? StackView.FULL
  76. : StackView.APP
  77. }
  78. newestFirst={recentFirst}
  79. stacktrace={data}
  80. groupingCurrentLevel={groupingCurrentLevel}
  81. hasHierarchicalGrouping={hasHierarchicalGrouping}
  82. />
  83. )
  84. }
  85. </TraceEventDataSection>
  86. );
  87. }