ddm.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 {DDMContextProvider, useDDMContext} from 'sentry/views/ddm/context';
  9. import {DDMLayout} from 'sentry/views/ddm/layout';
  10. function WrappedPageFiltersContainer({children}: {children: React.ReactNode}) {
  11. const {isDefaultQuery} = useDDMContext();
  12. return (
  13. <PageFiltersContainer disablePersistence={isDefaultQuery}>
  14. {children}
  15. </PageFiltersContainer>
  16. );
  17. }
  18. function DDM() {
  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. <DDMContextProvider>
  30. <WrappedPageFiltersContainer>
  31. <DDMLayout />
  32. </WrappedPageFiltersContainer>
  33. </DDMContextProvider>
  34. </SentryDocumentTitle>
  35. );
  36. }
  37. export default DDM;