eventEntries.tsx 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {CommitRow} from 'sentry/components/commitRow';
  4. import {EventEvidence} from 'sentry/components/events/eventEvidence';
  5. import EventReplay from 'sentry/components/events/eventReplay';
  6. import {ActionableItems} from 'sentry/components/events/interfaces/crashContent/exception/actionableItems';
  7. import {actionableItemsEnabled} from 'sentry/components/events/interfaces/crashContent/exception/useActionableItems';
  8. import {CustomMetricsEventData} from 'sentry/components/metrics/customMetricsEventData';
  9. import {t} from 'sentry/locale';
  10. import {space} from 'sentry/styles/space';
  11. import type {
  12. Entry,
  13. Event,
  14. Group,
  15. Organization,
  16. Project,
  17. SharedViewOrganization,
  18. } from 'sentry/types';
  19. import {EntryType, EventOrGroupType} from 'sentry/types/event';
  20. import {isNotSharedOrganization} from 'sentry/types/utils';
  21. import {isEmptyObject} from 'sentry/utils/object/isEmptyObject';
  22. import {EventContexts} from './contexts';
  23. import {EventDevice} from './device';
  24. import {EventAttachments} from './eventAttachments';
  25. import {EventDataSection} from './eventDataSection';
  26. import {EventEntry} from './eventEntry';
  27. import {EventExtraData} from './eventExtraData';
  28. import {EventSdk} from './eventSdk';
  29. import {EventTagsAndScreenshot} from './eventTagsAndScreenshot';
  30. import {EventViewHierarchy} from './eventViewHierarchy';
  31. import {EventGroupingInfo} from './groupingInfo';
  32. import {EventPackageData} from './packageData';
  33. import {EventRRWebIntegration} from './rrwebIntegration';
  34. import {DataSection} from './styles';
  35. import {SuspectCommits} from './suspectCommits';
  36. import {EventUserFeedback} from './userFeedback';
  37. type Props = {
  38. /**
  39. * The organization can be the shared view on a public issue view.
  40. */
  41. organization: Organization | SharedViewOrganization;
  42. project: Project;
  43. className?: string;
  44. event?: Event;
  45. group?: Group;
  46. isShare?: boolean;
  47. showTagSummary?: boolean;
  48. };
  49. function EventEntries({
  50. organization,
  51. project,
  52. event,
  53. group,
  54. className,
  55. isShare = false,
  56. showTagSummary = true,
  57. }: Props) {
  58. const orgSlug = organization.slug;
  59. const projectSlug = project.slug;
  60. const orgFeatures = organization?.features ?? [];
  61. if (!event) {
  62. return (
  63. <LatestEventNotAvailable>
  64. <h3>{t('Latest Event Not Available')}</h3>
  65. </LatestEventNotAvailable>
  66. );
  67. }
  68. const hasContext = !isEmptyObject(event.user ?? {}) || !isEmptyObject(event.contexts);
  69. const hasActionableItems = actionableItemsEnabled({
  70. eventId: event.id,
  71. organization,
  72. projectSlug,
  73. });
  74. return (
  75. <div className={className}>
  76. {hasActionableItems && (
  77. <ActionableItems event={event} project={project} isShare={isShare} />
  78. )}
  79. {!isShare && isNotSharedOrganization(organization) && (
  80. <SuspectCommits
  81. project={project}
  82. eventId={event.id}
  83. group={group}
  84. commitRow={CommitRow}
  85. />
  86. )}
  87. {event.userReport && group && (
  88. <EventDataSection title="User Feedback" type="user-feedback">
  89. <EventUserFeedback
  90. report={event.userReport}
  91. orgSlug={orgSlug}
  92. issueId={group.id}
  93. />
  94. </EventDataSection>
  95. )}
  96. {showTagSummary && (
  97. <EventTagsAndScreenshot
  98. event={event}
  99. projectSlug={projectSlug}
  100. isShare={isShare}
  101. />
  102. )}
  103. <EventEvidence event={event} project={project} />
  104. <Entries
  105. definedEvent={event}
  106. projectSlug={projectSlug}
  107. group={group}
  108. organization={organization}
  109. isShare={isShare}
  110. />
  111. {hasContext && <EventContexts group={group} event={event} />}
  112. <EventExtraData event={event} />
  113. <EventPackageData event={event} />
  114. <EventDevice event={event} />
  115. {!isShare && <EventViewHierarchy event={event} project={project} />}
  116. {!isShare && <EventAttachments event={event} projectSlug={projectSlug} />}
  117. <EventSdk sdk={event.sdk} meta={event._meta?.sdk} />
  118. {event.type === EventOrGroupType.TRANSACTION && event._metrics_summary && (
  119. <CustomMetricsEventData
  120. projectId={event.projectID}
  121. metricsSummary={event._metrics_summary}
  122. startTimestamp={event.startTimestamp}
  123. />
  124. )}
  125. {!isShare && event.groupID && (
  126. <EventGroupingInfo
  127. projectSlug={projectSlug}
  128. event={event}
  129. showGroupingConfig={
  130. orgFeatures.includes('set-grouping-config') && 'groupingConfig' in event
  131. }
  132. group={group}
  133. />
  134. )}
  135. {!isShare && (
  136. <EventRRWebIntegration event={event} orgId={orgSlug} projectSlug={projectSlug} />
  137. )}
  138. </div>
  139. );
  140. }
  141. // The ordering for event entries is owned by the interface serializers on the backend.
  142. // Because replays are not an interface, we need to manually insert the replay section
  143. // into the array of entries. The long-term solution here is to move the ordering
  144. // logic to this component, similar to how GroupEventDetailsContent works.
  145. export function partitionEntriesForReplay(entries: Entry[]) {
  146. let replayIndex = 0;
  147. for (const [i, entry] of entries.entries()) {
  148. if (
  149. [
  150. // The following entry types should be placed before the replay
  151. // This is similar to the ordering in GroupEventDetailsContent
  152. EntryType.MESSAGE,
  153. EntryType.STACKTRACE,
  154. EntryType.EXCEPTION,
  155. EntryType.THREADS,
  156. EntryType.SPANS,
  157. ].includes(entry.type)
  158. ) {
  159. replayIndex = i + 1;
  160. }
  161. }
  162. return [entries.slice(0, replayIndex), entries.slice(replayIndex)];
  163. }
  164. export function Entries({
  165. definedEvent,
  166. projectSlug,
  167. isShare,
  168. group,
  169. organization,
  170. hideBeforeReplayEntries = false,
  171. hideBreadCrumbs = false,
  172. }: {
  173. definedEvent: Event;
  174. projectSlug: string;
  175. hideBeforeReplayEntries?: boolean;
  176. hideBreadCrumbs?: boolean;
  177. isShare?: boolean;
  178. } & Pick<Props, 'group' | 'organization'>) {
  179. if (!Array.isArray(definedEvent.entries)) {
  180. return null;
  181. }
  182. const [beforeReplayEntries, afterReplayEntries] = partitionEntriesForReplay(
  183. definedEvent.entries
  184. );
  185. const eventEntryProps = {
  186. projectSlug,
  187. group,
  188. organization,
  189. event: definedEvent,
  190. isShare,
  191. };
  192. return (
  193. <Fragment>
  194. {!hideBeforeReplayEntries &&
  195. beforeReplayEntries.map((entry, entryIdx) => (
  196. <EventEntry key={entryIdx} entry={entry} {...eventEntryProps} />
  197. ))}
  198. {!isShare && <EventReplay {...eventEntryProps} />}
  199. {afterReplayEntries.map((entry, entryIdx) => {
  200. if (hideBreadCrumbs && entry.type === EntryType.BREADCRUMBS) {
  201. return null;
  202. }
  203. return <EventEntry key={entryIdx} entry={entry} {...eventEntryProps} />;
  204. })}
  205. </Fragment>
  206. );
  207. }
  208. const LatestEventNotAvailable = styled('div')`
  209. padding: ${space(2)} ${space(4)};
  210. `;
  211. const BorderlessEventEntries = styled(EventEntries)`
  212. & ${DataSection} {
  213. margin-left: 0 !important;
  214. margin-right: 0 !important;
  215. padding: ${space(3)} 0 0 0;
  216. }
  217. & ${DataSection}:first-child {
  218. padding-top: 0;
  219. border-top: 0;
  220. }
  221. `;
  222. export {EventEntries, BorderlessEventEntries};