system.tsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. import {Theme} from '@emotion/react';
  2. import type {FocusTrap} from 'focus-trap';
  3. import type {exportedGlobals} 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 exportedGlobals) => 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 Region {
  109. name: string;
  110. url: string;
  111. }
  112. interface CustomerDomain {
  113. organizationUrl: string | undefined;
  114. sentryUrl: string;
  115. subdomain: string;
  116. }
  117. export interface Config {
  118. apmSampling: number;
  119. csrfCookieName: string;
  120. customerDomain: CustomerDomain | null;
  121. demoMode: boolean;
  122. disableU2FForSUForm: boolean;
  123. distPrefix: string;
  124. dsn: string;
  125. enableAnalytics: boolean;
  126. features: Set<string>;
  127. gravatarBaseUrl: string;
  128. invitesEnabled: boolean;
  129. isAuthenticated: boolean;
  130. // Maintain isOnPremise key for backcompat (plugins?).
  131. isOnPremise: boolean;
  132. isSelfHosted: boolean;
  133. languageCode: string;
  134. lastOrganization: string | null;
  135. links: {
  136. organizationUrl: string | undefined;
  137. regionUrl: string | undefined;
  138. sentryUrl: string;
  139. superuserUrl?: string;
  140. };
  141. /**
  142. * This comes from django (django.contrib.messages)
  143. */
  144. messages: {level: keyof Theme['alert']; message: string}[];
  145. needsUpgrade: boolean;
  146. privacyUrl: string | null;
  147. // The list of regions the current user has memberships in.
  148. regions: Region[];
  149. sentryConfig: {
  150. allowUrls: string[];
  151. dsn: string;
  152. release: string;
  153. tracePropagationTargets: string[];
  154. profilesSampleRate?: number;
  155. };
  156. singleOrganization: boolean;
  157. superUserCookieDomain: string | null;
  158. superUserCookieName: string;
  159. supportEmail: string;
  160. termsUrl: string | null;
  161. theme: 'light' | 'dark';
  162. urlPrefix: string;
  163. user: User;
  164. userIdentity: {
  165. email: string;
  166. id: string;
  167. ip_address: string;
  168. isStaff: boolean;
  169. };
  170. validateSUForm: boolean;
  171. version: {
  172. build: string;
  173. current: string;
  174. latest: string;
  175. upgradeAvailable: boolean;
  176. };
  177. statuspage?: {
  178. api_host: string;
  179. id: string;
  180. };
  181. }
  182. export type PipelineInitialData = {
  183. name: string;
  184. props: Record<string, any>;
  185. };
  186. export type Broadcast = {
  187. cta: string;
  188. dateCreated: string;
  189. dateExpires: string;
  190. hasSeen: boolean;
  191. id: string;
  192. isActive: boolean;
  193. link: string;
  194. message: string;
  195. title: string;
  196. };
  197. export type SentryServiceIncident = {
  198. affectedComponents: Array<{
  199. name: string;
  200. status: 'degraded_performance' | 'partial_outage' | 'major_outage' | 'operational';
  201. updatedAt: string;
  202. }>;
  203. createdAt: string;
  204. id: string;
  205. name: string;
  206. status: string;
  207. updates: Array<{
  208. body: string;
  209. status: string;
  210. updatedAt: string;
  211. }>;
  212. url: string;
  213. };
  214. export type SentryServiceStatus = {
  215. incidents: SentryServiceIncident[];
  216. indicator: 'major' | 'minor' | 'none';
  217. url: string;
  218. };
  219. export type PromptActivity = {
  220. dismissedTime?: number;
  221. snoozedTime?: number;
  222. };