123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- import type {Location, LocationDescriptor} from 'history';
- import type {Crumb} from 'sentry/components/breadcrumbs';
- import Breadcrumbs from 'sentry/components/breadcrumbs';
- import {t} from 'sentry/locale';
- import type {Organization} from 'sentry/types';
- import type {SpanSlug} from 'sentry/utils/performance/suspectSpans/types';
- import {decodeScalar} from 'sentry/utils/queryString';
- import Tab from './transactionSummary/tabs';
- import {eventsRouteWithQuery} from './transactionSummary/transactionEvents/utils';
- import {spansRouteWithQuery} from './transactionSummary/transactionSpans/utils';
- import {tagsRouteWithQuery} from './transactionSummary/transactionTags/utils';
- import {vitalsRouteWithQuery} from './transactionSummary/transactionVitals/utils';
- import {transactionSummaryRouteWithQuery} from './transactionSummary/utils';
- import {vitalDetailRouteWithQuery} from './vitalDetail/utils';
- import {getPerformanceLandingUrl} from './utils';
- type Props = {
- location: Location;
- organization: Organization;
- eventSlug?: string;
- spanSlug?: SpanSlug;
- tab?: Tab;
- traceSlug?: string;
- transaction?: {
- name: string;
- project: string;
- };
- vitalName?: string;
- };
- function Breadcrumb(props: Props) {
- function getCrumbs() {
- const crumbs: Crumb[] = [];
- const {
- organization,
- location,
- transaction,
- vitalName,
- spanSlug,
- eventSlug,
- traceSlug,
- tab,
- } = props;
- const performanceTarget: LocationDescriptor = {
- pathname: getPerformanceLandingUrl(organization),
- query: {
- ...location.query,
- // clear out the transaction name
- transaction: undefined,
- },
- };
- crumbs.push({
- to: performanceTarget,
- label: t('Performance'),
- preservePageFilters: true,
- });
- if (vitalName) {
- const webVitalsTarget = vitalDetailRouteWithQuery({
- orgSlug: organization.slug,
- vitalName: 'fcp',
- projectID: decodeScalar(location.query.project),
- query: location.query,
- });
- crumbs.push({
- to: webVitalsTarget,
- label: t('Vital Detail'),
- preservePageFilters: true,
- });
- } else if (transaction) {
- const routeQuery = {
- orgSlug: organization.slug,
- transaction: transaction.name,
- projectID: transaction.project,
- query: location.query,
- };
- switch (tab) {
- case Tab.TAGS: {
- const tagsTarget = tagsRouteWithQuery(routeQuery);
- crumbs.push({
- to: tagsTarget,
- label: t('Tags'),
- preservePageFilters: true,
- });
- break;
- }
- case Tab.EVENTS: {
- const eventsTarget = eventsRouteWithQuery(routeQuery);
- crumbs.push({
- to: eventsTarget,
- label: t('All Events'),
- preservePageFilters: true,
- });
- break;
- }
- case Tab.WEB_VITALS: {
- const webVitalsTarget = vitalsRouteWithQuery(routeQuery);
- crumbs.push({
- to: webVitalsTarget,
- label: t('Web Vitals'),
- preservePageFilters: true,
- });
- break;
- }
- case Tab.SPANS: {
- const spansTarget = spansRouteWithQuery(routeQuery);
- crumbs.push({
- to: spansTarget,
- label: t('Spans'),
- preservePageFilters: true,
- });
- break;
- }
- case Tab.TRANSACTION_SUMMARY:
- default: {
- const summaryTarget = transactionSummaryRouteWithQuery(routeQuery);
- crumbs.push({
- to: summaryTarget,
- label: t('Transaction Summary'),
- preservePageFilters: true,
- });
- }
- }
- }
- if (transaction && spanSlug) {
- crumbs.push({
- to: '',
- label: t('Span Summary'),
- });
- } else if (transaction && eventSlug) {
- crumbs.push({
- to: '',
- label: t('Event Details'),
- });
- } else if (traceSlug) {
- crumbs.push({
- to: '',
- label: t('Trace'),
- });
- }
- return crumbs;
- }
- return <Breadcrumbs crumbs={getCrumbs()} />;
- }
- export default Breadcrumb;
|