stackTraceV2.tsx 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import CrashContent from 'sentry/components/events/interfaces/crashContent';
  2. import {t} from 'sentry/locale';
  3. import {Group, PlatformType, Project} from 'sentry/types';
  4. import {EntryType, Event} from 'sentry/types/event';
  5. import {STACK_TYPE, STACK_VIEW} from 'sentry/types/stacktrace';
  6. import {PermalinkTitle, TraceEventDataSection} from '../traceEventDataSection';
  7. import CrashContentStackTrace 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 StackTraceV2({
  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(): PlatformType {
  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. stackType={STACK_TYPE.ORIGINAL}
  42. projectSlug={projectSlug}
  43. eventId={event.id}
  44. platform={platform}
  45. stackTraceNotFound={stackTraceNotFound}
  46. recentFirst={isStacktraceNewestFirst()}
  47. fullStackTrace={!data.hasSystemFrames}
  48. title={<PermalinkTitle>{t('Stack Trace')}</PermalinkTitle>}
  49. wrapTitle={false}
  50. hasMinified={false}
  51. hasVerboseFunctionNames={
  52. !!data.frames?.some(
  53. frame =>
  54. !!frame.rawFunction &&
  55. !!frame.function &&
  56. frame.rawFunction !== frame.function
  57. )
  58. }
  59. hasAbsoluteFilePaths={!!data.frames?.some(frame => !!frame.filename)}
  60. hasAbsoluteAddresses={!!data.frames?.some(frame => !!frame.instructionAddr)}
  61. hasAppOnlyFrames={!!data.frames?.some(frame => frame.inApp !== true)}
  62. hasNewestFirst={(data.frames ?? []).length > 1}
  63. >
  64. {({recentFirst, display, fullStackTrace}) =>
  65. stackTraceNotFound ? (
  66. <NoStackTraceMessage />
  67. ) : (
  68. <CrashContentStackTrace
  69. meta={meta}
  70. event={event}
  71. platform={platform}
  72. stackView={
  73. display.includes('raw-stack-trace')
  74. ? STACK_VIEW.RAW
  75. : fullStackTrace
  76. ? STACK_VIEW.FULL
  77. : STACK_VIEW.APP
  78. }
  79. newestFirst={recentFirst}
  80. stacktrace={data}
  81. groupingCurrentLevel={groupingCurrentLevel}
  82. hasHierarchicalGrouping={hasHierarchicalGrouping}
  83. nativeV2
  84. />
  85. )
  86. }
  87. </TraceEventDataSection>
  88. );
  89. }