system.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. initialTrace: {
  133. baggage: string;
  134. sentry_trace: string;
  135. };
  136. invitesEnabled: boolean;
  137. isAuthenticated: boolean;
  138. // Maintain isOnPremise key for backcompat (plugins?).
  139. isOnPremise: boolean;
  140. isSelfHosted: boolean;
  141. languageCode: string;
  142. lastOrganization: string | null;
  143. links: {
  144. organizationUrl: string | undefined;
  145. regionUrl: string | undefined;
  146. sentryUrl: string;
  147. superuserUrl?: string;
  148. };
  149. /**
  150. * This comes from django (django.contrib.messages)
  151. */
  152. messages: {level: keyof Theme['alert']; message: string}[];
  153. needsUpgrade: boolean;
  154. privacyUrl: string | null;
  155. // The list of regions the current user has memberships in.
  156. regions: Region[];
  157. sentryConfig: {
  158. allowUrls: string[];
  159. dsn: string;
  160. release: string;
  161. tracePropagationTargets: string[];
  162. environment?: string;
  163. profilesSampleRate?: number;
  164. };
  165. singleOrganization: boolean;
  166. superUserCookieDomain: string | null;
  167. superUserCookieName: string;
  168. supportEmail: string;
  169. termsUrl: string | null;
  170. theme: 'light' | 'dark';
  171. urlPrefix: string;
  172. user: User;
  173. userIdentity: {
  174. email: string;
  175. id: string;
  176. ip_address: string;
  177. isStaff: boolean;
  178. };
  179. validateSUForm: boolean;
  180. version: {
  181. build: string;
  182. current: string;
  183. latest: string;
  184. upgradeAvailable: boolean;
  185. };
  186. statuspage?: {
  187. api_host: string;
  188. id: string;
  189. };
  190. }
  191. export type PipelineInitialData = {
  192. name: string;
  193. props: Record<string, any>;
  194. };
  195. export type Broadcast = {
  196. cta: string;
  197. dateCreated: string;
  198. dateExpires: string;
  199. hasSeen: boolean;
  200. id: string;
  201. isActive: boolean;
  202. link: string;
  203. message: string;
  204. title: string;
  205. };
  206. export type SentryServiceIncident = {
  207. affectedComponents: Array<{
  208. name: string;
  209. status: 'degraded_performance' | 'partial_outage' | 'major_outage' | 'operational';
  210. updatedAt: string;
  211. }>;
  212. createdAt: string;
  213. id: string;
  214. name: string;
  215. status: string;
  216. updates: Array<{
  217. body: string;
  218. status: string;
  219. updatedAt: string;
  220. }>;
  221. url: string;
  222. };
  223. export type SentryServiceStatus = {
  224. incidents: SentryServiceIncident[];
  225. indicator: 'major' | 'minor' | 'none';
  226. url: string;
  227. };
  228. export type PromptActivity = {
  229. dismissedTime?: number;
  230. snoozedTime?: number;
  231. };