missingPerformanceButtons.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // eslint-disable-next-line no-restricted-imports
  2. import {withRouter, WithRouterProps} from 'react-router';
  3. import {navigateTo} from 'sentry/actionCreators/navigation';
  4. import Feature from 'sentry/components/acl/feature';
  5. import Button from 'sentry/components/button';
  6. import ButtonBar from 'sentry/components/buttonBar';
  7. import FeatureTourModal from 'sentry/components/modals/featureTourModal';
  8. import {t} from 'sentry/locale';
  9. import {Organization} from 'sentry/types';
  10. import {trackAnalyticsEvent} from 'sentry/utils/analytics';
  11. import {PERFORMANCE_TOUR_STEPS} from 'sentry/views/performance/onboarding';
  12. const DOCS_URL = 'https://docs.sentry.io/performance-monitoring/getting-started/';
  13. type Props = {
  14. organization: Organization;
  15. } & WithRouterProps;
  16. function MissingPerformanceButtons({organization, router}: Props) {
  17. function handleTourAdvance(step: number, duration: number) {
  18. trackAnalyticsEvent({
  19. eventKey: 'project_detail.performance_tour.advance',
  20. eventName: 'Project Detail: Performance Tour Advance',
  21. organization_id: parseInt(organization.id, 10),
  22. step,
  23. duration,
  24. });
  25. }
  26. function handleClose(step: number, duration: number) {
  27. trackAnalyticsEvent({
  28. eventKey: 'project_detail.performance_tour.close',
  29. eventName: 'Project Detail: Performance Tour Close',
  30. organization_id: parseInt(organization.id, 10),
  31. step,
  32. duration,
  33. });
  34. }
  35. return (
  36. <Feature
  37. hookName="feature-disabled:project-performance-score-card"
  38. features={['performance-view']}
  39. organization={organization}
  40. >
  41. <ButtonBar gap={1}>
  42. <Button
  43. size="sm"
  44. priority="primary"
  45. onClick={event => {
  46. event.preventDefault();
  47. // TODO: add analytics here for this specific action.
  48. navigateTo(
  49. `/organizations/${organization.slug}/performance/?project=:project#performance-sidequest`,
  50. router
  51. );
  52. }}
  53. >
  54. {t('Start Setup')}
  55. </Button>
  56. <FeatureTourModal
  57. steps={PERFORMANCE_TOUR_STEPS}
  58. onAdvance={handleTourAdvance}
  59. onCloseModal={handleClose}
  60. doneText={t('Start Setup')}
  61. doneUrl={DOCS_URL}
  62. >
  63. {({showModal}) => (
  64. <Button size="sm" onClick={showModal}>
  65. {t('Get Tour')}
  66. </Button>
  67. )}
  68. </FeatureTourModal>
  69. </ButtonBar>
  70. </Feature>
  71. );
  72. }
  73. export default withRouter(MissingPerformanceButtons);