groupDetails.tsx 21 KB

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