useMetricsContext.tsx 333 B

12345678910111213
  1. import {useContext} from 'react';
  2. import {MetricsContext} from 'sentry/utils/metrics/metricsContext';
  3. export function useMetricsContext() {
  4. const metricsContext = useContext(MetricsContext);
  5. if (!metricsContext) {
  6. throw new Error('useMetricsContext was called outside of MetricsProvider');
  7. }
  8. return metricsContext;
  9. }