organization.tsx 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. import type {Project} from 'sentry/types/project';
  2. import type {AggregationOutputType} from 'sentry/utils/discover/fields';
  3. import type {DiscoverDatasets, SavedQueryDatasets} from 'sentry/utils/discover/types';
  4. import type {Actor, Avatar, ObjectStatus, Scope} from './core';
  5. import type {OrgExperiments} from './experiments';
  6. import type {ExternalTeam} from './integrations';
  7. import type {OnboardingTaskStatus} from './onboarding';
  8. import type {Relay} from './relay';
  9. import type {User} from './user';
  10. /**
  11. * Organization summaries are sent when you request a list of all organizations
  12. */
  13. export interface OrganizationSummary {
  14. aiSuggestedSolution: boolean;
  15. avatar: Avatar;
  16. codecovAccess: boolean;
  17. dateCreated: string;
  18. features: string[];
  19. githubNudgeInvite: boolean;
  20. githubOpenPRBot: boolean;
  21. githubPRBot: boolean;
  22. id: string;
  23. isEarlyAdopter: boolean;
  24. issueAlertsThreadFlag: boolean;
  25. links: {
  26. organizationUrl: string;
  27. regionUrl: string;
  28. };
  29. metricAlertsThreadFlag: boolean;
  30. name: string;
  31. require2FA: boolean;
  32. slug: string;
  33. status: {
  34. id: ObjectStatus;
  35. name: string;
  36. };
  37. }
  38. /**
  39. * Detailed organization (e.g. when requesting details for a single org)
  40. */
  41. export interface Organization extends OrganizationSummary {
  42. access: Scope[];
  43. aggregatedDataConsent: boolean;
  44. alertsMemberWrite: boolean;
  45. allowJoinRequests: boolean;
  46. allowSharedIssues: boolean;
  47. attachmentsRole: string;
  48. availableRoles: {id: string; name: string}[]; // Deprecated, use orgRoleList
  49. dataScrubber: boolean;
  50. dataScrubberDefaults: boolean;
  51. debugFilesRole: string;
  52. defaultRole: string;
  53. enhancedPrivacy: boolean;
  54. eventsMemberAdmin: boolean;
  55. experiments: Partial<OrgExperiments>;
  56. genAIConsent: boolean;
  57. isDefault: boolean;
  58. isDynamicallySampled: boolean;
  59. onboardingTasks: OnboardingTaskStatus[];
  60. openMembership: boolean;
  61. orgRoleList: OrgRole[];
  62. pendingAccessRequests: number;
  63. quota: {
  64. accountLimit: number | null;
  65. maxRate: number | null;
  66. maxRateInterval: number | null;
  67. projectLimit: number | null;
  68. };
  69. relayPiiConfig: string | null;
  70. safeFields: string[];
  71. scrapeJavaScript: boolean;
  72. scrubIPAddresses: boolean;
  73. sensitiveFields: string[];
  74. storeCrashReports: number;
  75. teamRoleList: TeamRole[];
  76. trustedRelays: Relay[];
  77. desiredSampleRate?: number | null;
  78. effectiveSampleRate?: number | null;
  79. orgRole?: string;
  80. planSampleRate?: number | null;
  81. }
  82. export interface Team {
  83. access: Scope[];
  84. avatar: Avatar;
  85. externalTeams: ExternalTeam[];
  86. flags: {
  87. 'idp:provisioned': boolean;
  88. };
  89. hasAccess: boolean;
  90. id: string;
  91. isMember: boolean;
  92. isPending: boolean;
  93. memberCount: number;
  94. name: string;
  95. slug: string;
  96. teamRole: string | null;
  97. }
  98. export interface DetailedTeam extends Team {
  99. projects: Project[];
  100. }
  101. export interface BaseRole {
  102. desc: string;
  103. id: string;
  104. name: string;
  105. isAllowed?: boolean;
  106. isRetired?: boolean;
  107. isTeamRolesAllowed?: boolean;
  108. }
  109. export interface OrgRole extends BaseRole {
  110. minimumTeamRole: string;
  111. isGlobal?: boolean;
  112. is_global?: boolean; // Deprecated: use isGlobal
  113. }
  114. export interface TeamRole extends BaseRole {
  115. isMinimumRoleFor: string;
  116. }
  117. /**
  118. * Returned from /organizations/org/users/
  119. */
  120. export interface Member {
  121. dateCreated: string;
  122. email: string;
  123. expired: boolean;
  124. flags: {
  125. 'idp:provisioned': boolean;
  126. 'idp:role-restricted': boolean;
  127. 'member-limit:restricted': boolean;
  128. 'partnership:restricted': boolean;
  129. 'sso:invalid': boolean;
  130. 'sso:linked': boolean;
  131. };
  132. id: string;
  133. inviteStatus: 'approved' | 'requested_to_be_invited' | 'requested_to_join';
  134. invite_link: string | null;
  135. inviterName: string | null;
  136. isOnlyOwner: boolean;
  137. name: string;
  138. orgRole: OrgRole['id'];
  139. orgRoleList: OrgRole[];
  140. pending: boolean | undefined;
  141. projects: string[];
  142. /**
  143. * @deprecated use orgRole
  144. */
  145. role: OrgRole['id'];
  146. roleName: string;
  147. /**
  148. * @deprecated use orgRoleList
  149. */
  150. roles: OrgRole[];
  151. teamRoleList: TeamRole[];
  152. // TODO: Move to global store
  153. teamRoles: {
  154. role: string | null;
  155. teamSlug: string;
  156. }[];
  157. /**
  158. * @deprecated use teamRoles
  159. */
  160. teams: string[];
  161. // # Deprecated, use teamRoles
  162. /**
  163. * User may be null when the member represents an invited member
  164. */
  165. user: User | null;
  166. }
  167. /**
  168. * Returned from TeamMembersEndpoint
  169. */
  170. export interface TeamMember extends Member {
  171. teamRole?: string | null;
  172. teamSlug?: string;
  173. }
  174. /**
  175. * Users that exist in CommitAuthors but are not members of the organization.
  176. * These users commit to repos installed for the organization.
  177. */
  178. export interface MissingMember {
  179. commitCount: number;
  180. email: string;
  181. // The user's ID in the repository provider (e.g. Github username)
  182. externalId: string;
  183. }
  184. /**
  185. * Minimal organization shape used on shared issue views.
  186. */
  187. export type SharedViewOrganization = {
  188. slug: string;
  189. features?: Array<string>;
  190. id?: string;
  191. };
  192. export type AuditLog = {
  193. actor: User;
  194. data: any;
  195. dateCreated: string;
  196. event: string;
  197. id: string;
  198. ipAddress: string;
  199. note: string;
  200. targetObject: number;
  201. targetUser: Actor | null;
  202. };
  203. export type AccessRequest = {
  204. id: string;
  205. member: Member;
  206. team: Team;
  207. requester?: Partial<{
  208. email: string;
  209. name: string;
  210. username: string;
  211. }>;
  212. };
  213. /**
  214. * Discover queries and result sets.
  215. */
  216. export type SavedQueryVersions = 1 | 2;
  217. export interface NewQuery {
  218. fields: Readonly<string[]>;
  219. name: string;
  220. version: SavedQueryVersions;
  221. createdBy?: User;
  222. dataset?: DiscoverDatasets;
  223. display?: string;
  224. end?: string | Date;
  225. environment?: Readonly<string[]>;
  226. expired?: boolean;
  227. id?: string;
  228. interval?: string;
  229. orderby?: string;
  230. projects?: Readonly<number[]>;
  231. query?: string;
  232. queryDataset?: SavedQueryDatasets;
  233. range?: string;
  234. start?: string | Date;
  235. teams?: Readonly<('myteams' | number)[]>;
  236. topEvents?: string;
  237. utc?: boolean | string;
  238. widths?: Readonly<string[]>;
  239. yAxis?: string[];
  240. }
  241. export interface SavedQuery extends NewQuery {
  242. dateCreated: string;
  243. dateUpdated: string;
  244. id: string;
  245. }
  246. export type SavedQueryState = {
  247. hasError: boolean;
  248. isLoading: boolean;
  249. savedQueries: SavedQuery[];
  250. };
  251. export type EventsStatsData = [number, {count: number; comparisonCount?: number}[]][];
  252. // API response format for a single series
  253. export type EventsStats = {
  254. data: EventsStatsData;
  255. end?: number;
  256. isExtrapolatedData?: boolean;
  257. isMetricsData?: boolean;
  258. isMetricsExtractedData?: boolean;
  259. meta?: {
  260. fields: Record<string, AggregationOutputType>;
  261. isMetricsData: boolean;
  262. tips: {columns?: string; query?: string};
  263. units: Record<string, string>;
  264. isMetricsExtractedData?: boolean;
  265. };
  266. order?: number;
  267. start?: number;
  268. totals?: {count: number};
  269. };
  270. // API response format for multiple series
  271. export type MultiSeriesEventsStats = {
  272. [seriesName: string]: EventsStats;
  273. };
  274. export type EventsStatsSeries<F extends string> = {
  275. data: {
  276. axis: F;
  277. values: number[];
  278. label?: string;
  279. }[];
  280. meta: {
  281. dataset: string;
  282. end: number;
  283. start: number;
  284. };
  285. timestamps: number[];
  286. };
  287. /**
  288. * Session API types.
  289. */
  290. // Base type for series style API response
  291. export interface SeriesApi {
  292. groups: {
  293. by: Record<string, string | number>;
  294. series: Record<string, number[]>;
  295. totals: Record<string, number>;
  296. }[];
  297. intervals: string[];
  298. }
  299. export interface SessionApiResponse extends SeriesApi {
  300. end: string;
  301. query: string;
  302. start: string;
  303. }
  304. export enum SessionFieldWithOperation {
  305. SESSIONS = 'sum(session)',
  306. USERS = 'count_unique(user)',
  307. DURATION = 'p50(session.duration)',
  308. CRASH_FREE_RATE_USERS = 'crash_free_rate(user)',
  309. CRASH_FREE_RATE_SESSIONS = 'crash_free_rate(session)',
  310. }
  311. export enum SessionStatus {
  312. HEALTHY = 'healthy',
  313. ABNORMAL = 'abnormal',
  314. ERRORED = 'errored',
  315. CRASHED = 'crashed',
  316. }