import {Fragment} from 'react'; import styled from '@emotion/styled'; import {Location} from 'history'; import GuideAnchor from 'sentry/components/assistant/guideAnchor'; import {SectionHeading} from 'sentry/components/charts/styles'; import Link from 'sentry/components/links/link'; import Placeholder from 'sentry/components/placeholder'; import QuestionTooltip from 'sentry/components/questionTooltip'; import UserMisery from 'sentry/components/userMisery'; import {IconOpen} from 'sentry/icons'; import {t} from 'sentry/locale'; import {Organization} from 'sentry/types'; import EventView from 'sentry/utils/discover/eventView'; import {QueryError} from 'sentry/utils/discover/genericDiscoverQuery'; import {WebVital} from 'sentry/utils/fields'; import {decodeScalar} from 'sentry/utils/queryString'; import {getTermHelp, PERFORMANCE_TERM} from 'sentry/views/performance/data'; import {vitalsRouteWithQuery} from 'sentry/views/performance/transactionSummary/transactionVitals/utils'; import {SidebarSpacer} from 'sentry/views/performance/transactionSummary/utils'; import VitalInfo from 'sentry/views/performance/vitalDetail/vitalInfo'; type Props = { error: QueryError | null; eventView: EventView; hasWebVitals: boolean; isLoading: boolean; location: Location; organization: Organization; totals: Record | null; transactionName: string; }; function UserStats({ isLoading, hasWebVitals, error, totals, location, organization, transactionName, eventView, }: Props) { const useAggregateAlias = !organization.features.includes( 'performance-frontend-use-events-endpoint' ); let userMisery = error !== null ?
{'\u2014'}
: ; if (!isLoading && error === null && totals) { const threshold: number | undefined = totals.project_threshold_config[1]; const miserableUsers: number | undefined = useAggregateAlias ? totals.count_miserable_user : totals['count_miserable_user()']; const userMiseryScore: number = useAggregateAlias ? totals.user_misery : totals['user_misery()']; const totalUsers = useAggregateAlias ? totals.count_unique_user : totals['count_unique_user()']; userMisery = ( ); } const orgSlug = organization.slug; const webVitalsTarget = vitalsRouteWithQuery({ orgSlug, transaction: transactionName, projectID: decodeScalar(location.query.project), query: location.query, }); return ( {hasWebVitals && ( {t('Web Vitals')} )} {t('User Misery')} {userMisery} ); } const VitalsHeading = styled('div')` display: flex; justify-content: space-between; align-items: center; `; export default UserStats;