system.tsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import {FocusTrap} from 'focus-trap';
  2. import exportGlobals from 'sentry/bootstrap/exportGlobals';
  3. import {User} from './user';
  4. export enum SentryInitRenderReactComponent {
  5. INDICATORS = 'Indicators',
  6. SETUP_WIZARD = 'SetupWizard',
  7. SYSTEM_ALERTS = 'SystemAlerts',
  8. U2F_SIGN = 'U2fSign',
  9. }
  10. export type OnSentryInitConfiguration =
  11. | {
  12. element: string;
  13. input: string;
  14. name: 'passwordStrength';
  15. }
  16. | {
  17. component: SentryInitRenderReactComponent;
  18. container: string;
  19. name: 'renderReact';
  20. props?: Record<string, any>;
  21. }
  22. | {
  23. name: 'onReady';
  24. onReady: (globals: typeof exportGlobals) => void;
  25. };
  26. declare global {
  27. interface Window {
  28. /**
  29. * Primary entrypoint for rendering the sentry app. This is typically
  30. * called in the django templates, or in the case of the EXPERIMENTAL_SPA,
  31. * after config hydration.
  32. */
  33. SentryRenderApp: () => void;
  34. /**
  35. * Used to close tooltips for testing purposes.
  36. */
  37. __closeAllTooltips: () => void;
  38. /**
  39. * The config object provided by the backend.
  40. */
  41. __initialData: Config;
  42. /**
  43. * This allows our server-rendered templates to push configuration that should be
  44. * run after we render our main application.
  45. *
  46. * An example of this is dynamically importing the `passwordStrength` module only
  47. * on the organization login page.
  48. */
  49. __onSentryInit:
  50. | OnSentryInitConfiguration[]
  51. | {
  52. push: (config: OnSentryInitConfiguration) => void;
  53. };
  54. /**
  55. * Used to open tooltips for testing purposes.
  56. */
  57. __openAllTooltips: () => void;
  58. /**
  59. * Pipeline
  60. */
  61. __pipelineInitialData: PipelineInitialData;
  62. /**
  63. * Assets public location
  64. */
  65. __sentryGlobalStaticPrefix: string;
  66. /**
  67. * This is used for testing purposes as an interem while we translate tests
  68. * to React Testing Library.
  69. *
  70. * See the useLegacyStore hook for more unformation about this.
  71. */
  72. _legacyStoreHookUpdate: (update: () => void) => void;
  73. // typing currently used for demo add on
  74. // TODO: improve typing
  75. SentryApp?: {
  76. ConfigStore: any;
  77. HookStore: any;
  78. Modal: any;
  79. getModalPortal: () => HTMLElement;
  80. modalFocusTrap?: {
  81. current?: FocusTrap;
  82. };
  83. };
  84. /**
  85. * Sentrys version string
  86. */
  87. __SENTRY__VERSION?: string;
  88. /**
  89. * Set to true if adblock could be installed.
  90. * See sentry/js/ads.js for how this global is disabled.
  91. */
  92. adblockSuspected?: boolean;
  93. /**
  94. * The CSRF cookie ised on the backend
  95. */
  96. csrfCookieName?: string;
  97. sentryEmbedCallback?: ((embed: any) => void) | null;
  98. }
  99. }
  100. export interface Config {
  101. apmSampling: number;
  102. csrfCookieName: string;
  103. demoMode: boolean;
  104. distPrefix: string;
  105. dsn: string;
  106. dsn_requests: string;
  107. features: Set<string>;
  108. gravatarBaseUrl: string;
  109. invitesEnabled: boolean;
  110. isAuthenticated: boolean;
  111. // Maintain isOnPremise key for backcompat (plugins?).
  112. isOnPremise: boolean;
  113. isSelfHosted: boolean;
  114. languageCode: string;
  115. lastOrganization: string | null;
  116. /**
  117. * This comes from django (django.contrib.messages)
  118. */
  119. messages: {level: string; message: string}[];
  120. needsUpgrade: boolean;
  121. privacyUrl: string | null;
  122. sentryConfig: {
  123. dsn: string;
  124. release: string;
  125. whitelistUrls: string[];
  126. };
  127. singleOrganization: boolean;
  128. supportEmail: string;
  129. termsUrl: string | null;
  130. theme: 'light' | 'dark';
  131. urlPrefix: string;
  132. user: User;
  133. userIdentity: {
  134. email: string;
  135. id: string;
  136. ip_address: string;
  137. isStaff: boolean;
  138. };
  139. version: {
  140. build: string;
  141. current: string;
  142. latest: string;
  143. upgradeAvailable: boolean;
  144. };
  145. statuspage?: {
  146. api_host: string;
  147. id: string;
  148. };
  149. }
  150. export type PipelineInitialData = {
  151. name: string;
  152. props: Record<string, any>;
  153. };
  154. export type Broadcast = {
  155. cta: string;
  156. dateCreated: string;
  157. dateExpires: string;
  158. hasSeen: boolean;
  159. id: string;
  160. isActive: boolean;
  161. link: string;
  162. message: string;
  163. title: string;
  164. };
  165. export type SentryServiceIncident = {
  166. id: string;
  167. name: string;
  168. status: string;
  169. url: string;
  170. updates?: string[];
  171. };
  172. export type SentryServiceStatus = {
  173. incidents: SentryServiceIncident[];
  174. indicator: 'major' | 'minor' | 'none';
  175. url: string;
  176. };
  177. export type PromptActivity = {
  178. dismissedTime?: number;
  179. snoozedTime?: number;
  180. };