system.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. import type {Theme} from '@emotion/react';
  2. import type {FocusTrap} from 'focus-trap';
  3. import type {ApiResult} from 'sentry/api';
  4. import type {exportedGlobals} from 'sentry/bootstrap/exportGlobals';
  5. import type {ParntershipAgreementType} from './hooks';
  6. import type {User} from './user';
  7. export enum SentryInitRenderReactComponent {
  8. INDICATORS = 'Indicators',
  9. SETUP_WIZARD = 'SetupWizard',
  10. SYSTEM_ALERTS = 'SystemAlerts',
  11. U2F_SIGN = 'U2fSign',
  12. SU_STAFF_ACCESS_FORM = 'SuperuserStaffAccessForm',
  13. }
  14. export type OnSentryInitConfiguration =
  15. | {
  16. element: string;
  17. input: string;
  18. name: 'passwordStrength';
  19. }
  20. | {
  21. component: SentryInitRenderReactComponent;
  22. container: string;
  23. name: 'renderReact';
  24. props?: Record<string, any>;
  25. }
  26. | {
  27. name: 'onReady';
  28. onReady: (globals: typeof exportedGlobals) => void;
  29. };
  30. declare global {
  31. interface Window {
  32. /**
  33. * Primary entrypoint for rendering the sentry app. This is typically
  34. * called in the django templates, or in the case of the EXPERIMENTAL_SPA,
  35. * after config hydration.
  36. */
  37. SentryRenderApp: () => void;
  38. /**
  39. * Used to close tooltips for testing purposes.
  40. */
  41. __closeAllTooltips: () => void;
  42. /**
  43. * The config object provided by the backend.
  44. */
  45. __initialData: Config;
  46. /**
  47. * This allows our server-rendered templates to push configuration that should be
  48. * run after we render our main application.
  49. *
  50. * An example of this is dynamically importing the `passwordStrength` module only
  51. * on the organization login page.
  52. */
  53. __onSentryInit:
  54. | OnSentryInitConfiguration[]
  55. | {
  56. push: (config: OnSentryInitConfiguration) => void;
  57. };
  58. /**
  59. * Used to open tooltips for testing purposes.
  60. */
  61. __openAllTooltips: () => void;
  62. /**
  63. * Pipeline
  64. */
  65. __pipelineInitialData: PipelineInitialData;
  66. /**
  67. * Assets public location
  68. */
  69. __sentryGlobalStaticPrefix: string;
  70. // typing currently used for demo add on
  71. // TODO: improve typing
  72. SentryApp?: {
  73. ConfigStore: any;
  74. HookStore: any;
  75. Modal: any;
  76. getModalPortal: () => HTMLElement;
  77. modalFocusTrap?: {
  78. current?: FocusTrap;
  79. };
  80. };
  81. /**
  82. * Is the UI running as dev-ui proxy.
  83. * Used by webpack-devserver + html-webpack
  84. */
  85. __SENTRY_DEV_UI?: boolean;
  86. /**
  87. * Sentrys version string
  88. */
  89. __SENTRY__VERSION?: string;
  90. /**
  91. * Is populated with promises/strings of commonly used data.
  92. */
  93. __sentry_preload?: {
  94. orgSlug?: string;
  95. organization?: Promise<ApiResult>;
  96. organization_fallback?: Promise<ApiResult>;
  97. projects?: Promise<ApiResult>;
  98. projects_fallback?: Promise<ApiResult>;
  99. teams?: Promise<ApiResult>;
  100. teams_fallback?: Promise<ApiResult>;
  101. };
  102. /**
  103. * Set to true if adblock could be installed.
  104. * See sentry/js/ads.js for how this global is disabled.
  105. */
  106. adblockSuspected?: boolean;
  107. /**
  108. * The CSRF cookie used on the backend
  109. */
  110. csrfCookieName?: string;
  111. sentryEmbedCallback?: ((embed: any) => void) | null;
  112. /**
  113. * The domain of which the superuser cookie is set onto.
  114. */
  115. superUserCookieDomain?: string;
  116. /**
  117. * The superuser cookie used on the backend
  118. */
  119. superUserCookieName?: string;
  120. }
  121. }
  122. export interface Region {
  123. name: string;
  124. url: string;
  125. }
  126. interface CustomerDomain {
  127. organizationUrl: string | undefined;
  128. sentryUrl: string;
  129. subdomain: string;
  130. }
  131. export interface Config {
  132. apmSampling: number;
  133. csrfCookieName: string;
  134. customerDomain: CustomerDomain | null;
  135. demoMode: boolean;
  136. disableU2FForSUForm: boolean;
  137. distPrefix: string;
  138. dsn: string;
  139. enableAnalytics: boolean;
  140. features: Set<string>;
  141. gravatarBaseUrl: string;
  142. initialTrace: {
  143. baggage: string;
  144. sentry_trace: string;
  145. };
  146. invitesEnabled: boolean;
  147. isAuthenticated: boolean;
  148. // Maintain isOnPremise key for backcompat (plugins?).
  149. isOnPremise: boolean;
  150. isSelfHosted: boolean;
  151. isSelfHostedErrorsOnly: boolean;
  152. languageCode: string;
  153. lastOrganization: string | null;
  154. links: {
  155. organizationUrl: string | undefined;
  156. regionUrl: string | undefined;
  157. sentryUrl: string;
  158. superuserUrl?: string;
  159. };
  160. // A list of regions that the user has membership in.
  161. memberRegions: Region[];
  162. /**
  163. * This comes from django (django.contrib.messages)
  164. */
  165. messages: Array<{level: keyof Theme['alert']; message: string}>;
  166. needsUpgrade: boolean;
  167. privacyUrl: string | null;
  168. // The list of regions the user has has access to.
  169. regions: Region[];
  170. sentryConfig: {
  171. allowUrls: string[];
  172. dsn: string;
  173. release: string;
  174. tracePropagationTargets: string[];
  175. environment?: string;
  176. profilesSampleRate?: number;
  177. };
  178. // sentryMode intends to supersede isSelfHosted,
  179. // so we can differentiate between "SELF_HOSTED", "SINGLE_TENANT", and "SAAS".
  180. sentryMode: 'SELF_HOSTED' | 'SINGLE_TENANT' | 'SAAS';
  181. shouldPreloadData: boolean;
  182. singleOrganization: boolean;
  183. superUserCookieDomain: string | null;
  184. superUserCookieName: string;
  185. supportEmail: string;
  186. termsUrl: string | null;
  187. theme: 'light' | 'dark';
  188. urlPrefix: string;
  189. /**
  190. * The user should not be accessible directly except during
  191. * app initialization. Use `useUser` or ConfigStore instead.
  192. * @deprecated
  193. */
  194. user: User;
  195. userIdentity: {
  196. email: string;
  197. id: string;
  198. ip_address: string;
  199. isStaff: boolean;
  200. };
  201. validateSUForm: boolean;
  202. version: {
  203. build: string;
  204. current: string;
  205. latest: string;
  206. upgradeAvailable: boolean;
  207. };
  208. partnershipAgreementPrompt?: {
  209. agreements: ParntershipAgreementType[];
  210. partnerDisplayName: string;
  211. } | null;
  212. relocationConfig?: {
  213. selectableRegions: string[];
  214. };
  215. shouldShowBeaconConsentPrompt?: boolean;
  216. statuspage?: {
  217. api_host: string;
  218. id: string;
  219. };
  220. }
  221. export type PipelineInitialData = {
  222. name: string;
  223. props: Record<string, any>;
  224. };
  225. export interface Broadcast {
  226. dateCreated: string;
  227. dateExpires: string;
  228. /**
  229. * Has the item been seen? affects the styling of the panel item
  230. */
  231. hasSeen: boolean;
  232. id: string;
  233. isActive: boolean;
  234. /**
  235. * The URL to use for the CTA
  236. */
  237. link: string;
  238. /**
  239. * A message with muted styling which appears above the children content
  240. */
  241. message: string;
  242. title: string;
  243. /**
  244. * Category of the broadcast.
  245. * Synced with https://github.com/getsentry/sentry/blob/master/src/sentry/models/broadcast.py#L14
  246. */
  247. category?: 'announcement' | 'feature' | 'blog' | 'event' | 'video';
  248. /**
  249. * The text for the CTA link at the bottom of the panel item
  250. */
  251. cta?: string;
  252. /**
  253. * Image url
  254. */
  255. mediaUrl?: string;
  256. /**
  257. * Region of the broadcast. If not set, the broadcast will be shown for all regions.
  258. */
  259. region?: string;
  260. }
  261. // XXX(epurkhiser): The components list can be generated using jq
  262. //
  263. // curl -s https://status.sentry.io/api/v2/components.json \
  264. // | jq -r '
  265. // .components
  266. // | map({key: (.name | gsub( "[^a-zA-Z]"; "_") | ascii_upcase ), value:.id})
  267. // | map("\(.key) = \"\(.value)\",")
  268. // | .[]'
  269. // | sort
  270. /**
  271. * Mapping of components to IDs
  272. *
  273. * Should be kept in sync with https://status.sentry.io/api/v2/components.json
  274. */
  275. export const enum StatusPageComponent {
  276. ALERTING = 'sykq5vtjw8zx',
  277. API = 'qywmfv7jr0pd',
  278. AUTHENTICATION_SERVICES = 'f5rs5z9q0dtk',
  279. AZURE_DEVOPS = 'tn9py6p7f85x',
  280. CUSTOM_METRICS = '7wrqyj84ltw7',
  281. DASHBOARD = 'khtl9dcky3lb',
  282. ELECTRON_SYMBOL_SERVER = '3jzzl28504tq',
  283. EMAIL = 'tjmyq3lb26w0',
  284. EU_ATTACHMENT_INGESTION = 'ztwsc8ff50v9',
  285. EU_CRON_MONITORING = 'qnj485gffb6v',
  286. EU_ERRORS = 'yqdr3zmyjv12',
  287. EU_ERROR_INGESTION = '1yf02ms0qsl7',
  288. EU_INGESTION = 'xmpnd79f7t51',
  289. EU_PROFILE_INGESTION = 'xbljnbzl9c77',
  290. EU_REPLAY_INGESTION = '3zhbl35gmbp0',
  291. EU_SPAN_INGESTION = '7rv05jl5qp0w',
  292. EU_TRANSACTION_INGESTION = 'tlkrt7x46b52',
  293. GITHUB = 'lqps2hvc2400',
  294. GOOGLE = 'bprcc4mhbhmm',
  295. HEROKU = '6g5bq169xp2s',
  296. INTEGRATION_PIPELINE = '6gtdt9t60dl0',
  297. MICROSOFT_SYMBOL_SERVER = '216356jwwrxq',
  298. MICROSOFT_TEAMS = 'z57k9q3r5jsh',
  299. NOTIFICATION_DELIVERY = 'rmq51qyvxfjh',
  300. PAGERDUTY = 'jd3tvjnx5l1f',
  301. PASSWORD_BASED = 'ml2wmx3hzlnn',
  302. SAML_BASED_SINGLE_SIGN_ON = 'hsbnk3hxcckr',
  303. SLACK = 'jkpcsxvvv2hf',
  304. STRIPE = '87stwrsyk6ls',
  305. THIRD_PARTY_INTEGRATIONS = 'yhfrrcmppvgh',
  306. US_ATTACHMENT_INGESTION = 'cycj4r32g25w',
  307. US_CRON_MONITORING = '6f1r28lydc6h',
  308. US_ERRORS = 'bctv81yt9s6w',
  309. US_ERROR_INGESTION = '51yszynm4xyv',
  310. US_INGESTION = '76x1wwzzfj5c',
  311. US_PROFILE_INGESTION = '52t4t3ww2qcn',
  312. US_REPLAY_INGESTION = 'zxkxxtspk64g',
  313. US_SPAN_INGESTION = 'qd7tzrk5q8xm',
  314. US_TRANSACTION_INGESTION = 'bdg4djkxjxmk',
  315. }
  316. export type StatusPageServiceStatus =
  317. | 'operational'
  318. | 'degraded_performance'
  319. | 'major_outage'
  320. | 'partial_outage';
  321. export interface StatusPageIncidentComponent {
  322. /**
  323. * ISO 8601 component creation time
  324. */
  325. created_at: string;
  326. description: string;
  327. group: boolean;
  328. group_id: string;
  329. id: StatusPageComponent;
  330. name: string;
  331. only_show_if_degraded: boolean;
  332. page_id: string;
  333. position: number;
  334. showcase: boolean;
  335. /**
  336. * Date of the component becoming active
  337. */
  338. start_date: string;
  339. status: StatusPageServiceStatus;
  340. /**
  341. * ISO 8601 component update time
  342. */
  343. updated_at: string;
  344. }
  345. export interface StatusPageAffectedComponent {
  346. code: StatusPageComponent;
  347. name: string;
  348. new_status: StatusPageServiceStatus;
  349. old_status: StatusPageServiceStatus;
  350. }
  351. export interface StatusPageIncidentUpdate {
  352. /**
  353. * Components affected by the update
  354. */
  355. affected_components: StatusPageAffectedComponent[];
  356. /**
  357. * Message to display for this update
  358. */
  359. body: string;
  360. /**
  361. * ISO Update creation time
  362. */
  363. created_at: string;
  364. /**
  365. * ISO Update display time
  366. */
  367. display_at: string;
  368. /**
  369. * Unique ID of the incident
  370. */
  371. id: string;
  372. /**
  373. * Unique ID of the incident
  374. */
  375. incident_id: string;
  376. /**
  377. * Status of the incident for tihs update
  378. */
  379. status: 'resolved' | 'monitoring' | 'identified' | 'investigating';
  380. /**
  381. * ISO Update update time
  382. */
  383. updated_at: string;
  384. }
  385. // See: https://doers.statuspage.io/api/v2/incidents/
  386. export interface StatuspageIncident {
  387. /**
  388. * Components related to this incident
  389. */
  390. components: StatusPageIncidentComponent[];
  391. /**
  392. * ISO 8601 created time
  393. */
  394. created_at: string;
  395. /**
  396. * Unique ID of the incident
  397. */
  398. id: string;
  399. /**
  400. * The impact of the incident
  401. */
  402. impact: 'none' | 'minor' | 'major';
  403. /**
  404. * Updates for this incident
  405. */
  406. incident_updates: StatusPageIncidentUpdate[];
  407. /**
  408. * ISO 8601 time monitoring began
  409. */
  410. monitoring_at: string | undefined;
  411. /**
  412. * Name of the incident
  413. */
  414. name: string;
  415. /**
  416. * The status page page ID
  417. */
  418. page_id: string;
  419. /**
  420. * ISO 8601 last updated time
  421. */
  422. resolved_at: string | undefined;
  423. /**
  424. * Short URL of the incident
  425. */
  426. shortlink: string;
  427. /**
  428. * ISO 8601 incident start time
  429. */
  430. started_at: string | undefined;
  431. /**
  432. * Current status of the incident
  433. */
  434. status: 'resolved' | 'unresolved' | 'monitoring';
  435. /**
  436. * ISO 8601 last updated time
  437. */
  438. updated_at: string | undefined;
  439. }
  440. export type PromptActivity = {
  441. dismissedTime?: number;
  442. snoozedTime?: number;
  443. };