ddm.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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} from 'sentry/views/ddm/context';
  9. import {DDMLayout} from 'sentry/views/ddm/layout';
  10. import {ScratchpadsProvider, useScratchpads} from 'sentry/views/ddm/scratchpadContext';
  11. function WrappedPageFiltersContainer({children}: {children: React.ReactNode}) {
  12. const {selected} = useScratchpads();
  13. return (
  14. <PageFiltersContainer disablePersistence={!!selected}>
  15. {children}
  16. </PageFiltersContainer>
  17. );
  18. }
  19. function DDM() {
  20. const organization = useOrganization();
  21. useEffect(() => {
  22. trackAnalytics('ddm.page-view', {
  23. organization,
  24. });
  25. Sentry.metrics.increment('ddm.visit');
  26. // eslint-disable-next-line react-hooks/exhaustive-deps
  27. }, []);
  28. return (
  29. <SentryDocumentTitle title={t('Metrics')} orgSlug={organization.slug}>
  30. <ScratchpadsProvider>
  31. <WrappedPageFiltersContainer>
  32. <DDMContextProvider>
  33. <DDMLayout />
  34. </DDMContextProvider>
  35. </WrappedPageFiltersContainer>
  36. </ScratchpadsProvider>
  37. </SentryDocumentTitle>
  38. );
  39. }
  40. export default DDM;