groupDetails.tsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. import {
  2. cloneElement,
  3. Fragment,
  4. isValidElement,
  5. useCallback,
  6. useEffect,
  7. useRef,
  8. useState,
  9. } from 'react';
  10. import {browserHistory, RouteComponentProps} from 'react-router';
  11. import styled from '@emotion/styled';
  12. import * as Sentry from '@sentry/react';
  13. import * as qs from 'query-string';
  14. import LoadingError from 'sentry/components/loadingError';
  15. import LoadingIndicator from 'sentry/components/loadingIndicator';
  16. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  17. import MissingProjectMembership from 'sentry/components/projects/missingProjectMembership';
  18. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  19. import {TabPanels, Tabs} from 'sentry/components/tabs';
  20. import {t} from 'sentry/locale';
  21. import GroupStore from 'sentry/stores/groupStore';
  22. import {space} from 'sentry/styles/space';
  23. import {Group, IssueCategory, Organization, Project} from 'sentry/types';
  24. import {Event} from 'sentry/types/event';
  25. import {defined} from 'sentry/utils';
  26. import {trackAnalytics} from 'sentry/utils/analytics';
  27. import {getUtcDateString} from 'sentry/utils/dates';
  28. import {
  29. getAnalyticsDataForEvent,
  30. getAnalyticsDataForGroup,
  31. getMessage,
  32. getTitle,
  33. } from 'sentry/utils/events';
  34. import {getAnalyicsDataForProject} from 'sentry/utils/projects';
  35. import {
  36. ApiQueryKey,
  37. setApiQueryData,
  38. useApiQuery,
  39. useQueryClient,
  40. } from 'sentry/utils/queryClient';
  41. import recreateRoute from 'sentry/utils/recreateRoute';
  42. import RequestError from 'sentry/utils/requestError/requestError';
  43. import useDisableRouteAnalytics from 'sentry/utils/routeAnalytics/useDisableRouteAnalytics';
  44. import useRouteAnalyticsEventNames from 'sentry/utils/routeAnalytics/useRouteAnalyticsEventNames';
  45. import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
  46. import useApi from 'sentry/utils/useApi';
  47. import {useLocation} from 'sentry/utils/useLocation';
  48. import useOrganization from 'sentry/utils/useOrganization';
  49. import useProjects from 'sentry/utils/useProjects';
  50. import useRouter from 'sentry/utils/useRouter';
  51. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  52. import {ERROR_TYPES} from './constants';
  53. import GroupHeader from './header';
  54. import SampleEventAlert from './sampleEventAlert';
  55. import {Tab, TabPaths} from './types';
  56. import {
  57. getGroupDetailsQueryData,
  58. getGroupEventDetailsQueryData,
  59. getGroupReprocessingStatus,
  60. markEventSeen,
  61. ReprocessingStatus,
  62. useEnvironmentsFromUrl,
  63. useFetchIssueTagsForDetailsPage,
  64. } from './utils';
  65. type Error = (typeof ERROR_TYPES)[keyof typeof ERROR_TYPES] | null;
  66. type RouterParams = {groupId: string; eventId?: string};
  67. type RouteProps = RouteComponentProps<RouterParams, {}>;
  68. type GroupDetailsProps = {
  69. children: React.ReactNode;
  70. organization: Organization;
  71. projects: Project[];
  72. };
  73. type FetchGroupDetailsState = {
  74. error: boolean;
  75. errorType: Error;
  76. event: Event | null;
  77. eventError: boolean;
  78. group: Group | null;
  79. loadingEvent: boolean;
  80. loadingGroup: boolean;
  81. refetchData: () => void;
  82. refetchGroup: () => void;
  83. };
  84. interface GroupDetailsContentProps extends GroupDetailsProps, FetchGroupDetailsState {
  85. group: Group;
  86. project: Project;
  87. }
  88. function getFetchDataRequestErrorType(status?: number | null): Error {
  89. if (!status) {
  90. return null;
  91. }
  92. if (status === 404) {
  93. return ERROR_TYPES.GROUP_NOT_FOUND;
  94. }
  95. if (status === 403) {
  96. return ERROR_TYPES.MISSING_MEMBERSHIP;
  97. }
  98. return null;
  99. }
  100. function getCurrentTab({router}: {router: RouteProps['router']}) {
  101. const currentRoute = router.routes[router.routes.length - 1];
  102. // If we're in the tag details page ("/tags/:tagKey/")
  103. if (router.params.tagKey) {
  104. return Tab.TAGS;
  105. }
  106. return (
  107. Object.values(Tab).find(tab => currentRoute.path === TabPaths[tab]) ?? Tab.DETAILS
  108. );
  109. }
  110. function getCurrentRouteInfo({
  111. group,
  112. event,
  113. organization,
  114. router,
  115. }: {
  116. event: Event | null;
  117. group: Group;
  118. organization: Organization;
  119. router: RouteProps['router'];
  120. }): {
  121. baseUrl: string;
  122. currentTab: Tab;
  123. } {
  124. const currentTab = getCurrentTab({router});
  125. const baseUrl = normalizeUrl(
  126. `/organizations/${organization.slug}/issues/${group.id}/${
  127. router.params.eventId && event ? `events/${event.id}/` : ''
  128. }`
  129. );
  130. return {baseUrl, currentTab};
  131. }
  132. function getReprocessingNewRoute({
  133. group,
  134. event,
  135. organization,
  136. router,
  137. }: {
  138. event: Event | null;
  139. group: Group;
  140. organization: Organization;
  141. router: RouteProps['router'];
  142. }) {
  143. const {routes, params, location} = router;
  144. const {groupId} = params;
  145. const {currentTab, baseUrl} = getCurrentRouteInfo({group, event, organization, router});
  146. const hasReprocessingV2Feature = organization.features?.includes('reprocessing-v2');
  147. const {id: nextGroupId} = group;
  148. const reprocessingStatus = getGroupReprocessingStatus(group);
  149. if (groupId !== nextGroupId) {
  150. if (hasReprocessingV2Feature) {
  151. // Redirects to the Activities tab
  152. if (
  153. reprocessingStatus === ReprocessingStatus.REPROCESSED_AND_HASNT_EVENT &&
  154. currentTab !== Tab.ACTIVITY
  155. ) {
  156. return {
  157. pathname: `${baseUrl}${Tab.ACTIVITY}/`,
  158. query: {...params, groupId: nextGroupId},
  159. };
  160. }
  161. }
  162. return recreateRoute('', {
  163. routes,
  164. location,
  165. params: {...params, groupId: nextGroupId},
  166. });
  167. }
  168. if (hasReprocessingV2Feature) {
  169. if (
  170. reprocessingStatus === ReprocessingStatus.REPROCESSING &&
  171. currentTab !== Tab.DETAILS
  172. ) {
  173. return {
  174. pathname: baseUrl,
  175. query: params,
  176. };
  177. }
  178. if (
  179. reprocessingStatus === ReprocessingStatus.REPROCESSED_AND_HASNT_EVENT &&
  180. currentTab !== Tab.ACTIVITY &&
  181. currentTab !== Tab.USER_FEEDBACK
  182. ) {
  183. return {
  184. pathname: `${baseUrl}${Tab.ACTIVITY}/`,
  185. query: params,
  186. };
  187. }
  188. }
  189. return undefined;
  190. }
  191. function useRefetchGroupForReprocessing({
  192. refetchGroup,
  193. }: Pick<FetchGroupDetailsState, 'refetchGroup'>) {
  194. const organization = useOrganization();
  195. const hasReprocessingV2Feature = organization.features?.includes('reprocessing-v2');
  196. useEffect(() => {
  197. let refetchInterval: number;
  198. if (hasReprocessingV2Feature) {
  199. refetchInterval = window.setInterval(refetchGroup, 30000);
  200. }
  201. return () => {
  202. window.clearInterval(refetchInterval);
  203. };
  204. }, [hasReprocessingV2Feature, refetchGroup]);
  205. }
  206. function useEventApiQuery(
  207. eventID: string,
  208. queryKey: [string, {query: {environment?: string[]}}]
  209. ) {
  210. const isLatest = eventID === 'latest';
  211. const latestEventQuery = useApiQuery<Event>(queryKey, {
  212. staleTime: 30000,
  213. cacheTime: 30000,
  214. enabled: isLatest,
  215. retry: (_, error) => error.status !== 404,
  216. });
  217. const otherEventQuery = useApiQuery<Event>(queryKey, {
  218. staleTime: Infinity,
  219. enabled: !isLatest,
  220. retry: (_, error) => error.status !== 404,
  221. });
  222. return isLatest ? latestEventQuery : otherEventQuery;
  223. }
  224. type FetchGroupQueryParameters = {
  225. environments: string[];
  226. groupId: string;
  227. };
  228. function makeFetchGroupQueryKey({
  229. groupId,
  230. environments,
  231. }: FetchGroupQueryParameters): ApiQueryKey {
  232. return [`/issues/${groupId}/`, {query: getGroupDetailsQueryData({environments})}];
  233. }
  234. /**
  235. * This is a temporary measure to ensure that the GroupStore and query cache
  236. * are both up to date while we are still using both in the issue details page.
  237. * Once we remove all references to GroupStore in the issue details page we
  238. * should remove this.
  239. */
  240. function useSyncGroupStore(incomingEnvs: string[]) {
  241. const queryClient = useQueryClient();
  242. const environmentsRef = useRef<string[]>(incomingEnvs);
  243. environmentsRef.current = incomingEnvs;
  244. const unlisten = useRef<Function>();
  245. if (unlisten.current === undefined) {
  246. unlisten.current = GroupStore.listen(() => {
  247. const [storeGroup] = GroupStore.getState();
  248. const environments = environmentsRef.current;
  249. if (defined(storeGroup)) {
  250. setApiQueryData(
  251. queryClient,
  252. makeFetchGroupQueryKey({groupId: storeGroup.id, environments}),
  253. storeGroup
  254. );
  255. }
  256. }, undefined);
  257. }
  258. useEffect(() => {
  259. return () => unlisten.current?.();
  260. }, []);
  261. }
  262. function useFetchGroupDetails(): FetchGroupDetailsState {
  263. const api = useApi();
  264. const organization = useOrganization();
  265. const router = useRouter();
  266. const params = router.params;
  267. const [error, setError] = useState<boolean>(false);
  268. const [errorType, setErrorType] = useState<Error | null>(null);
  269. const [event, setEvent] = useState<Event | null>(null);
  270. const [allProjectChanged, setAllProjectChanged] = useState<boolean>(false);
  271. const environments = useEnvironmentsFromUrl();
  272. const groupId = params.groupId;
  273. const eventId = params.eventId ?? 'latest';
  274. const eventUrl = `/issues/${groupId}/events/${eventId}/`;
  275. const {
  276. data: eventData,
  277. isLoading: loadingEvent,
  278. isError,
  279. refetch: refetchEvent,
  280. } = useEventApiQuery(eventId, [
  281. eventUrl,
  282. {query: getGroupEventDetailsQueryData({environments})},
  283. ]);
  284. const {
  285. data: groupData,
  286. isLoading: loadingGroup,
  287. isError: isGroupError,
  288. error: groupError,
  289. refetch: refetchGroupCall,
  290. } = useApiQuery<Group>(makeFetchGroupQueryKey({groupId, environments}), {
  291. staleTime: 30000,
  292. cacheTime: 30000,
  293. });
  294. const group = groupData ?? null;
  295. useEffect(() => {
  296. if (defined(group)) {
  297. GroupStore.loadInitialData([group]);
  298. }
  299. }, [groupId, group]);
  300. useSyncGroupStore(environments);
  301. useEffect(() => {
  302. if (eventData) {
  303. setEvent(eventData);
  304. }
  305. }, [eventData]);
  306. useEffect(() => {
  307. if (group && event) {
  308. const reprocessingNewRoute = getReprocessingNewRoute({
  309. group,
  310. event,
  311. router,
  312. organization,
  313. });
  314. if (reprocessingNewRoute) {
  315. browserHistory.push(reprocessingNewRoute);
  316. return;
  317. }
  318. }
  319. }, [group, event, router, organization]);
  320. useEffect(() => {
  321. const matchingProjectSlug = group?.project?.slug;
  322. if (!matchingProjectSlug) {
  323. return;
  324. }
  325. if (!group.hasSeen) {
  326. markEventSeen(api, organization.slug, matchingProjectSlug, params.groupId);
  327. }
  328. }, [
  329. api,
  330. group?.hasSeen,
  331. group?.project?.id,
  332. group?.project?.slug,
  333. organization.slug,
  334. params.groupId,
  335. ]);
  336. const allProjectsFlag = router.location.query._allp;
  337. useEffect(() => {
  338. const locationQuery = qs.parse(window.location.search) || {};
  339. // We use _allp as a temporary measure to know they came from the
  340. // issue list page with no project selected (all projects included in
  341. // filter).
  342. //
  343. // If it is not defined, we add the locked project id to the URL
  344. // (this is because if someone navigates directly to an issue on
  345. // single-project priveleges, then goes back - they were getting
  346. // assigned to the first project).
  347. //
  348. // If it is defined, we do not so that our back button will bring us
  349. // to the issue list page with no project selected instead of the
  350. // locked project.
  351. if (
  352. locationQuery.project === undefined &&
  353. !allProjectsFlag &&
  354. !allProjectChanged &&
  355. group?.project.id
  356. ) {
  357. locationQuery.project = group?.project.id;
  358. browserHistory.replace({...window.location, query: locationQuery});
  359. }
  360. if (allProjectsFlag && !allProjectChanged) {
  361. delete locationQuery.project;
  362. // We delete _allp from the URL to keep the hack a bit cleaner, but
  363. // this is not an ideal solution and will ultimately be replaced with
  364. // something smarter.
  365. delete locationQuery._allp;
  366. browserHistory.replace({...window.location, query: locationQuery});
  367. setAllProjectChanged(true);
  368. }
  369. }, [allProjectsFlag, group?.project.id, allProjectChanged]);
  370. const handleError = useCallback((e: RequestError) => {
  371. Sentry.captureException(e);
  372. setErrorType(getFetchDataRequestErrorType(e?.status));
  373. setError(true);
  374. }, []);
  375. useEffect(() => {
  376. if (isGroupError) {
  377. handleError(groupError);
  378. }
  379. }, [isGroupError, groupError, handleError]);
  380. const refetchGroup = useCallback(() => {
  381. if (
  382. group?.status !== ReprocessingStatus.REPROCESSING ||
  383. loadingGroup ||
  384. loadingEvent
  385. ) {
  386. return;
  387. }
  388. refetchGroupCall();
  389. }, [group, loadingGroup, loadingEvent, refetchGroupCall]);
  390. const refetchData = useCallback(() => {
  391. // Set initial state
  392. setError(false);
  393. setErrorType(null);
  394. // refetchEvent comes from useApiQuery since event and group data are separately fetched
  395. refetchEvent();
  396. refetchGroup();
  397. }, [refetchGroup, refetchEvent]);
  398. // Refetch when group is stale
  399. useEffect(() => {
  400. if (group) {
  401. if ((group as Group & {stale?: boolean}).stale) {
  402. refetchGroup();
  403. return;
  404. }
  405. }
  406. }, [refetchGroup, group]);
  407. useRefetchGroupForReprocessing({refetchGroup});
  408. useEffect(() => {
  409. return () => {
  410. GroupStore.reset();
  411. };
  412. }, []);
  413. return {
  414. loadingGroup,
  415. loadingEvent,
  416. group,
  417. event,
  418. errorType,
  419. error,
  420. eventError: isError,
  421. refetchData,
  422. refetchGroup,
  423. };
  424. }
  425. function useTrackView({
  426. group,
  427. event,
  428. project,
  429. tab,
  430. }: {
  431. event: Event | null;
  432. group: Group | null;
  433. tab: Tab;
  434. project?: Project;
  435. }) {
  436. const location = useLocation();
  437. const {alert_date, alert_rule_id, alert_type, ref_fallback, stream_index, query} =
  438. location.query;
  439. useRouteAnalyticsEventNames('issue_details.viewed', 'Issue Details: Viewed');
  440. useRouteAnalyticsParams({
  441. ...getAnalyticsDataForGroup(group),
  442. ...getAnalyticsDataForEvent(event),
  443. ...getAnalyicsDataForProject(project),
  444. tab,
  445. stream_index: typeof stream_index === 'string' ? Number(stream_index) : undefined,
  446. query: typeof query === 'string' ? query : undefined,
  447. // Alert properties track if the user came from email/slack alerts
  448. alert_date:
  449. typeof alert_date === 'string' ? getUtcDateString(Number(alert_date)) : undefined,
  450. alert_rule_id: typeof alert_rule_id === 'string' ? alert_rule_id : undefined,
  451. alert_type: typeof alert_type === 'string' ? alert_type : undefined,
  452. ref_fallback,
  453. // Will be updated by StacktraceLink if there is a stacktrace link
  454. stacktrace_link_viewed: false,
  455. // Will be updated by IssueQuickTrace if there is a trace
  456. trace_status: 'none',
  457. // Will be updated in GroupDetailsHeader if there are replays
  458. group_has_replay: false,
  459. });
  460. useDisableRouteAnalytics(!group || !event || !project);
  461. }
  462. const trackTabChanged = ({
  463. organization,
  464. project,
  465. group,
  466. event,
  467. tab,
  468. }: {
  469. event: Event | null;
  470. group: Group;
  471. organization: Organization;
  472. project: Project;
  473. tab: Tab;
  474. }) => {
  475. if (!project || !group) {
  476. return;
  477. }
  478. trackAnalytics('issue_details.tab_changed', {
  479. organization,
  480. project_id: parseInt(project.id, 10),
  481. tab,
  482. ...getAnalyticsDataForGroup(group),
  483. });
  484. if (group.issueCategory !== IssueCategory.ERROR) {
  485. return;
  486. }
  487. const analyticsData = event
  488. ? event.tags
  489. .filter(({key}) => ['device', 'os', 'browser'].includes(key))
  490. .reduce((acc, {key, value}) => {
  491. acc[key] = value;
  492. return acc;
  493. }, {})
  494. : {};
  495. trackAnalytics('issue_group_details.tab.clicked', {
  496. organization,
  497. tab,
  498. platform: project.platform,
  499. ...analyticsData,
  500. });
  501. };
  502. function GroupDetailsContentError({
  503. errorType,
  504. onRetry,
  505. }: {
  506. errorType: Error;
  507. onRetry: () => void;
  508. }) {
  509. const organization = useOrganization();
  510. const location = useLocation();
  511. const projectId = location.query.project;
  512. const {projects} = useProjects();
  513. const project = projects.find(proj => proj.id === projectId);
  514. switch (errorType) {
  515. case ERROR_TYPES.GROUP_NOT_FOUND:
  516. return (
  517. <StyledLoadingError
  518. message={t('The issue you were looking for was not found.')}
  519. />
  520. );
  521. case ERROR_TYPES.MISSING_MEMBERSHIP:
  522. return <MissingProjectMembership organization={organization} project={project} />;
  523. default:
  524. return <StyledLoadingError onRetry={onRetry} />;
  525. }
  526. }
  527. function GroupDetailsContent({
  528. children,
  529. group,
  530. project,
  531. loadingEvent,
  532. eventError,
  533. event,
  534. refetchData,
  535. }: GroupDetailsContentProps) {
  536. const organization = useOrganization();
  537. const router = useRouter();
  538. const {currentTab, baseUrl} = getCurrentRouteInfo({group, event, router, organization});
  539. const groupReprocessingStatus = getGroupReprocessingStatus(group);
  540. const environments = useEnvironmentsFromUrl();
  541. useTrackView({group, event, project, tab: currentTab});
  542. useEffect(() => {
  543. if (
  544. currentTab === Tab.DETAILS &&
  545. group &&
  546. event &&
  547. group.id !== event?.groupID &&
  548. !eventError
  549. ) {
  550. // if user pastes only the event id into the url, but it's from another group, redirect to correct group/event
  551. const redirectUrl = `/organizations/${organization.slug}/issues/${event.groupID}/events/${event.id}/`;
  552. router.push(normalizeUrl(redirectUrl));
  553. }
  554. }, [currentTab, event, eventError, group, organization.slug, router]);
  555. const childProps = {
  556. environments,
  557. group,
  558. project,
  559. event,
  560. loadingEvent,
  561. eventError,
  562. groupReprocessingStatus,
  563. onRetry: refetchData,
  564. baseUrl,
  565. };
  566. return (
  567. <Tabs
  568. value={currentTab}
  569. onChange={tab => trackTabChanged({tab, group, project, event, organization})}
  570. >
  571. <GroupHeader
  572. organization={organization}
  573. groupReprocessingStatus={groupReprocessingStatus}
  574. event={event ?? undefined}
  575. group={group}
  576. baseUrl={baseUrl}
  577. project={project as Project}
  578. />
  579. <GroupTabPanels>
  580. <TabPanels.Item key={currentTab}>
  581. {isValidElement(children) ? cloneElement(children, childProps) : children}
  582. </TabPanels.Item>
  583. </GroupTabPanels>
  584. </Tabs>
  585. );
  586. }
  587. function GroupDetailsPageContent(props: GroupDetailsProps & FetchGroupDetailsState) {
  588. const projectSlug = props.group?.project?.slug;
  589. const {
  590. projects,
  591. initiallyLoaded: projectsLoaded,
  592. fetchError: errorFetchingProjects,
  593. } = useProjects({slugs: projectSlug ? [projectSlug] : []});
  594. const project = projects.find(({slug}) => slug === projectSlug);
  595. const projectWithFallback = project ?? projects[0];
  596. useEffect(() => {
  597. if (props.group && projectsLoaded && !project) {
  598. Sentry.withScope(scope => {
  599. const projectIds = projects.map(item => item.id);
  600. scope.setContext('missingProject', {
  601. projectId: props.group?.project.id,
  602. availableProjects: projectIds,
  603. });
  604. Sentry.captureException(new Error('Project not found'));
  605. });
  606. }
  607. }, [props.group, project, projects, projectsLoaded]);
  608. if (props.error) {
  609. return (
  610. <GroupDetailsContentError errorType={props.errorType} onRetry={props.refetchData} />
  611. );
  612. }
  613. if (errorFetchingProjects) {
  614. return <StyledLoadingError message={t('Error loading the specified project')} />;
  615. }
  616. if (projectSlug && !errorFetchingProjects && projectsLoaded && !projectWithFallback) {
  617. return (
  618. <StyledLoadingError message={t('The project %s does not exist', projectSlug)} />
  619. );
  620. }
  621. if (!projectsLoaded || !projectWithFallback || !props.group) {
  622. return <LoadingIndicator />;
  623. }
  624. return (
  625. <GroupDetailsContent {...props} project={projectWithFallback} group={props.group} />
  626. );
  627. }
  628. function GroupDetails(props: GroupDetailsProps) {
  629. const organization = useOrganization();
  630. const router = useRouter();
  631. const {group, ...fetchGroupDetailsProps} = useFetchGroupDetails();
  632. const environments = useEnvironmentsFromUrl();
  633. const {data} = useFetchIssueTagsForDetailsPage(
  634. {
  635. groupId: router.params.groupId,
  636. environment: environments,
  637. },
  638. // Don't want this query to take precedence over the main requests
  639. {enabled: defined(group)}
  640. );
  641. const isSampleError = data?.some(tag => tag.key === 'sample_event') ?? false;
  642. const getGroupDetailsTitle = () => {
  643. const defaultTitle = 'Sentry';
  644. if (!group) {
  645. return defaultTitle;
  646. }
  647. const {title} = getTitle(group, organization?.features);
  648. const message = getMessage(group);
  649. const eventDetails = `${organization.slug} — ${group.project.slug}`;
  650. if (title && message) {
  651. return `${title}: ${message} — ${eventDetails}`;
  652. }
  653. return `${title || message || defaultTitle} — ${eventDetails}`;
  654. };
  655. return (
  656. <Fragment>
  657. {isSampleError && group && (
  658. <SampleEventAlert project={group.project} organization={organization} />
  659. )}
  660. <SentryDocumentTitle noSuffix title={getGroupDetailsTitle()}>
  661. <PageFiltersContainer
  662. skipLoadLastUsed
  663. forceProject={group?.project}
  664. shouldForceProject
  665. >
  666. <GroupDetailsPageContent
  667. {...props}
  668. {...{
  669. group,
  670. ...fetchGroupDetailsProps,
  671. }}
  672. />
  673. </PageFiltersContainer>
  674. </SentryDocumentTitle>
  675. </Fragment>
  676. );
  677. }
  678. export default Sentry.withProfiler(GroupDetails);
  679. const StyledLoadingError = styled(LoadingError)`
  680. margin: ${space(2)};
  681. `;
  682. const GroupTabPanels = styled(TabPanels)`
  683. flex-grow: 1;
  684. display: flex;
  685. flex-direction: column;
  686. justify-content: stretch;
  687. `;