projectMetrics.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {Fragment} from 'react';
  2. import * as Sentry from '@sentry/react';
  3. import {Button} from 'sentry/components/button';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  6. import {t, tct} from 'sentry/locale';
  7. import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
  8. import type {Organization} from 'sentry/types/organization';
  9. import type {Project} from 'sentry/types/project';
  10. import {METRICS_DOCS_URL} from 'sentry/utils/metrics/constants';
  11. import routeTitleGen from 'sentry/utils/routeTitle';
  12. import {useMetricsOnboardingSidebar} from 'sentry/views/metrics/ddmOnboarding/useMetricsOnboardingSidebar';
  13. import {MetricsBetaEndAlert} from 'sentry/views/metrics/metricsBetaEndAlert';
  14. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  15. import TextBlock from 'sentry/views/settings/components/text/textBlock';
  16. import PermissionAlert from 'sentry/views/settings/project/permissionAlert';
  17. import {CustomMetricsTable} from 'sentry/views/settings/projectMetrics/customMetricsTable';
  18. type Props = {
  19. organization: Organization;
  20. project: Project;
  21. } & RouteComponentProps<{projectId: string}, {}>;
  22. function ProjectMetrics({project, organization}: Props) {
  23. const {activateSidebar} = useMetricsOnboardingSidebar();
  24. return (
  25. <Fragment>
  26. <SentryDocumentTitle title={routeTitleGen(t('Metrics'), project.slug, false)} />
  27. <SettingsPageHeader
  28. title={t('Metrics')}
  29. action={
  30. <Button
  31. priority="primary"
  32. onClick={() => {
  33. Sentry.metrics.increment('ddm.add_custom_metric', 1, {
  34. tags: {
  35. referrer: 'settings',
  36. },
  37. });
  38. activateSidebar();
  39. }}
  40. size="sm"
  41. >
  42. {t('Add Metric')}
  43. </Button>
  44. }
  45. />
  46. <TextBlock>
  47. {tct(
  48. `Metrics are numerical values extracted from span attributes that can help you track anything about your environment over time. To learn more about metrics, [link:read the docs].`,
  49. {
  50. link: <ExternalLink href={METRICS_DOCS_URL} />,
  51. }
  52. )}
  53. </TextBlock>
  54. <MetricsBetaEndAlert organization={organization} />
  55. <PermissionAlert project={project} />
  56. <CustomMetricsTable project={project} />
  57. </Fragment>
  58. );
  59. }
  60. export default ProjectMetrics;