system.tsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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. shouldPreloadData: boolean;
  169. singleOrganization: boolean;
  170. superUserCookieDomain: string | null;
  171. superUserCookieName: string;
  172. supportEmail: string;
  173. termsUrl: string | null;
  174. theme: 'light' | 'dark';
  175. urlPrefix: string;
  176. /**
  177. * The user should not be accessible directly except during
  178. * app initialization. Use `useUser` or ConfigStore instead.
  179. * @deprecated
  180. */
  181. user: User;
  182. userIdentity: {
  183. email: string;
  184. id: string;
  185. ip_address: string;
  186. isStaff: boolean;
  187. };
  188. validateSUForm: boolean;
  189. version: {
  190. build: string;
  191. current: string;
  192. latest: string;
  193. upgradeAvailable: boolean;
  194. };
  195. partnershipAgreementPrompt?: {
  196. agreements: Array<ParntershipAgreementType>;
  197. partnerDisplayName: string;
  198. } | null;
  199. relocationConfig?: {
  200. selectableRegions: string[];
  201. };
  202. shouldShowBeaconConsentPrompt?: boolean;
  203. statuspage?: {
  204. api_host: string;
  205. id: string;
  206. };
  207. }
  208. export type PipelineInitialData = {
  209. name: string;
  210. props: Record<string, any>;
  211. };
  212. export type Broadcast = {
  213. cta: string;
  214. dateCreated: string;
  215. dateExpires: string;
  216. hasSeen: boolean;
  217. id: string;
  218. isActive: boolean;
  219. link: string;
  220. message: string;
  221. title: string;
  222. };
  223. // XXX(epurkhiser): The components list can be generated using jq
  224. //
  225. // curl -s https://status.sentry.io/api/v2/components.json \
  226. // | jq -r '
  227. // .components
  228. // | map({key: (.name | gsub( "[^a-zA-Z]"; "_") | ascii_upcase ), value:.id})
  229. // | map("\(.key) = \"\(.value)\",")
  230. // | .[]'
  231. // | sort
  232. /**
  233. * Mapping of components to IDs
  234. *
  235. * Should be kept in sync with https://status.sentry.io/api/v2/components.json
  236. */
  237. export const enum StatusPageComponent {
  238. ALERTING = 'sykq5vtjw8zx',
  239. API = 'qywmfv7jr0pd',
  240. AUTHENTICATION_SERVICES = 'f5rs5z9q0dtk',
  241. AZURE_DEVOPS = 'tn9py6p7f85x',
  242. CUSTOM_METRICS = '7wrqyj84ltw7',
  243. DASHBOARD = 'khtl9dcky3lb',
  244. ELECTRON_SYMBOL_SERVER = '3jzzl28504tq',
  245. EMAIL = 'tjmyq3lb26w0',
  246. EU_ATTACHMENT_INGESTION = 'ztwsc8ff50v9',
  247. EU_CRON_MONITORING = 'qnj485gffb6v',
  248. EU_ERRORS = 'yqdr3zmyjv12',
  249. EU_ERROR_INGESTION = '1yf02ms0qsl7',
  250. EU_INGESTION = 'xmpnd79f7t51',
  251. EU_PROFILE_INGESTION = 'xbljnbzl9c77',
  252. EU_REPLAY_INGESTION = '3zhbl35gmbp0',
  253. EU_SPAN_INGESTION = '7rv05jl5qp0w',
  254. EU_TRANSACTION_INGESTION = 'tlkrt7x46b52',
  255. GITHUB = 'lqps2hvc2400',
  256. GOOGLE = 'bprcc4mhbhmm',
  257. HEROKU = '6g5bq169xp2s',
  258. INTEGRATION_PIPELINE = '6gtdt9t60dl0',
  259. MICROSOFT_SYMBOL_SERVER = '216356jwwrxq',
  260. MICROSOFT_TEAMS = 'z57k9q3r5jsh',
  261. NOTIFICATION_DELIVERY = 'rmq51qyvxfjh',
  262. PAGERDUTY = 'jd3tvjnx5l1f',
  263. PASSWORD_BASED = 'ml2wmx3hzlnn',
  264. SAML_BASED_SINGLE_SIGN_ON = 'hsbnk3hxcckr',
  265. SLACK = 'jkpcsxvvv2hf',
  266. STRIPE = '87stwrsyk6ls',
  267. THIRD_PARTY_INTEGRATIONS = 'yhfrrcmppvgh',
  268. US_ATTACHMENT_INGESTION = 'cycj4r32g25w',
  269. US_CRON_MONITORING = '6f1r28lydc6h',
  270. US_ERRORS = 'bctv81yt9s6w',
  271. US_ERROR_INGESTION = '51yszynm4xyv',
  272. US_INGESTION = '76x1wwzzfj5c',
  273. US_PROFILE_INGESTION = '52t4t3ww2qcn',
  274. US_REPLAY_INGESTION = 'zxkxxtspk64g',
  275. US_SPAN_INGESTION = 'qd7tzrk5q8xm',
  276. US_TRANSACTION_INGESTION = 'bdg4djkxjxmk',
  277. }
  278. export type StatusPageServiceStatus =
  279. | 'operational'
  280. | 'degraded_performance'
  281. | 'major_outage'
  282. | 'partial_outage';
  283. export interface StatusPageIncidentComponent {
  284. /**
  285. * ISO 8601 component creation time
  286. */
  287. created_at: string;
  288. description: string;
  289. group: boolean;
  290. group_id: string;
  291. id: StatusPageComponent;
  292. name: string;
  293. only_show_if_degraded: boolean;
  294. page_id: string;
  295. position: number;
  296. showcase: boolean;
  297. /**
  298. * Date of the component becoming active
  299. */
  300. start_date: string;
  301. status: StatusPageServiceStatus;
  302. /**
  303. * ISO 8601 component update time
  304. */
  305. updated_at: string;
  306. }
  307. export interface StatusPageAffectedComponent {
  308. code: StatusPageComponent;
  309. name: string;
  310. new_status: StatusPageServiceStatus;
  311. old_status: StatusPageServiceStatus;
  312. }
  313. export interface StatusPageIncidentUpdate {
  314. /**
  315. * Components affected by the update
  316. */
  317. affected_components: StatusPageAffectedComponent[];
  318. /**
  319. * Message to display for this update
  320. */
  321. body: string;
  322. /**
  323. * ISO Update creation time
  324. */
  325. created_at: string;
  326. /**
  327. * ISO Update display time
  328. */
  329. display_at: string;
  330. /**
  331. * Unique ID of the incident
  332. */
  333. id: string;
  334. /**
  335. * Unique ID of the incident
  336. */
  337. incident_id: string;
  338. /**
  339. * Status of the incident for tihs update
  340. */
  341. status: 'resolved' | 'monitoring' | 'investigating';
  342. /**
  343. * ISO Update update time
  344. */
  345. updated_at: string;
  346. }
  347. // See: https://doers.statuspage.io/api/v2/incidents/
  348. export interface StatuspageIncident {
  349. /**
  350. * Components related to this incident
  351. */
  352. components: StatusPageIncidentComponent[];
  353. /**
  354. * ISO 8601 created time
  355. */
  356. created_at: string;
  357. /**
  358. * Unique ID of the incident
  359. */
  360. id: string;
  361. /**
  362. * The impact of the incident
  363. */
  364. impact: 'none' | 'minor' | 'major';
  365. /**
  366. * Updates for this incident
  367. */
  368. incident_updates: StatusPageIncidentUpdate[];
  369. /**
  370. * ISO 8601 time monitoring began
  371. */
  372. monitoring_at: string | undefined;
  373. /**
  374. * Name of the incident
  375. */
  376. name: string;
  377. /**
  378. * The status page page ID
  379. */
  380. page_id: string;
  381. /**
  382. * ISO 8601 last updated time
  383. */
  384. resolved_at: string | undefined;
  385. /**
  386. * Short URL of the incident
  387. */
  388. shortlink: string;
  389. /**
  390. * ISO 8601 incident start time
  391. */
  392. started_at: string | undefined;
  393. /**
  394. * Current status of the incident
  395. */
  396. status: 'resolved' | 'unresolved';
  397. /**
  398. * ISO 8601 last updated time
  399. */
  400. updated_at: string | undefined;
  401. }
  402. export type PromptActivity = {
  403. dismissedTime?: number;
  404. snoozedTime?: number;
  405. };