options.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. import keyBy from 'lodash/keyBy';
  2. import BooleanField from 'sentry/components/forms/fields/booleanField';
  3. import EmailField from 'sentry/components/forms/fields/emailField';
  4. import NumberField from 'sentry/components/forms/fields/numberField';
  5. import RadioField from 'sentry/components/forms/fields/radioField';
  6. import TextField from 'sentry/components/forms/fields/textField';
  7. import ExternalLink from 'sentry/components/links/externalLink';
  8. import {t, tct} from 'sentry/locale';
  9. import ConfigStore from 'sentry/stores/configStore';
  10. type Section = {
  11. key: string;
  12. heading?: string;
  13. };
  14. // TODO(epurkhiser): This should really use the types from the form system, but
  15. // they're still pretty bad so that's difficult I guess?
  16. export type Field = {
  17. key: string;
  18. label: React.ReactNode;
  19. allowEmpty?: boolean;
  20. choices?: [value: string, label: string][];
  21. component?: React.ComponentType<any>;
  22. defaultValue?: () => string | number | false;
  23. disabled?: boolean;
  24. disabledReason?: string;
  25. help?: React.ReactNode;
  26. isSet?: boolean;
  27. max?: number;
  28. min?: number;
  29. placeholder?: string;
  30. required?: boolean;
  31. step?: number;
  32. };
  33. // This are ordered based on their display order visually
  34. const sections: Section[] = [
  35. {
  36. key: 'system',
  37. },
  38. {
  39. key: 'mail',
  40. heading: t('Outbound email'),
  41. },
  42. {
  43. key: 'auth',
  44. heading: t('Authentication'),
  45. },
  46. {
  47. key: 'beacon',
  48. heading: t('Beacon'),
  49. },
  50. ];
  51. const HIGH_THROUGHPUT_RATE_OPTION = {
  52. defaultValue: () => '0',
  53. component: NumberField,
  54. min: 0.0,
  55. max: 1.0,
  56. step: 0.0001,
  57. };
  58. const performanceOptionDefinitions: Field[] = [
  59. {
  60. key: 'performance.issues.all.problem-detection',
  61. label: t('Performance problem detection rate'),
  62. help: t(
  63. 'Controls the rate at which performance problems are detected across the entire system. A value of 0 will disable performance issue detection, and a value of 1.0 turns on detection for every ingested transaction.'
  64. ),
  65. ...HIGH_THROUGHPUT_RATE_OPTION,
  66. },
  67. {
  68. key: 'performance.issues.all.problem-creation',
  69. label: t('Performance problem creation rate'),
  70. help: t(
  71. 'Controls the rate at which performance issues are created across the entire system. A value of 0 will disable performance issue detection, and a value of 1.0 turns on creation for every detected performance problem.'
  72. ),
  73. ...HIGH_THROUGHPUT_RATE_OPTION,
  74. },
  75. {
  76. key: 'performance.issues.all.early-adopter-rollout',
  77. label: t('Performance issues creation EA Rollout'),
  78. help: t(
  79. 'Controls the rate at which performance issues are created for EA organizations.'
  80. ),
  81. ...HIGH_THROUGHPUT_RATE_OPTION,
  82. },
  83. {
  84. key: 'performance.issues.all.general-availability-rollout',
  85. label: t('Performance issues creation GA Rollout'),
  86. help: t(
  87. 'Controls the rate at which performance issues are created for all organizations.'
  88. ),
  89. ...HIGH_THROUGHPUT_RATE_OPTION,
  90. },
  91. {
  92. key: 'performance.issues.all.post-process-group-early-adopter-rollout',
  93. label: t('Performance issues post process group EA Rollout'),
  94. help: t(
  95. 'Controls the rate at which performance issues sent through post process group for EA organizations.'
  96. ),
  97. ...HIGH_THROUGHPUT_RATE_OPTION,
  98. },
  99. {
  100. key: 'performance.issues.all.post-process-group-ga-rollout',
  101. label: t('Performance issues post process group GA Rollout'),
  102. help: t(
  103. 'Controls the rate at which performance issues sent through post process group for all organizations.'
  104. ),
  105. ...HIGH_THROUGHPUT_RATE_OPTION,
  106. },
  107. {
  108. key: 'performance.issues.n_plus_one.problem-detection',
  109. label: t('N+1 detection rate'),
  110. help: t(
  111. 'Controls the rate at which performance problems are detected specifically for N+1 detection. Value of 0 will disable detection, a value of 1.0 fully enables it.'
  112. ),
  113. ...HIGH_THROUGHPUT_RATE_OPTION,
  114. },
  115. {
  116. key: 'performance.issues.n_plus_one.problem-creation',
  117. label: t('N+1 creation rate'),
  118. help: t(
  119. 'Controls the rate at which performance issues are created specifically for N+1 detection. Value of 0 will disable creation, a value of 1.0 fully enables it.'
  120. ),
  121. ...HIGH_THROUGHPUT_RATE_OPTION,
  122. },
  123. {
  124. key: 'performance.issues.n_plus_one_db.problem-detection',
  125. label: t('N+1 (DB) detection rate'),
  126. help: t(
  127. 'Controls the rate at which performance problems are detected specifically for N+1 detection. Value of 0 will disable detection, a value of 1.0 fully enables it.'
  128. ),
  129. ...HIGH_THROUGHPUT_RATE_OPTION,
  130. },
  131. {
  132. key: 'performance.issues.n_plus_one_db.problem-creation',
  133. label: t('N+1 (DB) creation rate'),
  134. help: t(
  135. 'Controls the rate at which performance issues are created specifically for N+1 detection. Value of 0 will disable creation, a value of 1.0 fully enables it.'
  136. ),
  137. ...HIGH_THROUGHPUT_RATE_OPTION,
  138. },
  139. {
  140. key: 'performance.issues.n_plus_one_db_ext.problem-creation',
  141. label: t('N+1 (DB) (Extended) creation rate'),
  142. help: t(
  143. 'Controls the rate at which performance issues are created specifically for N+1 detection (extended). Value of 0 will disable creation, a value of 1.0 fully enables it.'
  144. ),
  145. ...HIGH_THROUGHPUT_RATE_OPTION,
  146. },
  147. {
  148. key: 'performance.issues.n_plus_one_db.count_threshold',
  149. label: t('N+1 (DB) count threshold'),
  150. help: t(
  151. 'Detector threshold. Controls the number of spans required to trigger performance issues. This affects all organizations system-wide.'
  152. ),
  153. defaultValue: () => '5',
  154. component: NumberField,
  155. min: 0,
  156. max: Number.MAX_SAFE_INTEGER,
  157. step: 1,
  158. },
  159. {
  160. key: 'performance.issues.n_plus_one_db.duration_threshold', // TODO: For fixing typo later.
  161. label: t('N+1 (DB) duration threshold'),
  162. help: t(
  163. 'Detector threshold. Controls the threshold for the cumulative duration of involved spans required to trigger performance issues. This affects all organizations system-wide.'
  164. ),
  165. defaultValue: () => '100',
  166. component: NumberField,
  167. min: 0,
  168. max: Number.MAX_SAFE_INTEGER,
  169. step: 1,
  170. },
  171. {
  172. key: 'performance.issues.consecutive_db.problem-creation',
  173. label: t('Problem Creation Rate'),
  174. help: t(
  175. 'Controls the overall rate at which performance problems are detected by the Consecutive DB detector.'
  176. ),
  177. ...HIGH_THROUGHPUT_RATE_OPTION,
  178. },
  179. {
  180. key: 'performance.issues.consecutive_db.la-rollout',
  181. label: t('Limited Availability Detection Rate'),
  182. help: t(
  183. 'Controls the rate at which performance problems are detected by the Consecutive DB detector for LA organizations.'
  184. ),
  185. ...HIGH_THROUGHPUT_RATE_OPTION,
  186. },
  187. {
  188. key: 'performance.issues.consecutive_db.ea-rollout',
  189. label: t('Early Adopter Detection Rate'),
  190. help: t(
  191. 'Controls the rate at which performance problems are detected by the Consecutive DB detector for EA organizations.'
  192. ),
  193. ...HIGH_THROUGHPUT_RATE_OPTION,
  194. },
  195. {
  196. key: 'performance.issues.consecutive_db.ga-rollout',
  197. label: t('General Availability Detection Rate'),
  198. help: t(
  199. 'Controls the rate at which performance problems are detected by the Consecutive DB detector for GA organizations.'
  200. ),
  201. ...HIGH_THROUGHPUT_RATE_OPTION,
  202. },
  203. {
  204. key: 'performance.issues.n_plus_one_api_calls.problem-creation',
  205. label: t('Problem Creation Rate'),
  206. help: t(
  207. 'Controls the overall rate at which performance problems are detected by the N+1 API Calls detector.'
  208. ),
  209. ...HIGH_THROUGHPUT_RATE_OPTION,
  210. },
  211. {
  212. key: 'performance.issues.n_plus_one_api_calls.la-rollout',
  213. label: t('Limited Availability Detection Rate'),
  214. help: t(
  215. 'Controls the rate at which performance problems are detected by the N+1 API Calls detector for LA organizations.'
  216. ),
  217. ...HIGH_THROUGHPUT_RATE_OPTION,
  218. },
  219. {
  220. key: 'performance.issues.n_plus_one_api_calls.ea-rollout',
  221. label: t('Early Adopter Detection Rate'),
  222. help: t(
  223. 'Controls the rate at which performance problems are detected by the N+1 API Calls detector for EA organizations.'
  224. ),
  225. ...HIGH_THROUGHPUT_RATE_OPTION,
  226. },
  227. {
  228. key: 'performance.issues.n_plus_one_api_calls.ga-rollout',
  229. label: t('General Availability Detection Rate'),
  230. help: t(
  231. 'Controls the rate at which performance problems are detected by the for N+1 API Calls detector for GA organizations.'
  232. ),
  233. ...HIGH_THROUGHPUT_RATE_OPTION,
  234. },
  235. {
  236. key: 'performance.issues.compressed_assets.problem-creation',
  237. label: t('Problem Creation Rate'),
  238. help: t(
  239. 'Controls the overall rate at which performance problems are detected by the compressed assets detector.'
  240. ),
  241. ...HIGH_THROUGHPUT_RATE_OPTION,
  242. },
  243. {
  244. key: 'performance.issues.compressed_assets.la-rollout',
  245. label: t('Limited Availability Detection Rate'),
  246. help: t(
  247. 'Controls the rate at which performance problems are detected by the compressed assets detector for LA organizations.'
  248. ),
  249. ...HIGH_THROUGHPUT_RATE_OPTION,
  250. },
  251. {
  252. key: 'performance.issues.compressed_assets.ea-rollout',
  253. label: t('Early Adopter Detection Rate'),
  254. help: t(
  255. 'Controls the rate at which performance problems are detected by the compressed assets detector for EA organizations.'
  256. ),
  257. ...HIGH_THROUGHPUT_RATE_OPTION,
  258. },
  259. {
  260. key: 'performance.issues.compressed_assets.ga-rollout',
  261. label: t('General Availability Detection Rate'),
  262. help: t(
  263. 'Controls the rate at which performance problems are detected by the compressed assets detector for GA organizations.'
  264. ),
  265. ...HIGH_THROUGHPUT_RATE_OPTION,
  266. },
  267. {
  268. key: 'performance.issues.file_io_main_thread.problem-creation',
  269. label: t('File IO Problem Creation Rate'),
  270. help: t(
  271. 'Controls the overall rate at which performance problems are detected by the File IO Detector'
  272. ),
  273. ...HIGH_THROUGHPUT_RATE_OPTION,
  274. },
  275. {
  276. key: 'performance.issues.slow_db_query.problem-creation',
  277. label: t('Problem Creation Rate'),
  278. help: t(
  279. 'Controls the overall rate at which performance problems are detected by the slow DB span detector.'
  280. ),
  281. ...HIGH_THROUGHPUT_RATE_OPTION,
  282. },
  283. {
  284. key: 'performance.issues.slow_db_query.la-rollout',
  285. label: t('Limited Availability Detection Rate'),
  286. help: t(
  287. 'Controls the rate at which performance problems are detected by the slow DB span detector for LA organizations.'
  288. ),
  289. ...HIGH_THROUGHPUT_RATE_OPTION,
  290. },
  291. {
  292. key: 'performance.issues.slow_db_query.ea-rollout',
  293. label: t('Early Adopter Detection Rate'),
  294. help: t(
  295. 'Controls the rate at which performance problems are detected by the slow DB span detector for EA organizations.'
  296. ),
  297. ...HIGH_THROUGHPUT_RATE_OPTION,
  298. },
  299. {
  300. key: 'performance.issues.slow_db_query.ga-rollout',
  301. label: t('General Availability Detection Rate'),
  302. help: t(
  303. 'Controls the rate at which performance problems are detected by the slow DB span detector for GA organizations.'
  304. ),
  305. ...HIGH_THROUGHPUT_RATE_OPTION,
  306. },
  307. {
  308. key: 'performance.issues.m_n_plus_one_db.problem-creation',
  309. label: t('Problem Creation Rate'),
  310. help: t(
  311. 'Controls the overall rate at which performance problems are detected by the MN+1 DB detector.'
  312. ),
  313. ...HIGH_THROUGHPUT_RATE_OPTION,
  314. },
  315. {
  316. key: 'performance.issues.m_n_plus_one_db.la-rollout',
  317. label: t('Limited Availability Detection Rate'),
  318. help: t(
  319. 'Controls the % of orgs in which performance problems are detected by the MN+1 DB detector for LA organizations.'
  320. ),
  321. ...HIGH_THROUGHPUT_RATE_OPTION,
  322. },
  323. {
  324. key: 'performance.issues.m_n_plus_one_db.ea-rollout',
  325. label: t('Early Adopter Detection Rate'),
  326. help: t(
  327. 'Controls the % of orgs in which performance problems are detected by the MN+1 DB detector for EA organizations.'
  328. ),
  329. ...HIGH_THROUGHPUT_RATE_OPTION,
  330. },
  331. {
  332. key: 'performance.issues.m_n_plus_one_db.ga-rollout',
  333. label: t('General Availability Detection Rate'),
  334. help: t(
  335. 'Controls the % of orgs in which performance problems are detected by the MN+1 DB detector for GA organizations.'
  336. ),
  337. ...HIGH_THROUGHPUT_RATE_OPTION,
  338. },
  339. {
  340. key: 'performance.issues.render_blocking_assets.problem-creation',
  341. label: t('Problem Creation Rate'),
  342. help: t(
  343. 'Controls the overall rate at which performance problems are detected by the large render blocking asset detector.'
  344. ),
  345. },
  346. {
  347. key: 'performance.issues.render_blocking_assets.la-rollout',
  348. label: t('Limited Availability Detection Rate'),
  349. help: t(
  350. 'Controls the rate at which performance problems are detected by the large render blocking asset detector for LA organizations.'
  351. ),
  352. },
  353. {
  354. key: 'performance.issues.render_blocking_assets.ea-rollout',
  355. label: t('Early Adopter Detection Rate'),
  356. help: t(
  357. 'Controls the rate at which performance problems are detected by the large render blocking asset detector for EA organizations.'
  358. ),
  359. },
  360. {
  361. key: 'performance.issues.render_blocking_assets.ga-rollout',
  362. label: t('General Availability Detection Rate'),
  363. help: t(
  364. 'Controls the rate at which performance problems are detected by the large render blocking asset detector for GA organizations.'
  365. ),
  366. },
  367. {
  368. key: 'performance.issues.consecutive_http.max_duration_between_spans',
  369. label: t('Time Between Spans'),
  370. help: t(
  371. 'Maximum time, in ms, between consecutive HTTP spans to be considered part of the same problem.'
  372. ),
  373. defaultValue: () => '1000',
  374. component: NumberField,
  375. min: 0,
  376. max: Number.MAX_SAFE_INTEGER,
  377. step: 1,
  378. },
  379. {
  380. key: 'performance.issues.consecutive_http.consecutive_count_threshold',
  381. label: t('Consecutive Count Threshold'),
  382. help: t('The minimum number of offending spans that must occur consecutively.'),
  383. defaultValue: () => '3',
  384. component: NumberField,
  385. min: 1,
  386. max: Number.MAX_SAFE_INTEGER,
  387. step: 1,
  388. },
  389. {
  390. key: 'performance.issues.consecutive_http.span_duration_threshold',
  391. label: t('Span Duration Threshold'),
  392. help: t(
  393. 'The duration, in ms, that a span must exceed for it to be considered an offending span.'
  394. ),
  395. defaultValue: () => '1000',
  396. component: NumberField,
  397. min: 0,
  398. max: Number.MAX_SAFE_INTEGER,
  399. step: 1,
  400. },
  401. {
  402. key: 'performance.issues.large_http_payload.size_threshold',
  403. label: t('Payload Size Threshold'),
  404. help: t(
  405. 'The threshold at which the payload size of an HTTP span is considered to be too large, in bytes.'
  406. ),
  407. defaultValue: () => '1000000',
  408. component: NumberField,
  409. min: 0,
  410. max: Number.MAX_SAFE_INTEGER,
  411. step: 1,
  412. },
  413. {
  414. key: 'profile.issues.blocked_main_thread-ingest.la-rollout',
  415. label: t('Limited Availability Detection Rate'),
  416. help: t(
  417. 'Controls the rate at which performance problems are detected by the blocked main thread profiling detector for LA organizations.'
  418. ),
  419. ...HIGH_THROUGHPUT_RATE_OPTION,
  420. },
  421. {
  422. key: 'profile.issues.blocked_main_thread-ingest.ea-rollout',
  423. label: t('Early Adopter Detection Rate'),
  424. help: t(
  425. 'Controls the rate at which performance problems are detected by the blocked main thread profiling detector for EA organizations.'
  426. ),
  427. ...HIGH_THROUGHPUT_RATE_OPTION,
  428. },
  429. {
  430. key: 'profile.issues.blocked_main_thread-ingest.ga-rollout',
  431. label: t('General Availability Detection Rate'),
  432. help: t(
  433. 'Controls the rate at which performance problems are detected by the blocked main thread profiling detector for GA organizations.'
  434. ),
  435. ...HIGH_THROUGHPUT_RATE_OPTION,
  436. },
  437. {
  438. key: 'profile.issues.blocked_main_thread-ppg.la-rollout',
  439. label: t('Limited Availability Detection Rate'),
  440. help: t(
  441. 'Controls the rate at which profile blocked main thread performance problems are sent to post process group for LA organizations.'
  442. ),
  443. ...HIGH_THROUGHPUT_RATE_OPTION,
  444. },
  445. {
  446. key: 'profile.issues.blocked_main_thread-ppg.ea-rollout',
  447. label: t('Early Adopter Detection Rate'),
  448. help: t(
  449. 'Controls the rate at which profile blocked main thread performance problems are sent to post process group for EA organizations.'
  450. ),
  451. ...HIGH_THROUGHPUT_RATE_OPTION,
  452. },
  453. {
  454. key: 'profile.issues.blocked_main_thread-ppg.ga-rollout',
  455. label: t('General Availability Detection Rate'),
  456. help: t(
  457. 'Controls the rate at which profile blocked main thread performance problems are sent to post process group for GA organizations.'
  458. ),
  459. ...HIGH_THROUGHPUT_RATE_OPTION,
  460. },
  461. ];
  462. // This are ordered based on their display order visually
  463. const definitions: Field[] = [
  464. {
  465. key: 'system.url-prefix',
  466. label: t('Root URL'),
  467. placeholder: 'https://sentry.example.com',
  468. help: t('The root web address which is used to communicate with the Sentry backend.'),
  469. defaultValue: () => `${document.location.protocol}//${document.location.host}`,
  470. },
  471. {
  472. key: 'system.admin-email',
  473. label: t('Admin Email'),
  474. placeholder: 'admin@example.com',
  475. help: t('The technical contact for this Sentry installation.'),
  476. // TODO(dcramer): this should not be hardcoded to a component
  477. component: EmailField,
  478. defaultValue: () => ConfigStore.get('user').email,
  479. },
  480. {
  481. key: 'system.support-email',
  482. label: t('Support Email'),
  483. placeholder: 'support@example.com',
  484. help: t('The support contact for this Sentry installation.'),
  485. // TODO(dcramer): this should not be hardcoded to a component
  486. component: EmailField,
  487. defaultValue: () => ConfigStore.get('user').email,
  488. },
  489. {
  490. key: 'system.security-email',
  491. label: t('Security Email'),
  492. placeholder: 'security@example.com',
  493. help: t('The security contact for this Sentry installation.'),
  494. // TODO(dcramer): this should not be hardcoded to a component
  495. component: EmailField,
  496. defaultValue: () => ConfigStore.get('user').email,
  497. },
  498. {
  499. key: 'system.rate-limit',
  500. label: t('Rate Limit'),
  501. placeholder: 'e.g. 500',
  502. help: t(
  503. 'The maximum number of events the system should accept per minute. A value of 0 will disable the default rate limit.'
  504. ),
  505. },
  506. {
  507. key: 'auth.allow-registration',
  508. label: t('Allow Registration'),
  509. help: t('Allow anyone to create an account and access this Sentry installation.'),
  510. component: BooleanField,
  511. defaultValue: () => false,
  512. },
  513. {
  514. key: 'auth.ip-rate-limit',
  515. label: t('IP Rate Limit'),
  516. placeholder: 'e.g. 10',
  517. help: t(
  518. 'The maximum number of times an authentication attempt may be made by a single IP address in a 60 second window.'
  519. ),
  520. },
  521. {
  522. key: 'auth.user-rate-limit',
  523. label: t('User Rate Limit'),
  524. placeholder: 'e.g. 10',
  525. help: t(
  526. 'The maximum number of times an authentication attempt may be made against a single account in a 60 second window.'
  527. ),
  528. },
  529. {
  530. key: 'api.rate-limit.org-create',
  531. label: t('Organization Creation Rate Limit'),
  532. placeholder: 'e.g. 5',
  533. help: t(
  534. 'The maximum number of organizations which may be created by a single account in a one hour window.'
  535. ),
  536. },
  537. {
  538. key: 'beacon.anonymous',
  539. label: 'Usage Statistics',
  540. component: RadioField,
  541. // yes and no are inverted here due to the nature of this configuration
  542. choices: [
  543. ['false', t('Send my contact information along with usage statistics')],
  544. ['true', t('Please keep my usage information anonymous')],
  545. ],
  546. help: tct(
  547. 'If enabled, any stats reported to sentry.io will exclude identifying information (such as your administrative email address). By anonymizing your installation the Sentry team will be unable to contact you about security updates. For more information on what data is sent to Sentry, see the [link:documentation]. Note: This is separate from error-reporting for the self-hosted installer. The data reported to the beacon only includes usage stats from your running self-hosted instance.',
  548. {
  549. link: <ExternalLink href="https://develop.sentry.dev/self-hosted/" />,
  550. }
  551. ),
  552. },
  553. {
  554. key: 'beacon.record_cpu_ram_usage',
  555. label: 'RAM/CPU usage',
  556. component: RadioField,
  557. defaultValue: () => 'true',
  558. choices: [
  559. [
  560. 'true',
  561. t(
  562. 'Yes, I would love to help Sentry developers improve the experience of self-hosted by sending CPU/RAM usage'
  563. ),
  564. ],
  565. ['false', t('No, I would prefer to keep CPU/RAM usage private')],
  566. ],
  567. help: tct(
  568. `Recording CPU/RAM usage will greatly help our development team understand how self-hosted sentry
  569. is being typically used, and to keep track of improvements that we hope to bring you in the future.`,
  570. {link: <ExternalLink href="https://sentry.io/privacy/" />}
  571. ),
  572. },
  573. {
  574. key: 'mail.from',
  575. label: t('Email From'),
  576. component: EmailField,
  577. defaultValue: () => `sentry@${document.location.hostname}`,
  578. help: t('Email address to be used in From for all outbound email.'),
  579. },
  580. {
  581. key: 'mail.host',
  582. label: t('SMTP Host'),
  583. placeholder: 'localhost',
  584. defaultValue: () => 'localhost',
  585. },
  586. {
  587. key: 'mail.port',
  588. label: t('SMTP Port'),
  589. placeholder: '25',
  590. defaultValue: () => '25',
  591. },
  592. {
  593. key: 'mail.username',
  594. label: t('SMTP Username'),
  595. defaultValue: () => '',
  596. },
  597. {
  598. key: 'mail.password',
  599. label: t('SMTP Password'),
  600. // TODO(mattrobenolt): We don't want to use a real password field unless
  601. // there's a way to reveal it. Without being able to see the password, it's
  602. // impossible to confirm if it's right.
  603. // component: PasswordField,
  604. defaultValue: () => '',
  605. },
  606. {
  607. key: 'mail.use-tls',
  608. label: t('Use STARTTLS? (exclusive with SSL)'),
  609. component: BooleanField,
  610. defaultValue: () => false,
  611. },
  612. {
  613. key: 'mail.use-ssl',
  614. label: t('Use SSL? (exclusive with STARTTLS)'),
  615. component: BooleanField,
  616. defaultValue: () => false,
  617. },
  618. ...performanceOptionDefinitions,
  619. ];
  620. const definitionsMap = keyBy(definitions, def => def.key);
  621. const disabledReasons = {
  622. diskPriority:
  623. 'This setting is defined in config.yml and may not be changed via the web UI.',
  624. smtpDisabled: 'SMTP mail has been disabled, so this option is unavailable',
  625. };
  626. export function getOption(option: string): Field {
  627. return definitionsMap[option];
  628. }
  629. export function getOptionDefault(option: string): string | number | false | undefined {
  630. const meta = getOption(option);
  631. return meta.defaultValue ? meta.defaultValue() : undefined;
  632. }
  633. function optionsForSection(section: Section) {
  634. return definitions.filter(option => option.key.split('.')[0] === section.key);
  635. }
  636. export function getOptionField(option: string, field: Field) {
  637. const meta = {...getOption(option), ...field};
  638. const Field = meta.component || TextField;
  639. return (
  640. <Field
  641. {...meta}
  642. name={option}
  643. key={option}
  644. defaultValue={getOptionDefault(option)}
  645. required={meta.required && !meta.allowEmpty}
  646. disabledReason={meta.disabledReason && disabledReasons[meta.disabledReason]}
  647. />
  648. );
  649. }
  650. function getSectionFieldSet(section: Section, fields: React.ReactNode[]) {
  651. return (
  652. <fieldset key={section.key}>
  653. {section.heading && <legend>{section.heading}</legend>}
  654. {fields}
  655. </fieldset>
  656. );
  657. }
  658. export function getForm(fieldMap: Record<string, React.ReactNode>) {
  659. const sets: React.ReactNode[] = [];
  660. for (const section of sections) {
  661. const set: React.ReactNode[] = [];
  662. for (const option of optionsForSection(section)) {
  663. if (fieldMap[option.key]) {
  664. set.push(fieldMap[option.key]);
  665. }
  666. }
  667. if (set.length) {
  668. sets.push(getSectionFieldSet(section, set));
  669. }
  670. }
  671. return sets;
  672. }