system.tsx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. import type {Theme} from '@emotion/react';
  2. import type {FocusTrap} from 'focus-trap';
  3. import type {exportedGlobals} from 'sentry/bootstrap/exportGlobals';
  4. import type {ParntershipAgreementType} from 'sentry/types/hooks';
  5. import type {User} from './user';
  6. export enum SentryInitRenderReactComponent {
  7. INDICATORS = 'Indicators',
  8. SETUP_WIZARD = 'SetupWizard',
  9. SYSTEM_ALERTS = 'SystemAlerts',
  10. U2F_SIGN = 'U2fSign',
  11. SU_STAFF_ACCESS_FORM = 'SuperuserStaffAccessForm',
  12. }
  13. export type OnSentryInitConfiguration =
  14. | {
  15. element: string;
  16. input: string;
  17. name: 'passwordStrength';
  18. }
  19. | {
  20. component: SentryInitRenderReactComponent;
  21. container: string;
  22. name: 'renderReact';
  23. props?: Record<string, any>;
  24. }
  25. | {
  26. name: 'onReady';
  27. onReady: (globals: typeof exportedGlobals) => void;
  28. };
  29. declare global {
  30. interface Window {
  31. /**
  32. * Primary entrypoint for rendering the sentry app. This is typically
  33. * called in the django templates, or in the case of the EXPERIMENTAL_SPA,
  34. * after config hydration.
  35. */
  36. SentryRenderApp: () => void;
  37. /**
  38. * Used to close tooltips for testing purposes.
  39. */
  40. __closeAllTooltips: () => void;
  41. /**
  42. * The config object provided by the backend.
  43. */
  44. __initialData: Config;
  45. /**
  46. * This allows our server-rendered templates to push configuration that should be
  47. * run after we render our main application.
  48. *
  49. * An example of this is dynamically importing the `passwordStrength` module only
  50. * on the organization login page.
  51. */
  52. __onSentryInit:
  53. | OnSentryInitConfiguration[]
  54. | {
  55. push: (config: OnSentryInitConfiguration) => void;
  56. };
  57. /**
  58. * Used to open tooltips for testing purposes.
  59. */
  60. __openAllTooltips: () => void;
  61. /**
  62. * Pipeline
  63. */
  64. __pipelineInitialData: PipelineInitialData;
  65. /**
  66. * Assets public location
  67. */
  68. __sentryGlobalStaticPrefix: string;
  69. /**
  70. * Is populated with promises/strings of commonly used data.
  71. */
  72. __sentry_preload: Record<string, any>;
  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. * Is the UI running as dev-ui proxy.
  86. * Used by webpack-devserver + html-webpack
  87. */
  88. __SENTRY_DEV_UI?: boolean;
  89. /**
  90. * Sentrys version string
  91. */
  92. __SENTRY__VERSION?: string;
  93. /**
  94. * Set to true if adblock could be installed.
  95. * See sentry/js/ads.js for how this global is disabled.
  96. */
  97. adblockSuspected?: boolean;
  98. /**
  99. * The CSRF cookie used on the backend
  100. */
  101. csrfCookieName?: string;
  102. sentryEmbedCallback?: ((embed: any) => void) | null;
  103. /**
  104. * The domain of which the superuser cookie is set onto.
  105. */
  106. superUserCookieDomain?: string;
  107. /**
  108. * The superuser cookie used on the backend
  109. */
  110. superUserCookieName?: string;
  111. }
  112. }
  113. export interface Region {
  114. name: string;
  115. url: string;
  116. }
  117. interface CustomerDomain {
  118. organizationUrl: string | undefined;
  119. sentryUrl: string;
  120. subdomain: string;
  121. }
  122. export interface Config {
  123. apmSampling: number;
  124. csrfCookieName: string;
  125. customerDomain: CustomerDomain | null;
  126. demoMode: boolean;
  127. disableU2FForSUForm: boolean;
  128. distPrefix: string;
  129. dsn: string;
  130. enableAnalytics: boolean;
  131. features: Set<string>;
  132. gravatarBaseUrl: string;
  133. initialTrace: {
  134. baggage: string;
  135. sentry_trace: string;
  136. };
  137. invitesEnabled: boolean;
  138. isAuthenticated: boolean;
  139. // Maintain isOnPremise key for backcompat (plugins?).
  140. isOnPremise: boolean;
  141. isSelfHosted: boolean;
  142. languageCode: string;
  143. lastOrganization: string | null;
  144. links: {
  145. organizationUrl: string | undefined;
  146. regionUrl: string | undefined;
  147. sentryUrl: string;
  148. superuserUrl?: string;
  149. };
  150. // A list of regions that the user has membership in.
  151. memberRegions: Region[];
  152. /**
  153. * This comes from django (django.contrib.messages)
  154. */
  155. messages: {level: keyof Theme['alert']; message: string}[];
  156. needsUpgrade: boolean;
  157. privacyUrl: string | null;
  158. // The list of regions the user has has access to.
  159. regions: Region[];
  160. sentryConfig: {
  161. allowUrls: string[];
  162. dsn: string;
  163. release: string;
  164. tracePropagationTargets: string[];
  165. environment?: string;
  166. profilesSampleRate?: number;
  167. };
  168. singleOrganization: boolean;
  169. superUserCookieDomain: string | null;
  170. superUserCookieName: string;
  171. supportEmail: string;
  172. termsUrl: string | null;
  173. theme: 'light' | 'dark';
  174. urlPrefix: string;
  175. /**
  176. * The user should not be accessible directly except during
  177. * app initialization. Use `useUser` or ConfigStore instead.
  178. * @deprecated
  179. */
  180. user: User;
  181. userIdentity: {
  182. email: string;
  183. id: string;
  184. ip_address: string;
  185. isStaff: boolean;
  186. };
  187. validateSUForm: boolean;
  188. version: {
  189. build: string;
  190. current: string;
  191. latest: string;
  192. upgradeAvailable: boolean;
  193. };
  194. partnershipAgreementPrompt?: {
  195. agreements: Array<ParntershipAgreementType>;
  196. partnerDisplayName: string;
  197. } | null;
  198. relocationConfig?: {
  199. selectableRegions: string[];
  200. };
  201. shouldShowBeaconConsentPrompt?: boolean;
  202. statuspage?: {
  203. api_host: string;
  204. id: string;
  205. };
  206. }
  207. export type PipelineInitialData = {
  208. name: string;
  209. props: Record<string, any>;
  210. };
  211. export type Broadcast = {
  212. cta: string;
  213. dateCreated: string;
  214. dateExpires: string;
  215. hasSeen: boolean;
  216. id: string;
  217. isActive: boolean;
  218. link: string;
  219. message: string;
  220. title: string;
  221. };
  222. export type SentryServiceIncident = {
  223. affectedComponents: Array<{
  224. name: string;
  225. status: 'degraded_performance' | 'partial_outage' | 'major_outage' | 'operational';
  226. updatedAt: string;
  227. }>;
  228. createdAt: string;
  229. id: string;
  230. name: string;
  231. status: string;
  232. updates: Array<{
  233. body: string;
  234. status: string;
  235. updatedAt: string;
  236. }>;
  237. url: string;
  238. };
  239. export type SentryServiceStatus = {
  240. incidents: SentryServiceIncident[];
  241. indicator: 'major' | 'minor' | 'none';
  242. url: string;
  243. };
  244. export type PromptActivity = {
  245. dismissedTime?: number;
  246. snoozedTime?: number;
  247. };