system.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. import {Theme} from '@emotion/react';
  2. import type {FocusTrap} from 'focus-trap';
  3. import type exportGlobals from 'sentry/bootstrap/exportGlobals';
  4. import type {User} from './user';
  5. export enum SentryInitRenderReactComponent {
  6. INDICATORS = 'Indicators',
  7. SETUP_WIZARD = 'SetupWizard',
  8. SYSTEM_ALERTS = 'SystemAlerts',
  9. U2F_SIGN = 'U2fSign',
  10. SU_ACCESS_FORM = 'SuperuserAccessForm',
  11. }
  12. export type OnSentryInitConfiguration =
  13. | {
  14. element: string;
  15. input: string;
  16. name: 'passwordStrength';
  17. }
  18. | {
  19. component: SentryInitRenderReactComponent;
  20. container: string;
  21. name: 'renderReact';
  22. props?: Record<string, any>;
  23. }
  24. | {
  25. name: 'onReady';
  26. onReady: (globals: typeof exportGlobals) => void;
  27. };
  28. declare global {
  29. interface Window {
  30. /**
  31. * Primary entrypoint for rendering the sentry app. This is typically
  32. * called in the django templates, or in the case of the EXPERIMENTAL_SPA,
  33. * after config hydration.
  34. */
  35. SentryRenderApp: () => void;
  36. /**
  37. * Used to close tooltips for testing purposes.
  38. */
  39. __closeAllTooltips: () => void;
  40. /**
  41. * The config object provided by the backend.
  42. */
  43. __initialData: Config;
  44. /**
  45. * This allows our server-rendered templates to push configuration that should be
  46. * run after we render our main application.
  47. *
  48. * An example of this is dynamically importing the `passwordStrength` module only
  49. * on the organization login page.
  50. */
  51. __onSentryInit:
  52. | OnSentryInitConfiguration[]
  53. | {
  54. push: (config: OnSentryInitConfiguration) => void;
  55. };
  56. /**
  57. * Used to open tooltips for testing purposes.
  58. */
  59. __openAllTooltips: () => void;
  60. /**
  61. * Pipeline
  62. */
  63. __pipelineInitialData: PipelineInitialData;
  64. /**
  65. * Assets public location
  66. */
  67. __sentryGlobalStaticPrefix: string;
  68. // typing currently used for demo add on
  69. // TODO: improve typing
  70. SentryApp?: {
  71. ConfigStore: any;
  72. HookStore: any;
  73. Modal: any;
  74. getModalPortal: () => HTMLElement;
  75. modalFocusTrap?: {
  76. current?: FocusTrap;
  77. };
  78. };
  79. /**
  80. * Is the UI running as dev-ui proxy.
  81. * Used by webpack-devserver + html-webpack
  82. */
  83. __SENTRY_DEV_UI?: boolean;
  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 used on the backend
  95. */
  96. csrfCookieName?: string;
  97. sentryEmbedCallback?: ((embed: any) => void) | null;
  98. /**
  99. * The domain of which the superuser cookie is set onto.
  100. */
  101. superUserCookieDomain?: string;
  102. /**
  103. * The superuser cookie used on the backend
  104. */
  105. superUserCookieName?: string;
  106. }
  107. }
  108. interface CustomerDomain {
  109. organizationUrl: string | undefined;
  110. sentryUrl: string;
  111. subdomain: string;
  112. }
  113. export interface Config {
  114. apmSampling: number;
  115. csrfCookieName: string;
  116. customerDomain: CustomerDomain | null;
  117. demoMode: boolean;
  118. disableU2FForSUForm: boolean;
  119. distPrefix: string;
  120. dsn: string;
  121. enableAnalytics: boolean;
  122. features: Set<string>;
  123. gravatarBaseUrl: string;
  124. invitesEnabled: boolean;
  125. isAuthenticated: boolean;
  126. // Maintain isOnPremise key for backcompat (plugins?).
  127. isOnPremise: boolean;
  128. isSelfHosted: boolean;
  129. languageCode: string;
  130. lastOrganization: string | null;
  131. links: {
  132. organizationUrl: string | undefined;
  133. regionUrl: string | undefined;
  134. sentryUrl: string;
  135. superuserUrl?: string;
  136. };
  137. /**
  138. * This comes from django (django.contrib.messages)
  139. */
  140. messages: {level: keyof Theme['alert']; message: string}[];
  141. needsUpgrade: boolean;
  142. privacyUrl: string | null;
  143. sentryConfig: {
  144. dsn: string;
  145. release: string;
  146. whitelistUrls: string[];
  147. };
  148. singleOrganization: boolean;
  149. superUserCookieDomain: string | null;
  150. superUserCookieName: string;
  151. supportEmail: string;
  152. termsUrl: string | null;
  153. theme: 'light' | 'dark';
  154. urlPrefix: string;
  155. user: User;
  156. userIdentity: {
  157. email: string;
  158. id: string;
  159. ip_address: string;
  160. isStaff: boolean;
  161. };
  162. validateSUForm: boolean;
  163. version: {
  164. build: string;
  165. current: string;
  166. latest: string;
  167. upgradeAvailable: boolean;
  168. };
  169. statuspage?: {
  170. api_host: string;
  171. id: string;
  172. };
  173. }
  174. export type PipelineInitialData = {
  175. name: string;
  176. props: Record<string, any>;
  177. };
  178. export type Broadcast = {
  179. cta: string;
  180. dateCreated: string;
  181. dateExpires: string;
  182. hasSeen: boolean;
  183. id: string;
  184. isActive: boolean;
  185. link: string;
  186. message: string;
  187. title: string;
  188. };
  189. export type SentryServiceIncident = {
  190. affectedComponents: Array<{
  191. name: string;
  192. status: 'degraded_performance' | 'partial_outage' | 'major_outage' | 'operational';
  193. updatedAt: string;
  194. }>;
  195. createdAt: string;
  196. id: string;
  197. name: string;
  198. status: string;
  199. updates: Array<{
  200. body: string;
  201. status: string;
  202. updatedAt: string;
  203. }>;
  204. url: string;
  205. };
  206. export type SentryServiceStatus = {
  207. incidents: SentryServiceIncident[];
  208. indicator: 'major' | 'minor' | 'none';
  209. url: string;
  210. };
  211. export type PromptActivity = {
  212. dismissedTime?: number;
  213. snoozedTime?: number;
  214. };