stackTrace.tsx 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 {PermalinkTitle, 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={<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. <StackTraceContent
  69. meta={meta}
  70. event={event}
  71. platform={platform}
  72. stackView={
  73. display.includes('raw-stack-trace')
  74. ? StackView.RAW
  75. : fullStackTrace
  76. ? StackView.FULL
  77. : StackView.APP
  78. }
  79. newestFirst={recentFirst}
  80. stacktrace={data}
  81. groupingCurrentLevel={groupingCurrentLevel}
  82. hasHierarchicalGrouping={hasHierarchicalGrouping}
  83. />
  84. )
  85. }
  86. </TraceEventDataSection>
  87. );
  88. }