index.tsx 8.3 KB

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