exportGlobals.tsx 1.7 KB

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