performanceEventViewContext.tsx 887 B

123456789101112131415161718192021222324252627
  1. import EventView, {ImmutableEventView} from 'sentry/utils/discover/eventView';
  2. import {createDefinedContext} from './utils';
  3. type usePerformanceEventViewContext = {
  4. eventView: EventView;
  5. };
  6. const [
  7. PerformanceEventViewProvider,
  8. _usePerformanceEventView,
  9. PerformanceEventViewContext,
  10. ] = createDefinedContext<usePerformanceEventViewContext>({
  11. name: 'PerformanceEventViewContext',
  12. });
  13. export {PerformanceEventViewProvider, PerformanceEventViewContext};
  14. // Provides a readonly event view. Also omits anything that isn't currently read-only, although in the future we should switch the code in EventView instead.
  15. // If you need mutability, use the mutable version.
  16. export function usePerformanceEventView(): ImmutableEventView {
  17. return _usePerformanceEventView().eventView;
  18. }
  19. export function useMutablePerformanceEventView() {
  20. return usePerformanceEventView().clone();
  21. }