system.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. };
  136. /**
  137. * This comes from django (django.contrib.messages)
  138. */
  139. messages: {level: keyof Theme['alert']; message: string}[];
  140. needsUpgrade: boolean;
  141. privacyUrl: string | null;
  142. sentryConfig: {
  143. dsn: string;
  144. release: string;
  145. whitelistUrls: string[];
  146. };
  147. singleOrganization: boolean;
  148. superUserCookieDomain: string | null;
  149. superUserCookieName: string;
  150. supportEmail: string;
  151. termsUrl: string | null;
  152. theme: 'light' | 'dark';
  153. urlPrefix: string;
  154. user: User;
  155. userIdentity: {
  156. email: string;
  157. id: string;
  158. ip_address: string;
  159. isStaff: boolean;
  160. };
  161. validateSUForm: boolean;
  162. version: {
  163. build: string;
  164. current: string;
  165. latest: string;
  166. upgradeAvailable: boolean;
  167. };
  168. statuspage?: {
  169. api_host: string;
  170. id: string;
  171. };
  172. }
  173. export type PipelineInitialData = {
  174. name: string;
  175. props: Record<string, any>;
  176. };
  177. export type Broadcast = {
  178. cta: string;
  179. dateCreated: string;
  180. dateExpires: string;
  181. hasSeen: boolean;
  182. id: string;
  183. isActive: boolean;
  184. link: string;
  185. message: string;
  186. title: string;
  187. };
  188. export type SentryServiceIncident = {
  189. affectedComponents: Array<{
  190. name: string;
  191. status: 'degraded_performance' | 'partial_outage' | 'major_outage' | 'operational';
  192. updatedAt: string;
  193. }>;
  194. createdAt: string;
  195. id: string;
  196. name: string;
  197. status: string;
  198. updates: Array<{
  199. body: string;
  200. status: string;
  201. updatedAt: string;
  202. }>;
  203. url: string;
  204. };
  205. export type SentryServiceStatus = {
  206. incidents: SentryServiceIncident[];
  207. indicator: 'major' | 'minor' | 'none';
  208. url: string;
  209. };
  210. export type PromptActivity = {
  211. dismissedTime?: number;
  212. snoozedTime?: number;
  213. };