index.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. /* global process */
  2. import {t} from 'sentry/locale';
  3. import {
  4. DataCategoryExact,
  5. DataCategoryInfo,
  6. OrgRole,
  7. PermissionResource,
  8. Scope,
  9. } from 'sentry/types';
  10. /**
  11. * Common constants here
  12. */
  13. // This is the element id where we render our React application to
  14. export const ROOT_ELEMENT = 'blk_router';
  15. export const USING_CUSTOMER_DOMAIN =
  16. typeof window !== 'undefined' ? Boolean(window?.__initialData?.customerDomain) : false;
  17. export const CUSTOMER_DOMAIN =
  18. typeof window !== 'undefined'
  19. ? window?.__initialData?.customerDomain?.subdomain
  20. : undefined;
  21. // This is considered the "default" route/view that users should be taken
  22. // to when the application does not have any further context
  23. //
  24. // e.g. loading app root or switching organization
  25. export const DEFAULT_APP_ROUTE = USING_CUSTOMER_DOMAIN
  26. ? '/issues/'
  27. : '/organizations/:orgSlug/issues/';
  28. export const API_ACCESS_SCOPES = [
  29. 'alerts:read',
  30. 'alerts:write',
  31. 'event:admin',
  32. 'event:read',
  33. 'event:write',
  34. 'member:admin',
  35. 'member:read',
  36. 'member:write',
  37. 'org:admin',
  38. 'org:integrations',
  39. 'org:read',
  40. 'org:write',
  41. 'project:admin',
  42. 'project:read',
  43. 'project:releases',
  44. 'project:write',
  45. 'team:admin',
  46. 'team:read',
  47. 'team:write',
  48. ] as const;
  49. export const ALLOWED_SCOPES = [
  50. 'alerts:read',
  51. 'alerts:write',
  52. 'event:admin',
  53. 'event:read',
  54. 'event:write',
  55. 'member:admin',
  56. 'member:read',
  57. 'member:write',
  58. 'org:admin',
  59. 'org:integrations',
  60. 'org:read',
  61. 'org:superuser', // not an assignable API access scope
  62. 'org:write',
  63. 'project:admin',
  64. 'project:read',
  65. 'project:releases',
  66. 'project:write',
  67. 'team:admin',
  68. 'team:read',
  69. 'team:write',
  70. ] as const;
  71. // These should only be used in the case where we cannot obtain roles through
  72. // the members endpoint (primarily in cases where a user is admining a
  73. // different organization they are not a OrganizationMember of ).
  74. export const ORG_ROLES: OrgRole[] = [
  75. {
  76. id: 'member',
  77. name: 'Member',
  78. allowed: true,
  79. desc: 'Members can view and act on events, as well as view most other data within the organization.',
  80. minimumTeamRole: 'contributor',
  81. },
  82. {
  83. id: 'admin',
  84. name: 'Admin',
  85. allowed: true,
  86. desc: "Admin privileges on any teams of which they're a member. They can create new teams and projects, as well as remove teams and projects on which they already hold membership (or all teams, if open membership is enabled). Additionally, they can manage memberships of teams that they are members of. They cannot invite members to the organization.",
  87. minimumTeamRole: 'admin',
  88. },
  89. {
  90. id: 'manager',
  91. name: 'Manager',
  92. allowed: true,
  93. desc: 'Gains admin access on all teams as well as the ability to add and remove members.',
  94. minimumTeamRole: 'admin',
  95. },
  96. {
  97. id: 'owner',
  98. name: 'Organization Owner',
  99. allowed: true,
  100. desc: 'Unrestricted access to the organization, its data, and its settings. Can add, modify, and delete projects and members, as well as make billing and plan changes.',
  101. minimumTeamRole: 'admin',
  102. },
  103. ];
  104. export type PermissionChoice = {
  105. label: 'No Access' | 'Read' | 'Read & Write' | 'Admin';
  106. scopes: Scope[];
  107. };
  108. type PermissionObj = {
  109. choices: {
  110. admin: PermissionChoice;
  111. 'no-access': PermissionChoice;
  112. read?: PermissionChoice;
  113. write?: PermissionChoice;
  114. };
  115. help: string;
  116. resource: PermissionResource;
  117. label?: string;
  118. };
  119. export const RELEASE_ADOPTION_STAGES = ['low_adoption', 'adopted', 'replaced'];
  120. // We expose permissions for Sentry Apps in a more resource-centric way.
  121. // All of the API_ACCESS_SCOPES from above should be represented in a more
  122. // User-friendly way here.
  123. export const SENTRY_APP_PERMISSIONS: PermissionObj[] = [
  124. {
  125. resource: 'Project',
  126. help: 'Projects, Tags, Debug Files, and Feedback',
  127. choices: {
  128. 'no-access': {label: 'No Access', scopes: []},
  129. read: {label: 'Read', scopes: ['project:read']},
  130. write: {label: 'Read & Write', scopes: ['project:read', 'project:write']},
  131. admin: {label: 'Admin', scopes: ['project:read', 'project:write', 'project:admin']},
  132. },
  133. },
  134. {
  135. resource: 'Team',
  136. help: 'Teams of members',
  137. choices: {
  138. 'no-access': {label: 'No Access', scopes: []},
  139. read: {label: 'Read', scopes: ['team:read']},
  140. write: {label: 'Read & Write', scopes: ['team:read', 'team:write']},
  141. admin: {label: 'Admin', scopes: ['team:read', 'team:write', 'team:admin']},
  142. },
  143. },
  144. {
  145. resource: 'Release',
  146. help: 'Releases, Commits, and related Files',
  147. choices: {
  148. 'no-access': {label: 'No Access', scopes: []},
  149. admin: {label: 'Admin', scopes: ['project:releases']},
  150. },
  151. },
  152. {
  153. resource: 'Event',
  154. label: 'Issue & Event',
  155. help: 'Issues, Events, and workflow statuses',
  156. choices: {
  157. 'no-access': {label: 'No Access', scopes: []},
  158. read: {label: 'Read', scopes: ['event:read']},
  159. write: {label: 'Read & Write', scopes: ['event:read', 'event:write']},
  160. admin: {label: 'Admin', scopes: ['event:read', 'event:write', 'event:admin']},
  161. },
  162. },
  163. {
  164. resource: 'Organization',
  165. help: 'Manage Organizations, resolve IDs, retrieve Repositories and Commits',
  166. choices: {
  167. 'no-access': {label: 'No Access', scopes: []},
  168. read: {label: 'Read', scopes: ['org:read']},
  169. write: {label: 'Read & Write', scopes: ['org:read', 'org:write']},
  170. admin: {
  171. label: 'Admin',
  172. scopes: ['org:read', 'org:write', 'org:admin', 'org:integrations'],
  173. },
  174. },
  175. },
  176. {
  177. resource: 'Member',
  178. help: 'Manage Members within Teams',
  179. choices: {
  180. 'no-access': {label: 'No Access', scopes: []},
  181. read: {label: 'Read', scopes: ['member:read']},
  182. write: {label: 'Read & Write', scopes: ['member:read', 'member:write']},
  183. admin: {label: 'Admin', scopes: ['member:read', 'member:write', 'member:admin']},
  184. },
  185. },
  186. ];
  187. export const DEFAULT_TOAST_DURATION = 6000;
  188. export const DEFAULT_DEBOUNCE_DURATION = 300;
  189. export const ALL_ENVIRONMENTS_KEY = '__all_environments__';
  190. // Maps a `type: string` -> `url-prefix: string`
  191. export const AVATAR_URL_MAP = {
  192. team: 'team-avatar',
  193. organization: 'organization-avatar',
  194. project: 'project-avatar',
  195. user: 'avatar',
  196. sentryAppColor: 'sentry-app-avatar',
  197. sentryAppSimple: 'sentry-app-avatar',
  198. docIntegration: 'doc-integration-avatar',
  199. };
  200. export const MENU_CLOSE_DELAY = 200;
  201. export const SLOW_TOOLTIP_DELAY = 1000;
  202. export const MAX_PICKABLE_DAYS = 90;
  203. export const DEFAULT_STATS_PERIOD = '14d';
  204. export const DEFAULT_QUERY = 'is:unresolved';
  205. export const DEFAULT_USE_UTC = true;
  206. export const DEFAULT_RELATIVE_PERIODS = {
  207. '1h': t('Last hour'),
  208. '24h': t('Last 24 hours'),
  209. '7d': t('Last 7 days'),
  210. '14d': t('Last 14 days'),
  211. '30d': t('Last 30 days'),
  212. '90d': t('Last 90 days'),
  213. };
  214. export const DEFAULT_RELATIVE_PERIODS_PAGE_FILTER = {
  215. '1h': t('1H'),
  216. '24h': t('24H'),
  217. '7d': t('7D'),
  218. '14d': t('14D'),
  219. '30d': t('30D'),
  220. };
  221. // https://github.com/getsentry/relay/blob/master/relay-common/src/constants.rs
  222. export const DATA_CATEGORY_INFO = {
  223. [DataCategoryExact.ERROR]: {
  224. name: DataCategoryExact.ERROR,
  225. apiName: 'error',
  226. plural: 'errors',
  227. displayName: 'error',
  228. titleName: t('Errors'),
  229. uid: 1,
  230. },
  231. [DataCategoryExact.TRANSACTION]: {
  232. name: DataCategoryExact.TRANSACTION,
  233. apiName: 'transaction',
  234. plural: 'transactions',
  235. displayName: 'transaction',
  236. titleName: t('Transactions'),
  237. uid: 2,
  238. },
  239. [DataCategoryExact.ATTACHMENT]: {
  240. name: DataCategoryExact.ATTACHMENT,
  241. apiName: 'attachment',
  242. plural: 'attachments',
  243. displayName: 'attachment',
  244. titleName: t('Attachments'),
  245. uid: 4,
  246. },
  247. [DataCategoryExact.PROFILE]: {
  248. name: DataCategoryExact.PROFILE,
  249. apiName: 'profile',
  250. plural: 'profiles',
  251. displayName: 'profile',
  252. titleName: t('Profiles'),
  253. uid: 6,
  254. },
  255. [DataCategoryExact.REPLAY]: {
  256. name: DataCategoryExact.REPLAY,
  257. apiName: 'replay',
  258. plural: 'replays',
  259. displayName: 'replay',
  260. titleName: t('Session Replays'),
  261. uid: 7,
  262. },
  263. [DataCategoryExact.TRANSACTION_PROCESSED]: {
  264. name: DataCategoryExact.TRANSACTION_PROCESSED,
  265. apiName: 'transactions',
  266. plural: 'transactions',
  267. displayName: 'transaction',
  268. titleName: t('Transactions'),
  269. uid: 8,
  270. },
  271. [DataCategoryExact.TRANSACTION_INDEXED]: {
  272. name: DataCategoryExact.TRANSACTION_INDEXED,
  273. apiName: 'transactionIndexed',
  274. plural: 'indexed transactions',
  275. displayName: 'indexed transaction',
  276. titleName: t('Indexed Transactions'),
  277. uid: 9,
  278. },
  279. [DataCategoryExact.MONITOR]: {
  280. name: DataCategoryExact.MONITOR,
  281. apiName: 'monitor',
  282. plural: 'monitor check-ins',
  283. displayName: 'monitor check-in',
  284. titleName: t('Monitor Check-Ins'),
  285. uid: 10,
  286. },
  287. [DataCategoryExact.MONITOR_SEAT]: {
  288. name: DataCategoryExact.MONITOR_SEAT,
  289. apiName: 'monitorSeat',
  290. plural: 'monitorSeats',
  291. displayName: 'cron monitors',
  292. titleName: t('Cron Monitors'),
  293. uid: 13,
  294. },
  295. } as const satisfies Record<DataCategoryExact, DataCategoryInfo>;
  296. // Special Search characters
  297. export const NEGATION_OPERATOR = '!';
  298. export const SEARCH_WILDCARD = '*';
  299. // SmartSearchBar settings
  300. export const MAX_AUTOCOMPLETE_RECENT_SEARCHES = 3;
  301. export const MAX_AUTOCOMPLETE_RELEASES = 5;
  302. export const DEFAULT_PER_PAGE = 50;
  303. // Limit query length so paginated response headers don't
  304. // go over HTTP header size limits (4Kb)
  305. export const MAX_QUERY_LENGTH = 400;
  306. // Webpack configures DEPLOY_PREVIEW_CONFIG for deploy preview builds.
  307. export const DEPLOY_PREVIEW_CONFIG = process.env.DEPLOY_PREVIEW_CONFIG as unknown as
  308. | undefined
  309. | {
  310. branch: string;
  311. commitSha: string;
  312. githubOrg: string;
  313. githubRepo: string;
  314. };
  315. // Webpack configures EXPERIMENTAL_SPA.
  316. export const EXPERIMENTAL_SPA = process.env.EXPERIMENTAL_SPA as unknown as
  317. | undefined
  318. | boolean;
  319. // so we don't use filtered values in certain display contexts
  320. // TODO(kmclb): once relay is doing the scrubbing, the masking value will be dynamic,
  321. // so this will have to change
  322. export const FILTER_MASK = '[Filtered]';
  323. // Errors that may occur during the fetching of organization details
  324. export const ORGANIZATION_FETCH_ERROR_TYPES = {
  325. ORG_NOT_FOUND: 'ORG_NOT_FOUND',
  326. ORG_NO_ACCESS: 'ORG_NO_ACCESS',
  327. };
  328. export const CONFIG_DOCS_URL = 'https://develop.sentry.dev/config/';
  329. export const DISCOVER2_DOCS_URL = 'https://docs.sentry.io/product/discover-queries/';
  330. export const IS_ACCEPTANCE_TEST = !!process.env.IS_ACCEPTANCE_TEST;
  331. export const NODE_ENV = process.env.NODE_ENV;
  332. export const SPA_DSN = process.env.SPA_DSN;
  333. export const SENTRY_RELEASE_VERSION = process.env.SENTRY_RELEASE_VERSION;
  334. export const UI_DEV_ENABLE_PROFILING = process.env.UI_DEV_ENABLE_PROFILING;
  335. export const DEFAULT_ERROR_JSON = {
  336. detail: t('Unknown error. Please try again.'),
  337. };