system.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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 './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. isSelfHostedErrorsOnly: boolean;
  143. languageCode: string;
  144. lastOrganization: string | null;
  145. links: {
  146. organizationUrl: string | undefined;
  147. regionUrl: string | undefined;
  148. sentryUrl: string;
  149. superuserUrl?: string;
  150. };
  151. // A list of regions that the user has membership in.
  152. memberRegions: Region[];
  153. /**
  154. * This comes from django (django.contrib.messages)
  155. */
  156. messages: {level: keyof Theme['alert']; message: string}[];
  157. needsUpgrade: boolean;
  158. privacyUrl: string | null;
  159. // The list of regions the user has has access to.
  160. regions: Region[];
  161. sentryConfig: {
  162. allowUrls: string[];
  163. dsn: string;
  164. release: string;
  165. tracePropagationTargets: string[];
  166. environment?: string;
  167. profilesSampleRate?: number;
  168. };
  169. // sentryMode intends to supersede isSelfHosted,
  170. // so we can differentiate between "SELF_HOSTED", "SINGLE_TENANT", and "SAAS".
  171. sentryMode: 'SELF_HOSTED' | 'SINGLE_TENANT' | 'SAAS';
  172. shouldPreloadData: boolean;
  173. singleOrganization: boolean;
  174. superUserCookieDomain: string | null;
  175. superUserCookieName: string;
  176. supportEmail: string;
  177. termsUrl: string | null;
  178. theme: 'light' | 'dark';
  179. urlPrefix: string;
  180. /**
  181. * The user should not be accessible directly except during
  182. * app initialization. Use `useUser` or ConfigStore instead.
  183. * @deprecated
  184. */
  185. user: User;
  186. userIdentity: {
  187. email: string;
  188. id: string;
  189. ip_address: string;
  190. isStaff: boolean;
  191. };
  192. validateSUForm: boolean;
  193. version: {
  194. build: string;
  195. current: string;
  196. latest: string;
  197. upgradeAvailable: boolean;
  198. };
  199. partnershipAgreementPrompt?: {
  200. agreements: Array<ParntershipAgreementType>;
  201. partnerDisplayName: string;
  202. } | null;
  203. relocationConfig?: {
  204. selectableRegions: string[];
  205. };
  206. shouldShowBeaconConsentPrompt?: boolean;
  207. statuspage?: {
  208. api_host: string;
  209. id: string;
  210. };
  211. }
  212. export type PipelineInitialData = {
  213. name: string;
  214. props: Record<string, any>;
  215. };
  216. export interface Broadcast {
  217. dateCreated: string;
  218. dateExpires: string;
  219. /**
  220. * Has the item been seen? affects the styling of the panel item
  221. */
  222. hasSeen: boolean;
  223. id: string;
  224. isActive: boolean;
  225. /**
  226. * The URL to use for the CTA
  227. */
  228. link: string;
  229. /**
  230. * A message with muted styling which appears above the children content
  231. */
  232. message: string;
  233. title: string;
  234. /**
  235. * Category of the broadcast.
  236. * Synced with https://github.com/getsentry/sentry/blob/master/src/sentry/models/broadcast.py#L14
  237. */
  238. category?: 'announcement' | 'feature' | 'blog' | 'event' | 'video';
  239. /**
  240. * The text for the CTA link at the bottom of the panel item
  241. */
  242. cta?: string;
  243. /**
  244. * Image url
  245. */
  246. mediaUrl?: string;
  247. /**
  248. * Region of the broadcast. If not set, the broadcast will be shown for all regions.
  249. */
  250. region?: string;
  251. }
  252. // XXX(epurkhiser): The components list can be generated using jq
  253. //
  254. // curl -s https://status.sentry.io/api/v2/components.json \
  255. // | jq -r '
  256. // .components
  257. // | map({key: (.name | gsub( "[^a-zA-Z]"; "_") | ascii_upcase ), value:.id})
  258. // | map("\(.key) = \"\(.value)\",")
  259. // | .[]'
  260. // | sort
  261. /**
  262. * Mapping of components to IDs
  263. *
  264. * Should be kept in sync with https://status.sentry.io/api/v2/components.json
  265. */
  266. export const enum StatusPageComponent {
  267. ALERTING = 'sykq5vtjw8zx',
  268. API = 'qywmfv7jr0pd',
  269. AUTHENTICATION_SERVICES = 'f5rs5z9q0dtk',
  270. AZURE_DEVOPS = 'tn9py6p7f85x',
  271. CUSTOM_METRICS = '7wrqyj84ltw7',
  272. DASHBOARD = 'khtl9dcky3lb',
  273. ELECTRON_SYMBOL_SERVER = '3jzzl28504tq',
  274. EMAIL = 'tjmyq3lb26w0',
  275. EU_ATTACHMENT_INGESTION = 'ztwsc8ff50v9',
  276. EU_CRON_MONITORING = 'qnj485gffb6v',
  277. EU_ERRORS = 'yqdr3zmyjv12',
  278. EU_ERROR_INGESTION = '1yf02ms0qsl7',
  279. EU_INGESTION = 'xmpnd79f7t51',
  280. EU_PROFILE_INGESTION = 'xbljnbzl9c77',
  281. EU_REPLAY_INGESTION = '3zhbl35gmbp0',
  282. EU_SPAN_INGESTION = '7rv05jl5qp0w',
  283. EU_TRANSACTION_INGESTION = 'tlkrt7x46b52',
  284. GITHUB = 'lqps2hvc2400',
  285. GOOGLE = 'bprcc4mhbhmm',
  286. HEROKU = '6g5bq169xp2s',
  287. INTEGRATION_PIPELINE = '6gtdt9t60dl0',
  288. MICROSOFT_SYMBOL_SERVER = '216356jwwrxq',
  289. MICROSOFT_TEAMS = 'z57k9q3r5jsh',
  290. NOTIFICATION_DELIVERY = 'rmq51qyvxfjh',
  291. PAGERDUTY = 'jd3tvjnx5l1f',
  292. PASSWORD_BASED = 'ml2wmx3hzlnn',
  293. SAML_BASED_SINGLE_SIGN_ON = 'hsbnk3hxcckr',
  294. SLACK = 'jkpcsxvvv2hf',
  295. STRIPE = '87stwrsyk6ls',
  296. THIRD_PARTY_INTEGRATIONS = 'yhfrrcmppvgh',
  297. US_ATTACHMENT_INGESTION = 'cycj4r32g25w',
  298. US_CRON_MONITORING = '6f1r28lydc6h',
  299. US_ERRORS = 'bctv81yt9s6w',
  300. US_ERROR_INGESTION = '51yszynm4xyv',
  301. US_INGESTION = '76x1wwzzfj5c',
  302. US_PROFILE_INGESTION = '52t4t3ww2qcn',
  303. US_REPLAY_INGESTION = 'zxkxxtspk64g',
  304. US_SPAN_INGESTION = 'qd7tzrk5q8xm',
  305. US_TRANSACTION_INGESTION = 'bdg4djkxjxmk',
  306. }
  307. export type StatusPageServiceStatus =
  308. | 'operational'
  309. | 'degraded_performance'
  310. | 'major_outage'
  311. | 'partial_outage';
  312. export interface StatusPageIncidentComponent {
  313. /**
  314. * ISO 8601 component creation time
  315. */
  316. created_at: string;
  317. description: string;
  318. group: boolean;
  319. group_id: string;
  320. id: StatusPageComponent;
  321. name: string;
  322. only_show_if_degraded: boolean;
  323. page_id: string;
  324. position: number;
  325. showcase: boolean;
  326. /**
  327. * Date of the component becoming active
  328. */
  329. start_date: string;
  330. status: StatusPageServiceStatus;
  331. /**
  332. * ISO 8601 component update time
  333. */
  334. updated_at: string;
  335. }
  336. export interface StatusPageAffectedComponent {
  337. code: StatusPageComponent;
  338. name: string;
  339. new_status: StatusPageServiceStatus;
  340. old_status: StatusPageServiceStatus;
  341. }
  342. export interface StatusPageIncidentUpdate {
  343. /**
  344. * Components affected by the update
  345. */
  346. affected_components: StatusPageAffectedComponent[];
  347. /**
  348. * Message to display for this update
  349. */
  350. body: string;
  351. /**
  352. * ISO Update creation time
  353. */
  354. created_at: string;
  355. /**
  356. * ISO Update display time
  357. */
  358. display_at: string;
  359. /**
  360. * Unique ID of the incident
  361. */
  362. id: string;
  363. /**
  364. * Unique ID of the incident
  365. */
  366. incident_id: string;
  367. /**
  368. * Status of the incident for tihs update
  369. */
  370. status: 'resolved' | 'monitoring' | 'identified' | 'investigating';
  371. /**
  372. * ISO Update update time
  373. */
  374. updated_at: string;
  375. }
  376. // See: https://doers.statuspage.io/api/v2/incidents/
  377. export interface StatuspageIncident {
  378. /**
  379. * Components related to this incident
  380. */
  381. components: StatusPageIncidentComponent[];
  382. /**
  383. * ISO 8601 created time
  384. */
  385. created_at: string;
  386. /**
  387. * Unique ID of the incident
  388. */
  389. id: string;
  390. /**
  391. * The impact of the incident
  392. */
  393. impact: 'none' | 'minor' | 'major';
  394. /**
  395. * Updates for this incident
  396. */
  397. incident_updates: StatusPageIncidentUpdate[];
  398. /**
  399. * ISO 8601 time monitoring began
  400. */
  401. monitoring_at: string | undefined;
  402. /**
  403. * Name of the incident
  404. */
  405. name: string;
  406. /**
  407. * The status page page ID
  408. */
  409. page_id: string;
  410. /**
  411. * ISO 8601 last updated time
  412. */
  413. resolved_at: string | undefined;
  414. /**
  415. * Short URL of the incident
  416. */
  417. shortlink: string;
  418. /**
  419. * ISO 8601 incident start time
  420. */
  421. started_at: string | undefined;
  422. /**
  423. * Current status of the incident
  424. */
  425. status: 'resolved' | 'unresolved' | 'monitoring';
  426. /**
  427. * ISO 8601 last updated time
  428. */
  429. updated_at: string | undefined;
  430. }
  431. export type PromptActivity = {
  432. dismissedTime?: number;
  433. snoozedTime?: number;
  434. };