groupDetails.tsx 21 KB

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