exportGlobals.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import * as React from 'react';
  2. import {findDOMNode} from 'react-dom';
  3. import {createRoot} from 'react-dom/client';
  4. import * as Sentry from '@sentry/react';
  5. import moment from 'moment';
  6. import plugins from 'sentry/plugins';
  7. const globals = {
  8. // The following globals are used in sentry-plugins webpack externals
  9. // configuration.
  10. React,
  11. Sentry,
  12. moment,
  13. ReactDOM: {findDOMNode, createRoot},
  14. // django templates make use of these globals
  15. SentryApp: {},
  16. };
  17. // The SentryApp global contains exported app modules for use in javascript
  18. // modules that are not compiled with the sentry bundle.
  19. const SentryApp = {
  20. // The following components are used in sentry-plugins.
  21. FormState: require('sentry/components/forms/state').default,
  22. LoadingIndicator: require('sentry/components/loadingIndicator').default,
  23. plugins: {
  24. add: plugins.add,
  25. addContext: plugins.addContext,
  26. BasePlugin: plugins.BasePlugin,
  27. DefaultIssuePlugin: plugins.DefaultIssuePlugin,
  28. },
  29. // The following components are used in legacy django HTML views
  30. // or in the Sentry sandbox
  31. ConfigStore: require('sentry/stores/configStore').default,
  32. HookStore: require('sentry/stores/hookStore').default,
  33. GuideActionCreator: require('sentry/actionCreators/guides'),
  34. Modal: require('sentry/actionCreators/modal'),
  35. getModalPortal: require('sentry/utils/getModalPortal').default,
  36. Client: require('sentry/api').Client,
  37. // This is used in the Email Modal in the Sandbox
  38. IconArrow: require('sentry/icons/iconArrow').IconArrow,
  39. };
  40. globals.SentryApp = SentryApp;
  41. Object.keys(globals).forEach(name => (window[name] = globals[name]));
  42. export {globals as exportedGlobals};