index.tsx 10.0 KB

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