system.tsx 5.3 KB

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