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. function WrappedPageFiltersContainer({children}: {children: React.ReactNode}) {
  11. const {isDefaultQuery} = useMetricsContext();
  12. return (
  13. <PageFiltersContainer disablePersistence={isDefaultQuery}>
  14. {children}
  15. </PageFiltersContainer>
  16. );
  17. }
  18. function Metrics() {
  19. const organization = useOrganization();
  20. useEffect(() => {
  21. trackAnalytics('ddm.page-view', {
  22. organization,
  23. });
  24. Sentry.metrics.increment('ddm.visit');
  25. // eslint-disable-next-line react-hooks/exhaustive-deps
  26. }, []);
  27. return (
  28. <SentryDocumentTitle title={t('Metrics')} orgSlug={organization.slug}>
  29. {
  30. <MetricsContextProvider>
  31. <WrappedPageFiltersContainer>
  32. <MetricsLayout />
  33. </WrappedPageFiltersContainer>
  34. </MetricsContextProvider>
  35. }
  36. </SentryDocumentTitle>
  37. );
  38. }
  39. export default Metrics;