groupEventDetailsContent.tsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. import {Fragment, lazy, useRef} from 'react';
  2. import styled from '@emotion/styled';
  3. import {CommitRow} from 'sentry/components/commitRow';
  4. import ErrorBoundary from 'sentry/components/errorBoundary';
  5. import {EventContexts} from 'sentry/components/events/contexts';
  6. import {EventDevice} from 'sentry/components/events/device';
  7. import {EventAttachments} from 'sentry/components/events/eventAttachments';
  8. import {EventDataSection} from 'sentry/components/events/eventDataSection';
  9. import {EventEntry} from 'sentry/components/events/eventEntry';
  10. import {EventEvidence} from 'sentry/components/events/eventEvidence';
  11. import {EventExtraData} from 'sentry/components/events/eventExtraData';
  12. import EventHydrationDiff from 'sentry/components/events/eventHydrationDiff';
  13. import EventReplay from 'sentry/components/events/eventReplay';
  14. import {EventSdk} from 'sentry/components/events/eventSdk';
  15. import AggregateSpanDiff from 'sentry/components/events/eventStatisticalDetector/aggregateSpanDiff';
  16. import EventBreakpointChart from 'sentry/components/events/eventStatisticalDetector/breakpointChart';
  17. import {EventAffectedTransactions} from 'sentry/components/events/eventStatisticalDetector/eventAffectedTransactions';
  18. import EventComparison from 'sentry/components/events/eventStatisticalDetector/eventComparison';
  19. import {EventDifferentialFlamegraph} from 'sentry/components/events/eventStatisticalDetector/eventDifferentialFlamegraph';
  20. import {EventFunctionComparisonList} from 'sentry/components/events/eventStatisticalDetector/eventFunctionComparisonList';
  21. import {EventRegressionSummary} from 'sentry/components/events/eventStatisticalDetector/eventRegressionSummary';
  22. import {EventFunctionBreakpointChart} from 'sentry/components/events/eventStatisticalDetector/functionBreakpointChart';
  23. import {TransactionsDeltaProvider} from 'sentry/components/events/eventStatisticalDetector/transactionsDeltaProvider';
  24. import {EventTagsAndScreenshot} from 'sentry/components/events/eventTagsAndScreenshot';
  25. import {EventViewHierarchy} from 'sentry/components/events/eventViewHierarchy';
  26. import {EventGroupingInfo} from 'sentry/components/events/groupingInfo';
  27. import HighlightsDataSection from 'sentry/components/events/highlights/highlightsDataSection';
  28. import {ActionableItems} from 'sentry/components/events/interfaces/crashContent/exception/actionableItems';
  29. import {actionableItemsEnabled} from 'sentry/components/events/interfaces/crashContent/exception/useActionableItems';
  30. import {CronTimelineSection} from 'sentry/components/events/interfaces/crons/cronTimelineSection';
  31. import {AnrRootCause} from 'sentry/components/events/interfaces/performance/anrRootCause';
  32. import {SpanEvidenceSection} from 'sentry/components/events/interfaces/performance/spanEvidence';
  33. import {EventPackageData} from 'sentry/components/events/packageData';
  34. import {EventRRWebIntegration} from 'sentry/components/events/rrwebIntegration';
  35. import {DataSection} from 'sentry/components/events/styles';
  36. import {SuspectCommits} from 'sentry/components/events/suspectCommits';
  37. import {EventUserFeedback} from 'sentry/components/events/userFeedback';
  38. import LazyLoad from 'sentry/components/lazyLoad';
  39. import {t} from 'sentry/locale';
  40. import {space} from 'sentry/styles/space';
  41. import {
  42. type EntryException,
  43. type Event,
  44. EventOrGroupType,
  45. type Group,
  46. IssueCategory,
  47. IssueType,
  48. type Project,
  49. } from 'sentry/types';
  50. import type {EventTransaction} from 'sentry/types/event';
  51. import {EntryType} from 'sentry/types/event';
  52. import {shouldShowCustomErrorResourceConfig} from 'sentry/utils/issueTypeConfig';
  53. import {QuickTraceContext} from 'sentry/utils/performance/quickTrace/quickTraceContext';
  54. import QuickTraceQuery from 'sentry/utils/performance/quickTrace/quickTraceQuery';
  55. import {getReplayIdFromEvent} from 'sentry/utils/replays/getReplayIdFromEvent';
  56. import {useLocation} from 'sentry/utils/useLocation';
  57. import useOrganization from 'sentry/utils/useOrganization';
  58. import {ResourcesAndPossibleSolutions} from 'sentry/views/issueDetails/resourcesAndPossibleSolutions';
  59. const LLMMonitoringSection = lazy(
  60. () => import('sentry/components/events/interfaces/llm-monitoring/llmMonitoringSection')
  61. );
  62. type GroupEventDetailsContentProps = {
  63. group: Group;
  64. project: Project;
  65. event?: Event;
  66. };
  67. type GroupEventEntryProps = {
  68. entryType: EntryType;
  69. event: Event;
  70. group: Group;
  71. project: Project;
  72. };
  73. function GroupEventEntry({event, entryType, group, project}: GroupEventEntryProps) {
  74. const organization = useOrganization();
  75. const matchingEntry = event.entries.find(entry => entry.type === entryType);
  76. if (!matchingEntry) {
  77. return null;
  78. }
  79. return (
  80. <EventEntry
  81. projectSlug={project.slug}
  82. group={group}
  83. entry={matchingEntry}
  84. {...{organization, event}}
  85. />
  86. );
  87. }
  88. function DefaultGroupEventDetailsContent({
  89. group,
  90. event,
  91. project,
  92. }: Required<GroupEventDetailsContentProps>) {
  93. const organization = useOrganization();
  94. const location = useLocation();
  95. const tagsRef = useRef<HTMLDivElement>(null);
  96. const projectSlug = project.slug;
  97. const hasReplay = Boolean(getReplayIdFromEvent(event));
  98. const mechanism = event.tags?.find(({key}) => key === 'mechanism')?.value;
  99. const isANR = mechanism === 'ANR' || mechanism === 'AppExitInfo';
  100. const hasAnrImprovementsFeature = organization.features.includes('anr-improvements');
  101. const showPossibleSolutionsHigher = shouldShowCustomErrorResourceConfig(group, project);
  102. const eventEntryProps = {group, event, project};
  103. const hasActionableItems = actionableItemsEnabled({
  104. eventId: event.id,
  105. organization,
  106. projectSlug,
  107. });
  108. return (
  109. <Fragment>
  110. {hasActionableItems && (
  111. <ActionableItems event={event} project={project} isShare={false} />
  112. )}
  113. <StyledDataSection>
  114. <SuspectCommits
  115. project={project}
  116. eventId={event.id}
  117. group={group}
  118. commitRow={CommitRow}
  119. />
  120. </StyledDataSection>
  121. {event.userReport && (
  122. <EventDataSection title={t('User Feedback')} type="user-feedback">
  123. <EventUserFeedback
  124. report={event.userReport}
  125. orgSlug={organization.slug}
  126. issueId={group.id}
  127. showEventLink={false}
  128. />
  129. </EventDataSection>
  130. )}
  131. {event.type === EventOrGroupType.ERROR &&
  132. organization.features.includes('insights-addon-modules') &&
  133. event?.entries
  134. ?.filter((x): x is EntryException => x.type === EntryType.EXCEPTION)
  135. .flatMap(x => x.data.values ?? [])
  136. .some(({value}) => {
  137. const lowerText = value?.toLowerCase();
  138. return (
  139. lowerText &&
  140. (lowerText.includes('api key') || lowerText.includes('429')) &&
  141. (lowerText.includes('openai') ||
  142. lowerText.includes('anthropic') ||
  143. lowerText.includes('cohere') ||
  144. lowerText.includes('langchain'))
  145. );
  146. }) ? (
  147. <LazyLoad
  148. LazyComponent={LLMMonitoringSection}
  149. event={event}
  150. organization={organization}
  151. />
  152. ) : null}
  153. {group.issueCategory === IssueCategory.CRON && (
  154. <CronTimelineSection
  155. event={event}
  156. organization={organization}
  157. project={project}
  158. />
  159. )}
  160. <HighlightsDataSection
  161. event={event}
  162. group={group}
  163. project={project}
  164. viewAllRef={tagsRef}
  165. />
  166. {showPossibleSolutionsHigher && (
  167. <ResourcesAndPossibleSolutionsIssueDetailsContent
  168. event={event}
  169. project={project}
  170. group={group}
  171. />
  172. )}
  173. <EventEvidence event={event} group={group} project={project} />
  174. <GroupEventEntry entryType={EntryType.MESSAGE} {...eventEntryProps} />
  175. <GroupEventEntry entryType={EntryType.EXCEPTION} {...eventEntryProps} />
  176. <GroupEventEntry entryType={EntryType.STACKTRACE} {...eventEntryProps} />
  177. <GroupEventEntry entryType={EntryType.THREADS} {...eventEntryProps} />
  178. {hasAnrImprovementsFeature && isANR && (
  179. <QuickTraceQuery
  180. event={event}
  181. location={location}
  182. orgSlug={organization.slug}
  183. type={'spans'}
  184. skipLight
  185. >
  186. {results => {
  187. return (
  188. <QuickTraceContext.Provider value={results}>
  189. <AnrRootCause event={event} organization={organization} />
  190. </QuickTraceContext.Provider>
  191. );
  192. }}
  193. </QuickTraceQuery>
  194. )}
  195. {group.issueCategory === IssueCategory.PERFORMANCE && (
  196. <SpanEvidenceSection
  197. event={event as EventTransaction}
  198. organization={organization}
  199. projectSlug={project.slug}
  200. />
  201. )}
  202. <EventHydrationDiff event={event} group={group} />
  203. <EventReplay event={event} group={group} projectSlug={project.slug} />
  204. <GroupEventEntry entryType={EntryType.HPKP} {...eventEntryProps} />
  205. <GroupEventEntry entryType={EntryType.CSP} {...eventEntryProps} />
  206. <GroupEventEntry entryType={EntryType.EXPECTCT} {...eventEntryProps} />
  207. <GroupEventEntry entryType={EntryType.EXPECTSTAPLE} {...eventEntryProps} />
  208. <GroupEventEntry entryType={EntryType.TEMPLATE} {...eventEntryProps} />
  209. <GroupEventEntry entryType={EntryType.BREADCRUMBS} {...eventEntryProps} />
  210. {!showPossibleSolutionsHigher && (
  211. <ResourcesAndPossibleSolutionsIssueDetailsContent
  212. event={event}
  213. project={project}
  214. group={group}
  215. />
  216. )}
  217. <GroupEventEntry entryType={EntryType.DEBUGMETA} {...eventEntryProps} />
  218. <GroupEventEntry entryType={EntryType.REQUEST} {...eventEntryProps} />
  219. <div ref={tagsRef}>
  220. <EventTagsAndScreenshot event={event} projectSlug={project.slug} />
  221. </div>
  222. <EventContexts group={group} event={event} />
  223. <EventExtraData event={event} />
  224. <EventPackageData event={event} />
  225. <EventDevice event={event} />
  226. <EventViewHierarchy event={event} project={project} />
  227. <EventAttachments event={event} projectSlug={project.slug} />
  228. <EventSdk sdk={event.sdk} meta={event._meta?.sdk} />
  229. {event.groupID && (
  230. <EventGroupingInfo
  231. projectSlug={project.slug}
  232. event={event}
  233. showGroupingConfig={
  234. organization.features.includes('set-grouping-config') &&
  235. 'groupingConfig' in event
  236. }
  237. group={group}
  238. />
  239. )}
  240. {!hasReplay && (
  241. <EventRRWebIntegration
  242. event={event}
  243. orgId={organization.slug}
  244. projectSlug={project.slug}
  245. />
  246. )}
  247. </Fragment>
  248. );
  249. }
  250. function ResourcesAndPossibleSolutionsIssueDetailsContent({
  251. event,
  252. project,
  253. group,
  254. }: Required<GroupEventDetailsContentProps>) {
  255. return (
  256. <ErrorBoundary mini>
  257. <ResourcesAndPossibleSolutions event={event} project={project} group={group} />
  258. </ErrorBoundary>
  259. );
  260. }
  261. function PerformanceDurationRegressionIssueDetailsContent({
  262. group,
  263. event,
  264. project,
  265. }: Required<GroupEventDetailsContentProps>) {
  266. return (
  267. <Fragment>
  268. <ErrorBoundary mini>
  269. <EventRegressionSummary event={event} group={group} />
  270. </ErrorBoundary>
  271. <ErrorBoundary mini>
  272. <EventBreakpointChart event={event} />
  273. </ErrorBoundary>
  274. <ErrorBoundary mini>
  275. <AggregateSpanDiff event={event} project={project} />
  276. </ErrorBoundary>
  277. <ErrorBoundary mini>
  278. <EventComparison event={event} project={project} />
  279. </ErrorBoundary>
  280. </Fragment>
  281. );
  282. }
  283. function ProfilingDurationRegressionIssueDetailsContent({
  284. group,
  285. event,
  286. project,
  287. }: Required<GroupEventDetailsContentProps>) {
  288. return (
  289. <TransactionsDeltaProvider event={event} project={project}>
  290. <Fragment>
  291. <ErrorBoundary mini>
  292. <EventRegressionSummary event={event} group={group} />
  293. </ErrorBoundary>
  294. <ErrorBoundary mini>
  295. <EventFunctionBreakpointChart event={event} />
  296. </ErrorBoundary>
  297. <ErrorBoundary mini>
  298. <EventAffectedTransactions event={event} group={group} project={project} />
  299. </ErrorBoundary>
  300. <ErrorBoundary mini>
  301. <DataSection>
  302. <b>{t('Largest Changes in Call Stack Frequency')}</b>
  303. <p>
  304. {t(`See which functions changed the most before and after the regression. The
  305. frame with the largest increase in call stack population likely
  306. contributed to the cause for the duration regression.`)}
  307. </p>
  308. <EventDifferentialFlamegraph event={event} />
  309. </DataSection>
  310. </ErrorBoundary>
  311. <ErrorBoundary mini>
  312. <EventFunctionComparisonList event={event} group={group} project={project} />
  313. </ErrorBoundary>
  314. </Fragment>
  315. </TransactionsDeltaProvider>
  316. );
  317. }
  318. function GroupEventDetailsContent({
  319. group,
  320. event,
  321. project,
  322. }: GroupEventDetailsContentProps) {
  323. if (!event) {
  324. return (
  325. <NotFoundMessage>
  326. <h3>{t('Latest event not available')}</h3>
  327. </NotFoundMessage>
  328. );
  329. }
  330. switch (group.issueType) {
  331. case IssueType.PERFORMANCE_DURATION_REGRESSION:
  332. case IssueType.PERFORMANCE_ENDPOINT_REGRESSION: {
  333. return (
  334. <PerformanceDurationRegressionIssueDetailsContent
  335. group={group}
  336. event={event}
  337. project={project}
  338. />
  339. );
  340. }
  341. case IssueType.PROFILE_FUNCTION_REGRESSION_EXPERIMENTAL:
  342. case IssueType.PROFILE_FUNCTION_REGRESSION: {
  343. return (
  344. <ProfilingDurationRegressionIssueDetailsContent
  345. group={group}
  346. event={event}
  347. project={project}
  348. />
  349. );
  350. }
  351. default: {
  352. return (
  353. <DefaultGroupEventDetailsContent group={group} event={event} project={project} />
  354. );
  355. }
  356. }
  357. }
  358. const NotFoundMessage = styled('div')`
  359. padding: ${space(2)} ${space(4)};
  360. `;
  361. const StyledDataSection = styled(DataSection)`
  362. padding: ${space(0.5)} ${space(2)};
  363. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  364. padding: ${space(1)} ${space(4)};
  365. }
  366. &:empty {
  367. display: none;
  368. }
  369. `;
  370. export default GroupEventDetailsContent;