sampleEventAlert.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import styled from '@emotion/styled';
  2. import Button from 'sentry/components/button';
  3. import PageAlertBar from 'sentry/components/pageAlertBar';
  4. import {IconLightning} from 'sentry/icons';
  5. import {t} from 'sentry/locale';
  6. import space from 'sentry/styles/space';
  7. import {GlobalSelection, Organization, Project} from 'sentry/types';
  8. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  9. import withGlobalSelection from 'sentry/utils/withGlobalSelection';
  10. import withOrganization from 'sentry/utils/withOrganization';
  11. import withProjects from 'sentry/utils/withProjects';
  12. function SampleEventAlert({
  13. selection,
  14. organization,
  15. projects,
  16. }: {
  17. selection: GlobalSelection;
  18. organization: Organization;
  19. projects: Project[];
  20. }) {
  21. if (projects.length === 0) {
  22. return null;
  23. }
  24. if (selection.projects.length !== 1) {
  25. return null;
  26. }
  27. const selectedProject = projects.find(p => p.id === selection.projects[0].toString());
  28. if (!selectedProject || selectedProject.firstEvent) {
  29. return null;
  30. }
  31. return (
  32. <PageAlertBar>
  33. <IconLightning />
  34. <TextWrapper>
  35. {t(
  36. 'You are viewing a sample error. Configure Sentry to start viewing real errors.'
  37. )}
  38. </TextWrapper>
  39. <Button
  40. size="xsmall"
  41. priority="primary"
  42. to={`/${organization.slug}/${selectedProject.slug}/getting-started/${
  43. selectedProject.platform || ''
  44. }`}
  45. onClick={() =>
  46. trackAdvancedAnalyticsEvent('growth.sample_error_onboarding_link_clicked', {
  47. project_id: selectedProject.id,
  48. organization,
  49. platform: selectedProject.platform,
  50. })
  51. }
  52. >
  53. {t('Get Started')}
  54. </Button>
  55. </PageAlertBar>
  56. );
  57. }
  58. export default withProjects(withOrganization(withGlobalSelection(SampleEventAlert)));
  59. const TextWrapper = styled('span')`
  60. margin: 0 ${space(1)};
  61. `;