traceMetadataHeader.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {useCallback, useMemo} from 'react';
  2. import ButtonBar from 'sentry/components/buttonBar';
  3. import DiscoverButton from 'sentry/components/discoverButton';
  4. import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
  5. import * as Layout from 'sentry/components/layouts/thirds';
  6. import {t} from 'sentry/locale';
  7. import type {Organization} from 'sentry/types/organization';
  8. import {trackAnalytics} from 'sentry/utils/analytics';
  9. import type EventView from 'sentry/utils/discover/eventView';
  10. import {useLocation} from 'sentry/utils/useLocation';
  11. import Breadcrumb from '../breadcrumb';
  12. interface TraceMetadataHeaderProps {
  13. organization: Organization;
  14. projectID: string;
  15. title: string;
  16. traceEventView: EventView;
  17. traceSlug: string;
  18. }
  19. export function TraceMetadataHeader(props: TraceMetadataHeaderProps) {
  20. const location = useLocation();
  21. const breadcrumbTransaction = useMemo(() => {
  22. return {
  23. project: props.projectID ?? '',
  24. name: props.title ?? '',
  25. };
  26. }, [props.projectID, props.title]);
  27. const trackOpenInDiscover = useCallback(() => {
  28. trackAnalytics('performance_views.trace_view.open_in_discover', {
  29. organization: props.organization,
  30. });
  31. }, [props.organization]);
  32. return (
  33. <Layout.Header>
  34. <Layout.HeaderContent>
  35. <Breadcrumb
  36. organization={props.organization}
  37. location={location}
  38. transaction={breadcrumbTransaction}
  39. traceSlug={props.traceSlug}
  40. />
  41. </Layout.HeaderContent>
  42. <Layout.HeaderActions>
  43. <ButtonBar gap={1}>
  44. <DiscoverButton
  45. size="sm"
  46. to={props.traceEventView.getResultsViewUrlTarget(props.organization.slug)}
  47. onClick={trackOpenInDiscover}
  48. >
  49. {t('Open in Discover')}
  50. </DiscoverButton>
  51. <FeedbackWidgetButton />
  52. </ButtonBar>
  53. </Layout.HeaderActions>
  54. </Layout.Header>
  55. );
  56. }