getStacktraceBody.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import rawStacktraceContent from 'sentry/components/events/interfaces/crashContent/stackTrace/rawContent';
  2. import type {Event} from 'sentry/types/event';
  3. export default function getStacktraceBody(
  4. event: Event,
  5. hasSimilarityEmbeddingsFeature: boolean = false
  6. ) {
  7. if (!event || !event.entries) {
  8. return [];
  9. }
  10. // TODO(billyvg): This only accounts for the first exception, will need navigation to be able to
  11. // diff multiple exceptions
  12. //
  13. // See: https://github.com/getsentry/sentry/issues/6055
  14. const exc = event.entries.find(({type}) => type === 'exception');
  15. if (!exc) {
  16. // Look for a message if not an exception
  17. const msg = event.entries.find(({type}) => type === 'message');
  18. if (!msg) {
  19. return [];
  20. }
  21. return msg?.data?.formatted && [msg.data.formatted];
  22. }
  23. if (!exc.data) {
  24. return [];
  25. }
  26. // TODO(ts): This should be verified when EntryData has the correct type
  27. return exc.data.values
  28. .filter(value => !!value.stacktrace)
  29. .map(value =>
  30. rawStacktraceContent(
  31. value.stacktrace,
  32. event.platform,
  33. value,
  34. hasSimilarityEmbeddingsFeature
  35. )
  36. )
  37. .reduce((acc, value) => acc.concat(value), []);
  38. }