system.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. /**
  69. * Is populated with promises/strings of commonly used data.
  70. */
  71. __sentry_preload: Record<string, any>;
  72. // typing currently used for demo add on
  73. // TODO: improve typing
  74. SentryApp?: {
  75. ConfigStore: any;
  76. HookStore: any;
  77. Modal: any;
  78. getModalPortal: () => HTMLElement;
  79. modalFocusTrap?: {
  80. current?: FocusTrap;
  81. };
  82. };
  83. /**
  84. * Is the UI running as dev-ui proxy.
  85. * Used by webpack-devserver + html-webpack
  86. */
  87. __SENTRY_DEV_UI?: boolean;
  88. /**
  89. * Sentrys version string
  90. */
  91. __SENTRY__VERSION?: string;
  92. /**
  93. * Set to true if adblock could be installed.
  94. * See sentry/js/ads.js for how this global is disabled.
  95. */
  96. adblockSuspected?: boolean;
  97. /**
  98. * The CSRF cookie used on the backend
  99. */
  100. csrfCookieName?: string;
  101. sentryEmbedCallback?: ((embed: any) => void) | null;
  102. /**
  103. * The domain of which the superuser cookie is set onto.
  104. */
  105. superUserCookieDomain?: string;
  106. /**
  107. * The superuser cookie used on the backend
  108. */
  109. superUserCookieName?: string;
  110. }
  111. }
  112. interface Region {
  113. name: string;
  114. url: string;
  115. }
  116. interface CustomerDomain {
  117. organizationUrl: string | undefined;
  118. sentryUrl: string;
  119. subdomain: string;
  120. }
  121. export interface Config {
  122. apmSampling: number;
  123. csrfCookieName: string;
  124. customerDomain: CustomerDomain | null;
  125. demoMode: boolean;
  126. disableU2FForSUForm: boolean;
  127. distPrefix: string;
  128. dsn: string;
  129. enableAnalytics: boolean;
  130. features: Set<string>;
  131. gravatarBaseUrl: string;
  132. invitesEnabled: boolean;
  133. isAuthenticated: boolean;
  134. // Maintain isOnPremise key for backcompat (plugins?).
  135. isOnPremise: boolean;
  136. isSelfHosted: boolean;
  137. languageCode: string;
  138. lastOrganization: string | null;
  139. links: {
  140. organizationUrl: string | undefined;
  141. regionUrl: string | undefined;
  142. sentryUrl: string;
  143. superuserUrl?: string;
  144. };
  145. /**
  146. * This comes from django (django.contrib.messages)
  147. */
  148. messages: {level: keyof Theme['alert']; message: string}[];
  149. needsUpgrade: boolean;
  150. privacyUrl: string | null;
  151. // The list of regions the current user has memberships in.
  152. regions: Region[];
  153. sentryConfig: {
  154. allowUrls: string[];
  155. dsn: string;
  156. release: string;
  157. tracePropagationTargets: string[];
  158. profilesSampleRate?: number;
  159. };
  160. singleOrganization: boolean;
  161. superUserCookieDomain: string | null;
  162. superUserCookieName: string;
  163. supportEmail: string;
  164. termsUrl: string | null;
  165. theme: 'light' | 'dark';
  166. urlPrefix: string;
  167. user: User;
  168. userIdentity: {
  169. email: string;
  170. id: string;
  171. ip_address: string;
  172. isStaff: boolean;
  173. };
  174. validateSUForm: boolean;
  175. version: {
  176. build: string;
  177. current: string;
  178. latest: string;
  179. upgradeAvailable: boolean;
  180. };
  181. statuspage?: {
  182. api_host: string;
  183. id: string;
  184. };
  185. }
  186. export type PipelineInitialData = {
  187. name: string;
  188. props: Record<string, any>;
  189. };
  190. export type Broadcast = {
  191. cta: string;
  192. dateCreated: string;
  193. dateExpires: string;
  194. hasSeen: boolean;
  195. id: string;
  196. isActive: boolean;
  197. link: string;
  198. message: string;
  199. title: string;
  200. };
  201. export type SentryServiceIncident = {
  202. affectedComponents: Array<{
  203. name: string;
  204. status: 'degraded_performance' | 'partial_outage' | 'major_outage' | 'operational';
  205. updatedAt: string;
  206. }>;
  207. createdAt: string;
  208. id: string;
  209. name: string;
  210. status: string;
  211. updates: Array<{
  212. body: string;
  213. status: string;
  214. updatedAt: string;
  215. }>;
  216. url: string;
  217. };
  218. export type SentryServiceStatus = {
  219. incidents: SentryServiceIncident[];
  220. indicator: 'major' | 'minor' | 'none';
  221. url: string;
  222. };
  223. export type PromptActivity = {
  224. dismissedTime?: number;
  225. snoozedTime?: number;
  226. };