stackTrace.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import type {CrashContent} from 'sentry/components/events/interfaces/crashContent';
  2. import {t} from 'sentry/locale';
  3. import type {Group, PlatformKey, Project} from 'sentry/types';
  4. import type {Event} from 'sentry/types/event';
  5. import {EntryType} from 'sentry/types/event';
  6. import {StackView} from 'sentry/types/stacktrace';
  7. import {TraceEventDataSection} from '../traceEventDataSection';
  8. import {StackTraceContent} from './crashContent/stackTrace';
  9. import NoStackTraceMessage from './noStackTraceMessage';
  10. import {isStacktraceNewestFirst} from './utils';
  11. type CrashContentProps = React.ComponentProps<typeof CrashContent>;
  12. type Props = Pick<
  13. CrashContentProps,
  14. 'groupingCurrentLevel' | 'hasHierarchicalGrouping'
  15. > & {
  16. data: NonNullable<CrashContentProps['stacktrace']>;
  17. event: Event;
  18. projectSlug: Project['slug'];
  19. groupingCurrentLevel?: Group['metadata']['current_level'];
  20. hideGuide?: boolean;
  21. };
  22. export function StackTrace({
  23. projectSlug,
  24. event,
  25. data,
  26. hasHierarchicalGrouping,
  27. groupingCurrentLevel,
  28. }: Props) {
  29. const entryIndex = event.entries.findIndex(
  30. eventEntry => eventEntry.type === EntryType.STACKTRACE
  31. );
  32. const meta = event._meta?.entries?.[entryIndex]?.data;
  33. function getPlatform(): PlatformKey {
  34. const framePlatform = data.frames?.find(frame => !!frame.platform);
  35. return framePlatform?.platform ?? event.platform ?? 'other';
  36. }
  37. const platform = getPlatform();
  38. const stackTraceNotFound = !(data.frames ?? []).length;
  39. return (
  40. <TraceEventDataSection
  41. type={EntryType.STACKTRACE}
  42. projectSlug={projectSlug}
  43. eventId={event.id}
  44. platform={platform}
  45. stackTraceNotFound={stackTraceNotFound}
  46. recentFirst={isStacktraceNewestFirst()}
  47. fullStackTrace={!data.hasSystemFrames}
  48. title={t('Stack Trace')}
  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. }