import {Location} from 'history'; import Feature from 'sentry/components/acl/feature'; import FeatureDisabled from 'sentry/components/acl/featureDisabled'; import ErrorBoundary from 'sentry/components/errorBoundary'; import {Hovercard} from 'sentry/components/hovercard'; import ExternalLink from 'sentry/components/links/externalLink'; import Link from 'sentry/components/links/link'; import Placeholder from 'sentry/components/placeholder'; import QuickTrace from 'sentry/components/quickTrace'; import {generateTraceTarget} from 'sentry/components/quickTrace/utils'; import {t, tct, tn} from 'sentry/locale'; import {AvatarProject, OrganizationSummary} from 'sentry/types'; import {Event} from 'sentry/types/event'; import {trackAnalytics} from 'sentry/utils/analytics'; import {getConfigureTracingDocsLink} from 'sentry/utils/docs'; import {getShortEventId} from 'sentry/utils/events'; import { QuickTraceQueryChildrenProps, TraceMeta, } from 'sentry/utils/performance/quickTrace/types'; import useOrganization from 'sentry/utils/useOrganization'; import {MetaData} from './styles'; interface Props extends Pick, 'errorDest' | 'transactionDest'> { anchor: 'left' | 'right'; event: Event; location: Location; quickTrace: QuickTraceQueryChildrenProps | null; traceMeta: TraceMeta | null; project?: AvatarProject; } function handleTraceLink(organization: OrganizationSummary) { trackAnalytics('quick_trace.trace_id.clicked', { organization: organization.id, source: 'events', }); } export default function QuickTraceMeta({ event, location, quickTrace, traceMeta, anchor, errorDest, transactionDest, project, }: Props) { const organization = useOrganization(); const features = ['performance-view']; const noFeatureMessage = t('Requires performance monitoring.'); const docsLink = getConfigureTracingDocsLink(project); const traceId = event.contexts?.trace?.trace_id ?? null; const traceTarget = generateTraceTarget(event, organization); let body: React.ReactNode; let footer: React.ReactNode; if (!traceId || !quickTrace || quickTrace.trace === null) { // this platform doesn't support performance don't show anything here if (docsLink === null) { return null; } body = t('Missing Trace'); // need to configure tracing footer = {t('Read the docs')}; } else { if (quickTrace.isLoading) { body = ; } else if (quickTrace.error) { body = '\u2014'; } else { body = ( ); } footer = ( handleTraceLink(organization)}> {tct('View Full Trace: [id][events]', { id: getShortEventId(traceId ?? ''), events: traceMeta ? tn(' (%s event)', ' (%s events)', traceMeta.transactions + traceMeta.errors) : '', })} ); } return ( {({hasFeature}) => { // also need to enable the performance feature if (!hasFeature) { footer = ( } > {footer} ); } return ; }} ); } export function QuickTraceMetaBase({ body, footer, }: { body: React.ReactNode; footer: React.ReactNode; }) { return ( {body}} subtext={
{footer}
} /> ); }