import {useEffect, useMemo} from 'react'; import styled from '@emotion/styled'; import {LocationDescriptor} from 'history'; import omit from 'lodash/omit'; import GuideAnchor from 'sentry/components/assistant/guideAnchor'; import Badge from 'sentry/components/badge'; import Breadcrumbs from 'sentry/components/breadcrumbs'; import Count from 'sentry/components/count'; import EnvironmentPageFilter from 'sentry/components/environmentPageFilter'; import EventOrGroupTitle from 'sentry/components/eventOrGroupTitle'; import ErrorLevel from 'sentry/components/events/errorLevel'; import EventMessage from 'sentry/components/events/eventMessage'; import FeatureBadge from 'sentry/components/featureBadge'; import InboxReason from 'sentry/components/group/inboxBadges/inboxReason'; import {GroupStatusBadge} from 'sentry/components/group/inboxBadges/statusBadge'; import UnhandledInboxTag from 'sentry/components/group/inboxBadges/unhandledTag'; import ProjectBadge from 'sentry/components/idBadge/projectBadge'; import * as Layout from 'sentry/components/layouts/thirds'; import Link from 'sentry/components/links/link'; import ReplayCountBadge from 'sentry/components/replays/replayCountBadge'; import useReplaysCount from 'sentry/components/replays/useReplaysCount'; import ShortId from 'sentry/components/shortId'; import {TabList} from 'sentry/components/tabs'; import {Tooltip} from 'sentry/components/tooltip'; import {IconChat} from 'sentry/icons'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {Event, Group, IssueType, Organization, Project} from 'sentry/types'; import {trackAnalytics} from 'sentry/utils/analytics'; import {getMessage} from 'sentry/utils/events'; import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig'; import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams'; import {useLocation} from 'sentry/utils/useLocation'; import useOrganization from 'sentry/utils/useOrganization'; import GroupActions from './actions'; import {Tab} from './types'; import {TagAndMessageWrapper} from './unhandledTag'; import {ReprocessingStatus} from './utils'; type Props = { baseUrl: string; group: Group; groupReprocessingStatus: ReprocessingStatus; organization: Organization; project: Project; event?: Event; }; interface GroupHeaderTabsProps extends Pick { disabledTabs: Tab[]; eventRoute: LocationDescriptor; } function GroupHeaderTabs({ baseUrl, disabledTabs, eventRoute, group, project, }: GroupHeaderTabsProps) { const organization = useOrganization(); const replaysCount = useReplaysCount({ groupIds: group.id, organization, })[group.id]; const projectFeatures = new Set(project ? project.features : []); const organizationFeatures = new Set(organization ? organization.features : []); const hasGroupingTreeUI = organizationFeatures.has('grouping-tree-ui'); const hasSimilarView = projectFeatures.has('similarity-view'); const hasEventAttachments = organizationFeatures.has('event-attachments'); const hasReplaySupport = organizationFeatures.has('session-replay'); const issueTypeConfig = getConfigForIssueType(group); useEffect(() => { if (!hasReplaySupport || typeof replaysCount === 'undefined') { return; } trackAnalytics('replay.render-issues-detail-count', { platform: project.platform!, project_id: project.id, count: replaysCount, organization, }); }, [hasReplaySupport, replaysCount, project, organization]); useRouteAnalyticsParams({ group_has_replay: (replaysCount ?? 0) > 0, }); return ( {t('Details')} {t('Activity')} {group.numComments} {t('Tags')} {t('All Events')} ); } function GroupHeader({ baseUrl, group, groupReprocessingStatus, organization, event, project, }: Props) { const location = useLocation(); const hasEscalatingIssuesUi = organization.features.includes('escalating-issues-ui'); const disabledTabs = useMemo(() => { const hasReprocessingV2Feature = organization.features.includes('reprocessing-v2'); if (!hasReprocessingV2Feature) { return []; } if (groupReprocessingStatus === ReprocessingStatus.REPROCESSING) { return [ Tab.ACTIVITY, Tab.USER_FEEDBACK, Tab.ATTACHMENTS, Tab.EVENTS, Tab.MERGED, Tab.GROUPING, Tab.SIMILAR_ISSUES, Tab.TAGS, ]; } if (groupReprocessingStatus === ReprocessingStatus.REPROCESSED_AND_HASNT_EVENT) { return [ Tab.DETAILS, Tab.ATTACHMENTS, Tab.EVENTS, Tab.MERGED, Tab.GROUPING, Tab.SIMILAR_ISSUES, Tab.TAGS, Tab.USER_FEEDBACK, ]; } return []; }, [organization, groupReprocessingStatus]); const eventRoute = useMemo(() => { const searchTermWithoutQuery = omit(location.query, 'query'); return { pathname: `${baseUrl}events/`, query: searchTermWithoutQuery, }; }, [location, baseUrl]); const {userCount} = group; let className = 'group-detail'; if (group.hasSeen) { className += ' hasSeen'; } if (group.status === 'resolved') { className += ' isResolved'; } const message = getMessage(group); const disableActions = !!disabledTabs.length; const shortIdBreadCrumb = group.shortId && ( {group.issueType === IssueType.PERFORMANCE_CONSECUTIVE_DB_QUERIES && ( )} {group.issueType === IssueType.PERFORMANCE_SLOW_DB_QUERY && ( )} {group.issueType === IssueType.PERFORMANCE_CONSECUTIVE_DB_QUERIES && ( )} {group.issueType === IssueType.PERFORMANCE_RENDER_BLOCKING_ASSET && ( )} ); return (

{!hasEscalatingIssuesUi && group.inbox && ( )} {hasEscalatingIssuesUi && ( )}
{group.level && } {group.isUnhandled && }
{t('Events')}
{t('Users')}
{userCount !== 0 ? ( ) : ( 0 )}
{/* Environment picker for mobile */}
); } export default GroupHeader; const BreadcrumbActionWrapper = styled('div')` display: flex; flex-direction: row; justify-content: space-between; gap: ${space(1)}; align-items: center; `; const ShortIdBreadrcumb = styled('div')` display: flex; gap: ${space(1)}; align-items: center; `; const StyledShortId = styled(ShortId)` font-family: ${p => p.theme.text.family}; font-size: ${p => p.theme.fontSizeMedium}; line-height: 1; `; const HeaderRow = styled('div')` display: flex; gap: ${space(2)}; justify-content: space-between; margin-top: ${space(2)}; @media (max-width: ${p => p.theme.breakpoints.small}) { flex-direction: column; } `; const TitleWrapper = styled('div')` @media (min-width: ${p => p.theme.breakpoints.small}) { max-width: 65%; } `; const TitleHeading = styled('div')` display: flex; line-height: 2; gap: ${space(1)}; `; const StyledEventOrGroupTitle = styled(EventOrGroupTitle)` font-size: inherit; `; const StatsWrapper = styled('div')` display: grid; grid-template-columns: repeat(2, min-content); gap: calc(${space(3)} + ${space(3)}); @media (min-width: ${p => p.theme.breakpoints.small}) { justify-content: flex-end; } `; const StyledTagAndMessageWrapper = styled(TagAndMessageWrapper)` display: flex; gap: ${space(1)}; justify-content: flex-start; line-height: 1.2; `; const IconBadge = styled(Badge)` display: flex; align-items: center; gap: ${space(0.5)}; `; const StyledTabList = styled(TabList)` margin-top: ${space(2)}; `;