import {Fragment} from 'react'; import styled from '@emotion/styled'; import type {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 type {Organization} from 'sentry/types/organization'; import type EventView from 'sentry/utils/discover/eventView'; import type {QueryError} from 'sentry/utils/discover/genericDiscoverQuery'; import {WebVital} from 'sentry/utils/fields'; import {useMetricsCardinalityContext} from 'sentry/utils/performance/contexts/metricsCardinality'; import {useMEPSettingContext} from 'sentry/utils/performance/contexts/metricsEnhancedSetting'; import {decodeScalar} from 'sentry/utils/queryString'; import {getTermHelp, PerformanceTerm} from 'sentry/views/performance/data'; import {getTransactionMEPParamsIfApplicable} from 'sentry/views/performance/transactionSummary/transactionOverview/utils'; 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 hasTransactionSummaryCleanupFlag = organization.features.includes( 'performance-transaction-summary-cleanup' ); let userMisery = error !== null ?
{'\u2014'}
: ; if (!isLoading && error === null && totals) { const threshold: number | undefined = totals.project_threshold_config ? totals.project_threshold_config[1] : undefined; const miserableUsers: number | undefined = totals['count_miserable_user()']; const userMiseryScore: number = totals['user_misery()'] || 0; const totalUsers = totals['count_unique_user()']; userMisery = ( ); } const orgSlug = organization.slug; const webVitalsTarget = vitalsRouteWithQuery({ orgSlug, transaction: transactionName, projectID: decodeScalar(location.query.project), query: location.query, }); const mepSetting = useMEPSettingContext(); const mepCardinalityContext = useMetricsCardinalityContext(); const queryExtras = getTransactionMEPParamsIfApplicable( mepSetting, mepCardinalityContext, organization ); return ( {hasWebVitals && ( {t('Web Vitals')} )} {!hasTransactionSummaryCleanupFlag && ( {t('User Misery')} {userMisery} )} ); } const VitalsHeading = styled('div')` display: flex; justify-content: space-between; align-items: center; `; export default UserStats;