index.tsx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /* global process */
  2. import {t} from 'sentry/locale';
  3. import {DataCategory, OrgRole, PermissionResource, Scope} from 'sentry/types';
  4. /**
  5. * Common constants here
  6. */
  7. // This is the element id where we render our React application to
  8. export const ROOT_ELEMENT = 'blk_router';
  9. // This is considered the "default" route/view that users should be taken
  10. // to when the application does not have any further context
  11. //
  12. // e.g. loading app root or switching organization
  13. export const DEFAULT_APP_ROUTE = '/organizations/:orgSlug/issues/';
  14. export const API_ACCESS_SCOPES = [
  15. 'project:read',
  16. 'project:write',
  17. 'project:admin',
  18. 'project:releases',
  19. 'team:read',
  20. 'team:write',
  21. 'team:admin',
  22. 'event:read',
  23. 'event:write',
  24. 'event:admin',
  25. 'org:read',
  26. 'org:write',
  27. 'org:admin',
  28. 'org:integrations',
  29. 'member:read',
  30. 'member:write',
  31. 'member:admin',
  32. 'alerts:read',
  33. 'alerts:write',
  34. ] as const;
  35. // Default API scopes when adding a new API token or org API token
  36. export const DEFAULT_API_ACCESS_SCOPES = [
  37. 'event:read',
  38. 'event:admin',
  39. 'project:read',
  40. 'project:releases',
  41. 'org:read',
  42. 'team:read',
  43. 'member:read',
  44. ];
  45. // These should only be used in the case where we cannot obtain roles through
  46. // the members endpoint (primarily in cases where a user is admining a
  47. // different organization they are not a OrganizationMember of ).
  48. export const ORG_ROLES: OrgRole[] = [
  49. {
  50. id: 'member',
  51. name: 'Member',
  52. allowed: true,
  53. desc: 'Members can view and act on events, as well as view most other data within the organization.',
  54. minimumTeamRole: 'contributor',
  55. },
  56. {
  57. id: 'admin',
  58. name: 'Admin',
  59. allowed: true,
  60. 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.",
  61. minimumTeamRole: 'admin',
  62. },
  63. {
  64. id: 'manager',
  65. name: 'Manager',
  66. allowed: true,
  67. desc: 'Gains admin access on all teams as well as the ability to add and remove members.',
  68. minimumTeamRole: 'admin',
  69. },
  70. {
  71. id: 'owner',
  72. name: 'Organization Owner',
  73. allowed: true,
  74. 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.',
  75. minimumTeamRole: 'admin',
  76. },
  77. ];
  78. export type PermissionChoice = {
  79. label: 'No Access' | 'Read' | 'Read & Write' | 'Admin';
  80. scopes: Scope[];
  81. };
  82. type PermissionObj = {
  83. choices: {
  84. admin: PermissionChoice;
  85. 'no-access': PermissionChoice;
  86. read?: PermissionChoice;
  87. write?: PermissionChoice;
  88. };
  89. help: string;
  90. resource: PermissionResource;
  91. label?: string;
  92. };
  93. export const RELEASE_ADOPTION_STAGES = ['low_adoption', 'adopted', 'replaced'];
  94. // We expose permissions for Sentry Apps in a more resource-centric way.
  95. // All of the API_ACCESS_SCOPES from above should be represented in a more
  96. // User-friendly way here.
  97. export const SENTRY_APP_PERMISSIONS: PermissionObj[] = [
  98. {
  99. resource: 'Project',
  100. help: 'Projects, Tags, Debug Files, and Feedback',
  101. choices: {
  102. 'no-access': {label: 'No Access', scopes: []},
  103. read: {label: 'Read', scopes: ['project:read']},
  104. write: {label: 'Read & Write', scopes: ['project:read', 'project:write']},
  105. admin: {label: 'Admin', scopes: ['project:read', 'project:write', 'project:admin']},
  106. },
  107. },
  108. {
  109. resource: 'Team',
  110. help: 'Teams of members',
  111. choices: {
  112. 'no-access': {label: 'No Access', scopes: []},
  113. read: {label: 'Read', scopes: ['team:read']},
  114. write: {label: 'Read & Write', scopes: ['team:read', 'team:write']},
  115. admin: {label: 'Admin', scopes: ['team:read', 'team:write', 'team:admin']},
  116. },
  117. },
  118. {
  119. resource: 'Release',
  120. help: 'Releases, Commits, and related Files',
  121. choices: {
  122. 'no-access': {label: 'No Access', scopes: []},
  123. admin: {label: 'Admin', scopes: ['project:releases']},
  124. },
  125. },
  126. {
  127. resource: 'Event',
  128. label: 'Issue & Event',
  129. help: 'Issues, Events, and workflow statuses',
  130. choices: {
  131. 'no-access': {label: 'No Access', scopes: []},
  132. read: {label: 'Read', scopes: ['event:read']},
  133. write: {label: 'Read & Write', scopes: ['event:read', 'event:write']},
  134. admin: {label: 'Admin', scopes: ['event:read', 'event:write', 'event:admin']},
  135. },
  136. },
  137. {
  138. resource: 'Organization',
  139. help: 'Manage Organizations, resolve IDs, retrieve Repositories and Commits',
  140. choices: {
  141. 'no-access': {label: 'No Access', scopes: []},
  142. read: {label: 'Read', scopes: ['org:read']},
  143. write: {label: 'Read & Write', scopes: ['org:read', 'org:write']},
  144. admin: {label: 'Admin', scopes: ['org:read', 'org:write', 'org:admin']},
  145. },
  146. },
  147. {
  148. resource: 'Member',
  149. help: 'Manage Members within Teams',
  150. choices: {
  151. 'no-access': {label: 'No Access', scopes: []},
  152. read: {label: 'Read', scopes: ['member:read']},
  153. write: {label: 'Read & Write', scopes: ['member:read', 'member:write']},
  154. admin: {label: 'Admin', scopes: ['member:read', 'member:write', 'member:admin']},
  155. },
  156. },
  157. ];
  158. export const DEFAULT_TOAST_DURATION = 6000;
  159. export const DEFAULT_DEBOUNCE_DURATION = 300;
  160. export const ALL_ENVIRONMENTS_KEY = '__all_environments__';
  161. // Maps a `type: string` -> `url-prefix: string`
  162. export const AVATAR_URL_MAP = {
  163. team: 'team-avatar',
  164. organization: 'organization-avatar',
  165. project: 'project-avatar',
  166. user: 'avatar',
  167. sentryAppColor: 'sentry-app-avatar',
  168. sentryAppSimple: 'sentry-app-avatar',
  169. docIntegration: 'doc-integration-avatar',
  170. };
  171. export const MENU_CLOSE_DELAY = 200;
  172. export const MAX_PICKABLE_DAYS = 90;
  173. export const DEFAULT_STATS_PERIOD = '14d';
  174. export const DEFAULT_QUERY = 'is:unresolved';
  175. export const DEFAULT_USE_UTC = true;
  176. export const DEFAULT_RELATIVE_PERIODS = {
  177. '1h': t('Last hour'),
  178. '24h': t('Last 24 hours'),
  179. '7d': t('Last 7 days'),
  180. '14d': t('Last 14 days'),
  181. '30d': t('Last 30 days'),
  182. '90d': t('Last 90 days'),
  183. };
  184. export const DEFAULT_RELATIVE_PERIODS_PAGE_FILTER = {
  185. '1h': t('1H'),
  186. '24h': t('24H'),
  187. '7d': t('7D'),
  188. '14d': t('14D'),
  189. '30d': t('30D'),
  190. };
  191. export const DATA_CATEGORY_NAMES = {
  192. [DataCategory.ERRORS]: t('Errors'),
  193. [DataCategory.TRANSACTIONS]: t('Transactions'),
  194. [DataCategory.ATTACHMENTS]: t('Attachments'),
  195. [DataCategory.TRANSACTIONS_PROCESSED]: t('Processed Transactions'),
  196. };
  197. // Special Search characters
  198. export const NEGATION_OPERATOR = '!';
  199. export const SEARCH_WILDCARD = '*';
  200. // SmartSearchBar settings
  201. export const MAX_AUTOCOMPLETE_RECENT_SEARCHES = 3;
  202. export const MAX_AUTOCOMPLETE_RELEASES = 5;
  203. export const DEFAULT_PER_PAGE = 50;
  204. // Limit query length so paginated response headers don't
  205. // go over HTTP header size limits (4Kb)
  206. export const MAX_QUERY_LENGTH = 400;
  207. // Webpack configures DEPLOY_PREVIEW_CONFIG for deploy preview builds.
  208. export const DEPLOY_PREVIEW_CONFIG = process.env.DEPLOY_PREVIEW_CONFIG as unknown as
  209. | undefined
  210. | {
  211. branch: string;
  212. commitSha: string;
  213. githubOrg: string;
  214. githubRepo: string;
  215. };
  216. // Webpack configures EXPERIMENTAL_SPA.
  217. export const EXPERIMENTAL_SPA = process.env.EXPERIMENTAL_SPA as unknown as
  218. | undefined
  219. | boolean;
  220. // so we don't use filtered values in certain display contexts
  221. // TODO(kmclb): once relay is doing the scrubbing, the masking value will be dynamic,
  222. // so this will have to change
  223. export const FILTER_MASK = '[Filtered]';
  224. // Errors that may occur during the fetching of organization details
  225. export const ORGANIZATION_FETCH_ERROR_TYPES = {
  226. ORG_NOT_FOUND: 'ORG_NOT_FOUND',
  227. ORG_NO_ACCESS: 'ORG_NO_ACCESS',
  228. };
  229. export const CONFIG_DOCS_URL = 'https://develop.sentry.dev/config/';
  230. export const DISCOVER2_DOCS_URL = 'https://docs.sentry.io/product/discover-queries/';
  231. export const IS_ACCEPTANCE_TEST = !!process.env.IS_ACCEPTANCE_TEST;
  232. export const NODE_ENV = process.env.NODE_ENV;
  233. export const SPA_DSN = process.env.SPA_DSN;
  234. export const SENTRY_RELEASE_VERSION = process.env.SENTRY_RELEASE_VERSION;
  235. export const DEFAULT_ERROR_JSON = {
  236. detail: t('Unknown error. Please try again.'),
  237. };