metrics.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {useEffect} from 'react';
  2. import * as Sentry from '@sentry/react';
  3. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  4. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  5. import {t} from 'sentry/locale';
  6. import {trackAnalytics} from 'sentry/utils/analytics';
  7. import useOrganization from 'sentry/utils/useOrganization';
  8. import {MetricsContextProvider, useMetricsContext} from 'sentry/views/metrics/context';
  9. import {MetricsLayout} from 'sentry/views/metrics/layout';
  10. import {useOptInModal} from 'sentry/views/metrics/optInModal';
  11. function WrappedPageFiltersContainer({children}: {children: React.ReactNode}) {
  12. const {isDefaultQuery} = useMetricsContext();
  13. return (
  14. <PageFiltersContainer disablePersistence={isDefaultQuery}>
  15. {children}
  16. </PageFiltersContainer>
  17. );
  18. }
  19. function Metrics() {
  20. const organization = useOrganization();
  21. useOptInModal();
  22. useEffect(() => {
  23. trackAnalytics('ddm.page-view', {
  24. organization,
  25. });
  26. Sentry.metrics.increment('ddm.visit');
  27. // eslint-disable-next-line react-hooks/exhaustive-deps
  28. }, []);
  29. return (
  30. <SentryDocumentTitle title={t('Metrics')} orgSlug={organization.slug}>
  31. <MetricsContextProvider>
  32. <WrappedPageFiltersContainer>
  33. <MetricsLayout />
  34. </WrappedPageFiltersContainer>
  35. </MetricsContextProvider>
  36. </SentryDocumentTitle>
  37. );
  38. }
  39. export default Metrics;