index.tsx 11 KB

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