123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- 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/organization';
- import type {SpanSlug} from 'sentry/utils/performance/suspectSpans/types';
- import {decodeScalar} from 'sentry/utils/queryString';
- import type {DomainView} from 'sentry/views/insights/pages/useFilters';
- 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,
- });
- crumbs.push(
- ...getTabCrumbs({
- location,
- organization,
- transaction,
- vitalName,
- spanSlug,
- eventSlug,
- traceSlug,
- tab,
- })
- );
- return crumbs;
- }
- return <Breadcrumbs crumbs={getCrumbs()} />;
- }
- export const getTabCrumbs = ({
- location,
- organization,
- transaction,
- vitalName,
- spanSlug,
- eventSlug,
- traceSlug,
- tab,
- view,
- }: {
- location: Location;
- organization: Organization;
- eventSlug?: string;
- spanSlug?: SpanSlug;
- tab?: Tab;
- traceSlug?: string;
- transaction?: {
- name: string;
- project: string;
- };
- view?: DomainView;
- vitalName?: string;
- }) => {
- const crumbs: Crumb[] = [];
- 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,
- view,
- };
- 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.REPLAYS: {
- crumbs.push({
- label: t('Replays'),
- });
- break;
- }
- case Tab.PROFILING: {
- crumbs.push({
- label: t('Profiles'),
- });
- break;
- }
- case Tab.AGGREGATE_WATERFALL: {
- crumbs.push({
- label: t('Aggregate Spans'),
- });
- 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 Details'),
- });
- }
- return crumbs;
- };
- export default Breadcrumb;
|