system.tsx 5.3 KB

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