missingPerformanceButtons.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 useRouter from 'sentry/utils/useRouter';
  10. import {PERFORMANCE_TOUR_STEPS} from 'sentry/views/performance/onboarding';
  11. import {getPerformanceBaseUrl} from 'sentry/views/performance/utils';
  12. const DOCS_URL = 'https://docs.sentry.io/performance-monitoring/getting-started/';
  13. type Props = {
  14. organization: Organization;
  15. };
  16. function MissingPerformanceButtons({organization}: Props) {
  17. const router = useRouter();
  18. function handleTourAdvance(step: number, duration: number) {
  19. trackAnalytics('project_detail.performance_tour.advance', {
  20. organization,
  21. step,
  22. duration,
  23. });
  24. }
  25. function handleClose(step: number, duration: number) {
  26. trackAnalytics('project_detail.performance_tour.close', {
  27. organization,
  28. step,
  29. duration,
  30. });
  31. }
  32. return (
  33. <Feature
  34. hookName="feature-disabled:project-performance-score-card"
  35. features="performance-view"
  36. organization={organization}
  37. >
  38. <ButtonBar gap={1}>
  39. <Button
  40. size="sm"
  41. priority="primary"
  42. onClick={event => {
  43. event.preventDefault();
  44. // TODO: add analytics here for this specific action.
  45. navigateTo(
  46. `${getPerformanceBaseUrl(organization.slug)}/?project=:project#performance-sidequest`,
  47. router
  48. );
  49. }}
  50. >
  51. {t('Start Setup')}
  52. </Button>
  53. <FeatureTourModal
  54. steps={PERFORMANCE_TOUR_STEPS}
  55. onAdvance={handleTourAdvance}
  56. onCloseModal={handleClose}
  57. doneText={t('Start Setup')}
  58. doneUrl={DOCS_URL}
  59. >
  60. {({showModal}) => (
  61. <Button size="sm" onClick={showModal}>
  62. {t('Get Tour')}
  63. </Button>
  64. )}
  65. </FeatureTourModal>
  66. </ButtonBar>
  67. </Feature>
  68. );
  69. }
  70. export default MissingPerformanceButtons;