eventEntry.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import {
  2. Group,
  3. IssueCategory,
  4. Organization,
  5. Project,
  6. SharedViewOrganization,
  7. } from 'sentry/types';
  8. import {Entry, EntryType, Event, EventTransaction} from 'sentry/types/event';
  9. import {Breadcrumbs} from './interfaces/breadcrumbs';
  10. import {Csp} from './interfaces/csp';
  11. import {DebugMeta} from './interfaces/debugMeta';
  12. import {Exception} from './interfaces/exception';
  13. import {ExceptionV2} from './interfaces/exceptionV2';
  14. import {Generic} from './interfaces/generic';
  15. import {Message} from './interfaces/message';
  16. import {Resources} from './interfaces/performance/resources';
  17. import {SpanEvidenceSection} from './interfaces/performance/spanEvidence';
  18. import {getResourceDescription, getResourceLinks} from './interfaces/performance/utils';
  19. import {Request} from './interfaces/request';
  20. import {Spans} from './interfaces/spans';
  21. import {StackTrace} from './interfaces/stackTrace';
  22. import {StackTraceV2} from './interfaces/stackTraceV2';
  23. import {Template} from './interfaces/template';
  24. import {Threads} from './interfaces/threads';
  25. import {ThreadsV2} from './interfaces/threadsV2';
  26. type Props = {
  27. entry: Entry;
  28. event: Event;
  29. organization: SharedViewOrganization | Organization;
  30. projectSlug: Project['slug'];
  31. group?: Group;
  32. isShare?: boolean;
  33. };
  34. export function EventEntry({
  35. entry,
  36. projectSlug,
  37. event,
  38. organization,
  39. group,
  40. isShare,
  41. }: Props) {
  42. const hasHierarchicalGrouping =
  43. !!organization.features?.includes('grouping-stacktrace-ui') &&
  44. !!(event.metadata.current_tree_label || event.metadata.finest_tree_label);
  45. const hasNativeStackTraceV2 = !!organization.features?.includes(
  46. 'native-stack-trace-v2'
  47. );
  48. const groupingCurrentLevel = group?.metadata?.current_level;
  49. switch (entry.type) {
  50. case EntryType.EXCEPTION: {
  51. return hasNativeStackTraceV2 ? (
  52. <ExceptionV2
  53. event={event}
  54. data={entry.data}
  55. projectId={projectSlug}
  56. groupingCurrentLevel={groupingCurrentLevel}
  57. hasHierarchicalGrouping={hasHierarchicalGrouping}
  58. />
  59. ) : (
  60. <Exception
  61. event={event}
  62. data={entry.data}
  63. projectId={projectSlug}
  64. groupingCurrentLevel={groupingCurrentLevel}
  65. hasHierarchicalGrouping={hasHierarchicalGrouping}
  66. />
  67. );
  68. }
  69. case EntryType.MESSAGE: {
  70. return <Message event={event} data={entry.data} />;
  71. }
  72. case EntryType.REQUEST: {
  73. return <Request event={event} data={entry.data} />;
  74. }
  75. case EntryType.STACKTRACE: {
  76. return hasNativeStackTraceV2 ? (
  77. <StackTraceV2
  78. event={event}
  79. data={entry.data}
  80. projectId={projectSlug}
  81. groupingCurrentLevel={groupingCurrentLevel}
  82. hasHierarchicalGrouping={hasHierarchicalGrouping}
  83. />
  84. ) : (
  85. <StackTrace
  86. event={event}
  87. data={entry.data}
  88. projectId={projectSlug}
  89. groupingCurrentLevel={groupingCurrentLevel}
  90. hasHierarchicalGrouping={hasHierarchicalGrouping}
  91. />
  92. );
  93. }
  94. case EntryType.TEMPLATE: {
  95. return <Template event={event} data={entry.data} />;
  96. }
  97. case EntryType.CSP: {
  98. return <Csp event={event} data={entry.data} />;
  99. }
  100. case EntryType.EXPECTCT:
  101. case EntryType.EXPECTSTAPLE: {
  102. const {data, type} = entry;
  103. return <Generic type={type} data={data} />;
  104. }
  105. case EntryType.HPKP:
  106. return (
  107. <Generic type={entry.type} data={entry.data} meta={event._meta?.hpkp ?? {}} />
  108. );
  109. case EntryType.BREADCRUMBS: {
  110. return (
  111. <Breadcrumbs
  112. data={entry.data}
  113. organization={organization as Organization}
  114. event={event}
  115. isShare={isShare}
  116. projectSlug={projectSlug}
  117. />
  118. );
  119. }
  120. case EntryType.THREADS: {
  121. return hasNativeStackTraceV2 ? (
  122. <ThreadsV2
  123. event={event}
  124. data={entry.data}
  125. projectId={projectSlug}
  126. groupingCurrentLevel={groupingCurrentLevel}
  127. hasHierarchicalGrouping={hasHierarchicalGrouping}
  128. />
  129. ) : (
  130. <Threads
  131. event={event}
  132. data={entry.data}
  133. projectId={projectSlug}
  134. groupingCurrentLevel={groupingCurrentLevel}
  135. hasHierarchicalGrouping={hasHierarchicalGrouping}
  136. />
  137. );
  138. }
  139. case EntryType.DEBUGMETA:
  140. return (
  141. <DebugMeta
  142. event={event}
  143. projectId={projectSlug}
  144. groupId={group?.id}
  145. organization={organization as Organization}
  146. data={entry.data}
  147. />
  148. );
  149. case EntryType.SPANS:
  150. // XXX: We currently do not show spans in the share view,
  151. if (isShare) {
  152. return null;
  153. }
  154. if (group?.issueCategory === IssueCategory.PERFORMANCE) {
  155. return (
  156. <SpanEvidenceSection
  157. issueType={group?.issueType}
  158. event={event as EventTransaction}
  159. organization={organization as Organization}
  160. />
  161. );
  162. }
  163. return (
  164. <Spans
  165. event={event as EventTransaction}
  166. organization={organization as Organization}
  167. />
  168. );
  169. case EntryType.RESOURCES:
  170. if (!group || !group.issueType) {
  171. return null;
  172. }
  173. return (
  174. <Resources
  175. description={getResourceDescription(group.issueType)}
  176. links={getResourceLinks(group.issueType, event.platform)}
  177. />
  178. );
  179. default:
  180. // this should not happen
  181. /* eslint no-console:0 */
  182. window.console &&
  183. console.error &&
  184. console.error('Unregistered interface: ' + (entry as any).type);
  185. return null;
  186. }
  187. }