import {Fragment} from 'react'; import {browserHistory} from 'react-router'; import styled from '@emotion/styled'; import {Location} from 'history'; import BreakdownBars from 'sentry/components/charts/breakdownBars'; import ErrorPanel from 'sentry/components/charts/errorPanel'; import {SectionHeading} from 'sentry/components/charts/styles'; import EmptyStateWarning from 'sentry/components/emptyStateWarning'; import Placeholder from 'sentry/components/placeholder'; import QuestionTooltip from 'sentry/components/questionTooltip'; import {IconWarning} from 'sentry/icons'; import {t} from 'sentry/locale'; import {Organization} from 'sentry/types'; import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent'; import DiscoverQuery from 'sentry/utils/discover/discoverQuery'; import EventView from 'sentry/utils/discover/eventView'; import {MutableSearch} from 'sentry/utils/tokenizeSearch'; import {getTermHelp, PERFORMANCE_TERM} from 'sentry/views/performance/data'; type Props = { eventView: EventView; location: Location; organization: Organization; }; function StatusBreakdown({eventView, location, organization}: Props) { const useEvents = organization.features.includes( 'performance-frontend-use-events-endpoint' ); const breakdownView = eventView .withColumns([ {kind: 'function', function: ['count', '', '', undefined]}, {kind: 'field', field: 'transaction.status'}, ]) .withSorts([{kind: 'desc', field: 'count'}]); return ( {t('Status Breakdown')} {({isLoading, error, tableData}) => { if (isLoading) { return ; } if (error) { return ( ); } if (!tableData || tableData.data.length === 0) { return ( {t('No statuses found')} ); } const points = tableData.data.map(row => ({ label: String(row['transaction.status']), value: parseInt(String(row[useEvents ? 'count()' : 'count']), 10), onClick: () => { const query = new MutableSearch(eventView.query); query .removeFilter('!transaction.status') .setFilterValues('transaction.status', [ row['transaction.status'] as string, ]); browserHistory.push({ pathname: location.pathname, query: { ...location.query, cursor: undefined, query: query.formatString(), }, }); trackAdvancedAnalyticsEvent( 'performance_views.transaction_summary.status_breakdown_click', { organization, status: row['transaction.status'] as string, } ); }, })); return ; }} ); } const EmptyStatusBreakdown = styled(EmptyStateWarning)` height: 124px; padding: 50px 15%; `; export default StatusBreakdown;