useRouteAnalyticsHookSetup.tsx 548 B

123456789101112131415161718
  1. import {useContext} from 'react';
  2. import HookStore from 'sentry/stores/hookStore';
  3. import {RouteAnalyticsContext} from 'sentry/views/routeAnalyticsContextProvider';
  4. /**
  5. * Sets the organization for route analytics events.
  6. * Only needs to be used once for the entire app just
  7. * below the Organization context.
  8. */
  9. export default function useRouteAnalyticsHookSetup() {
  10. const {setOrganization} = useContext(RouteAnalyticsContext);
  11. HookStore.persistCallback(
  12. 'react-hook:route-activated',
  13. 'setOrganization',
  14. setOrganization
  15. );
  16. }