missingPerformanceButtons.tsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {navigateTo} from 'sentry/actionCreators/navigation';
  2. import Feature from 'sentry/components/acl/feature';
  3. import {Button} from 'sentry/components/button';
  4. import ButtonBar from 'sentry/components/buttonBar';
  5. import FeatureTourModal from 'sentry/components/modals/featureTourModal';
  6. import {t} from 'sentry/locale';
  7. import type {Organization} from 'sentry/types/organization';
  8. import {trackAnalytics} from 'sentry/utils/analytics';
  9. import usePageFilters from 'sentry/utils/usePageFilters';
  10. import useProjects from 'sentry/utils/useProjects';
  11. import useRouter from 'sentry/utils/useRouter';
  12. import type {DomainView} from 'sentry/views/insights/pages/useFilters';
  13. import {PERFORMANCE_TOUR_STEPS} from 'sentry/views/performance/onboarding';
  14. import {
  15. getPerformanceBaseUrl,
  16. platformToDomainView,
  17. } from 'sentry/views/performance/utils';
  18. const DOCS_URL = 'https://docs.sentry.io/performance-monitoring/getting-started/';
  19. type Props = {
  20. organization: Organization;
  21. };
  22. function MissingPerformanceButtons({organization}: Props) {
  23. const router = useRouter();
  24. const {projects} = useProjects();
  25. const {
  26. selection: {projects: selectedProjects},
  27. } = usePageFilters();
  28. function handleTourAdvance(step: number, duration: number) {
  29. trackAnalytics('project_detail.performance_tour.advance', {
  30. organization,
  31. step,
  32. duration,
  33. });
  34. }
  35. function handleClose(step: number, duration: number) {
  36. trackAnalytics('project_detail.performance_tour.close', {
  37. organization,
  38. step,
  39. duration,
  40. });
  41. }
  42. const hasPerfLandingRemovalFlag = organization.features?.includes(
  43. 'insights-performance-landing-removal'
  44. );
  45. const domainView: DomainView | undefined = platformToDomainView(
  46. projects,
  47. selectedProjects
  48. );
  49. return (
  50. <Feature
  51. hookName="feature-disabled:project-performance-score-card"
  52. features="performance-view"
  53. organization={organization}
  54. >
  55. <ButtonBar gap={1}>
  56. <Button
  57. size="sm"
  58. priority="primary"
  59. onClick={event => {
  60. event.preventDefault();
  61. // TODO: add analytics here for this specific action.
  62. navigateTo(
  63. `${hasPerfLandingRemovalFlag ? getPerformanceBaseUrl(organization.slug) : getPerformanceBaseUrl(organization.slug, domainView)}/?project=:project#performance-sidequest`,
  64. router
  65. );
  66. }}
  67. >
  68. {t('Start Setup')}
  69. </Button>
  70. <FeatureTourModal
  71. steps={PERFORMANCE_TOUR_STEPS}
  72. onAdvance={handleTourAdvance}
  73. onCloseModal={handleClose}
  74. doneText={t('Start Setup')}
  75. doneUrl={DOCS_URL}
  76. >
  77. {({showModal}) => (
  78. <Button size="sm" onClick={showModal}>
  79. {t('Get Tour')}
  80. </Button>
  81. )}
  82. </FeatureTourModal>
  83. </ButtonBar>
  84. </Feature>
  85. );
  86. }
  87. export default MissingPerformanceButtons;