import {Fragment, ReactNode} from 'react'; import queryString from 'query-string'; import FeatureBadge from 'sentry/components/featureBadge'; import ExternalLink from 'sentry/components/links/externalLink'; import ListLink from 'sentry/components/links/listLink'; import ScrollableTabs from 'sentry/components/replays/scrollableTabs'; import {Tooltip} from 'sentry/components/tooltip'; import {t} from 'sentry/locale'; import type {Organization} from 'sentry/types'; import {trackAnalytics} from 'sentry/utils/analytics'; import useActiveReplayTab, {TabKey} from 'sentry/utils/replays/hooks/useActiveReplayTab'; import {useLocation} from 'sentry/utils/useLocation'; import useOrganization from 'sentry/utils/useOrganization'; function getReplayTabs(organization: Organization): Record { const hasA11yTab = organization.features.includes('session-replay-a11y-tab'); const hasPerfTab = organization.features.includes('session-replay-trace-table'); return { [TabKey.CONSOLE]: t('Console'), [TabKey.NETWORK]: t('Network'), [TabKey.ERRORS]: ( {t('Errors')} ), [TabKey.TRACE]: t('Trace'), [TabKey.PERF]: hasPerfTab ? ( {t('Perf')} ) : null, [TabKey.DOM]: t('DOM Events'), [TabKey.A11Y]: hasA11yTab ? ( {t('What is accessibility?')} } > {t('a11y')} ) : null, [TabKey.MEMORY]: t('Memory'), }; } type Props = { className?: string; }; function FocusTabs({className}: Props) { const organization = useOrganization(); const {pathname, query} = useLocation(); const {getActiveTab, setActiveTab} = useActiveReplayTab(); const activeTab = getActiveTab(); return ( {Object.entries(getReplayTabs(organization)).map(([tab, label]) => label ? ( tab === activeTab} to={`${pathname}?${queryString.stringify({...query, t_main: tab})}`} onClick={e => { e.preventDefault(); setActiveTab(tab); trackAnalytics('replay.details-tab-changed', { tab, organization, }); }} > {label} ) : null )} ); } export default FocusTabs;