group.tsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. import {PlatformKey} from 'sentry/data/platformCategories';
  2. import {Actor, TimeseriesValue} from './core';
  3. import {Event, EventMetadata, EventOrGroupType, Level} from './event';
  4. import {Commit, PullRequest} from './integrations';
  5. import {Team} from './organization';
  6. import {Project} from './project';
  7. import {Release} from './release';
  8. import {AvatarUser, User} from './user';
  9. export type EntryData = Record<string, any | Array<any>>;
  10. /**
  11. * Saved issues searches
  12. */
  13. export type RecentSearch = {
  14. dateCreated: string;
  15. id: string;
  16. lastSeen: string;
  17. organizationId: string;
  18. query: string;
  19. type: SavedSearchType;
  20. };
  21. // XXX: Deprecated Sentry 9 attributes are not included here.
  22. export type SavedSearch = {
  23. dateCreated: string;
  24. id: string;
  25. isGlobal: boolean;
  26. isOrgCustom: boolean;
  27. isPinned: boolean;
  28. name: string;
  29. query: string;
  30. sort: string;
  31. type: SavedSearchType;
  32. };
  33. export enum SavedSearchType {
  34. ISSUE = 0,
  35. EVENT = 1,
  36. }
  37. // endpoint: /api/0/issues/:issueId/attachments/?limit=50
  38. export type IssueAttachment = {
  39. dateCreated: string;
  40. event_id: string;
  41. headers: Object;
  42. id: string;
  43. mimetype: string;
  44. name: string;
  45. sha1: string;
  46. size: number;
  47. type: string;
  48. };
  49. // endpoint: /api/0/projects/:orgSlug/:projSlug/events/:eventId/attachments/
  50. export type EventAttachment = Omit<IssueAttachment, 'event_id'>;
  51. /**
  52. * Issue Tags
  53. */
  54. export type Tag = {
  55. key: string;
  56. name: string;
  57. isInput?: boolean;
  58. /**
  59. * How many values should be suggested in autocomplete.
  60. * Overrides SmartSearchBar's `maxSearchItems` prop.
  61. */
  62. maxSuggestedValues?: number;
  63. predefined?: boolean;
  64. totalValues?: number;
  65. values?: string[];
  66. };
  67. export type TagCollection = Record<string, Tag>;
  68. export type TagValue = {
  69. count: number;
  70. firstSeen: string;
  71. key: string;
  72. lastSeen: string;
  73. name: string;
  74. value: string;
  75. email?: string;
  76. identifier?: string;
  77. ipAddress?: string;
  78. query?: string;
  79. username?: string;
  80. } & AvatarUser;
  81. type Topvalue = {
  82. count: number;
  83. firstSeen: string;
  84. key: string;
  85. lastSeen: string;
  86. name: string;
  87. value: string;
  88. // Might not actually exist.
  89. query?: string;
  90. };
  91. export type TagWithTopValues = {
  92. key: string;
  93. name: string;
  94. topValues: Array<Topvalue>;
  95. totalValues: number;
  96. uniqueValues: number;
  97. canDelete?: boolean;
  98. };
  99. /**
  100. * Inbox, issue owners and Activity
  101. */
  102. export type InboxReasonDetails = {
  103. count?: number | null;
  104. until?: string | null;
  105. user_count?: number | null;
  106. user_window?: number | null;
  107. window?: number | null;
  108. };
  109. export type InboxDetails = {
  110. reason_details: InboxReasonDetails;
  111. date_added?: string;
  112. reason?: number;
  113. };
  114. export type SuggestedOwnerReason = 'suspectCommit' | 'ownershipRule';
  115. // Received from the backend to denote suggested owners of an issue
  116. export type SuggestedOwner = {
  117. date_added: string;
  118. owner: string;
  119. type: SuggestedOwnerReason;
  120. };
  121. export type IssueOwnership = {
  122. autoAssignment: boolean;
  123. dateCreated: string;
  124. fallthrough: boolean;
  125. isActive: boolean;
  126. lastUpdated: string;
  127. raw: string;
  128. };
  129. export enum GroupActivityType {
  130. NOTE = 'note',
  131. SET_RESOLVED = 'set_resolved',
  132. SET_RESOLVED_BY_AGE = 'set_resolved_by_age',
  133. SET_RESOLVED_IN_RELEASE = 'set_resolved_in_release',
  134. SET_RESOLVED_IN_COMMIT = 'set_resolved_in_commit',
  135. SET_RESOLVED_IN_PULL_REQUEST = 'set_resolved_in_pull_request',
  136. SET_UNRESOLVED = 'set_unresolved',
  137. SET_IGNORED = 'set_ignored',
  138. SET_PUBLIC = 'set_public',
  139. SET_PRIVATE = 'set_private',
  140. SET_REGRESSION = 'set_regression',
  141. CREATE_ISSUE = 'create_issue',
  142. UNMERGE_SOURCE = 'unmerge_source',
  143. UNMERGE_DESTINATION = 'unmerge_destination',
  144. FIRST_SEEN = 'first_seen',
  145. ASSIGNED = 'assigned',
  146. UNASSIGNED = 'unassigned',
  147. MERGE = 'merge',
  148. REPROCESS = 'reprocess',
  149. MARK_REVIEWED = 'mark_reviewed',
  150. }
  151. type GroupActivityBase = {
  152. dateCreated: string;
  153. id: string;
  154. project: Project;
  155. assignee?: string;
  156. issue?: Group;
  157. user?: null | User;
  158. };
  159. type GroupActivityNote = GroupActivityBase & {
  160. data: {
  161. text: string;
  162. };
  163. type: GroupActivityType.NOTE;
  164. };
  165. type GroupActivitySetResolved = GroupActivityBase & {
  166. data: Record<string, any>;
  167. type: GroupActivityType.SET_RESOLVED;
  168. };
  169. type GroupActivitySetUnresolved = GroupActivityBase & {
  170. data: Record<string, any>;
  171. type: GroupActivityType.SET_UNRESOLVED;
  172. };
  173. type GroupActivitySetPublic = GroupActivityBase & {
  174. data: Record<string, any>;
  175. type: GroupActivityType.SET_PUBLIC;
  176. };
  177. type GroupActivitySetPrivate = GroupActivityBase & {
  178. data: Record<string, any>;
  179. type: GroupActivityType.SET_PRIVATE;
  180. };
  181. type GroupActivitySetByAge = GroupActivityBase & {
  182. data: Record<string, any>;
  183. type: GroupActivityType.SET_RESOLVED_BY_AGE;
  184. };
  185. type GroupActivityUnassigned = GroupActivityBase & {
  186. data: Record<string, any>;
  187. type: GroupActivityType.UNASSIGNED;
  188. };
  189. type GroupActivityFirstSeen = GroupActivityBase & {
  190. data: Record<string, any>;
  191. type: GroupActivityType.FIRST_SEEN;
  192. };
  193. type GroupActivityMarkReviewed = GroupActivityBase & {
  194. data: Record<string, any>;
  195. type: GroupActivityType.MARK_REVIEWED;
  196. };
  197. type GroupActivityRegression = GroupActivityBase & {
  198. data: {
  199. version?: string;
  200. };
  201. type: GroupActivityType.SET_REGRESSION;
  202. };
  203. export type GroupActivitySetByResolvedInRelease = GroupActivityBase & {
  204. data: {
  205. current_release_version?: string;
  206. version?: string;
  207. };
  208. type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
  209. };
  210. type GroupActivitySetByResolvedInCommit = GroupActivityBase & {
  211. data: {
  212. commit: Commit;
  213. };
  214. type: GroupActivityType.SET_RESOLVED_IN_COMMIT;
  215. };
  216. type GroupActivitySetByResolvedInPullRequest = GroupActivityBase & {
  217. data: {
  218. pullRequest: PullRequest;
  219. };
  220. type: GroupActivityType.SET_RESOLVED_IN_PULL_REQUEST;
  221. };
  222. export type GroupActivitySetIgnored = GroupActivityBase & {
  223. data: {
  224. ignoreCount?: number;
  225. ignoreDuration?: number;
  226. ignoreUntil?: string;
  227. ignoreUserCount?: number;
  228. ignoreUserWindow?: number;
  229. ignoreWindow?: number;
  230. };
  231. type: GroupActivityType.SET_IGNORED;
  232. };
  233. export type GroupActivityReprocess = GroupActivityBase & {
  234. data: {
  235. eventCount: number;
  236. newGroupId: number;
  237. oldGroupId: number;
  238. };
  239. type: GroupActivityType.REPROCESS;
  240. };
  241. type GroupActivityUnmergeDestination = GroupActivityBase & {
  242. data: {
  243. fingerprints: Array<string>;
  244. source?: {
  245. id: string;
  246. shortId: string;
  247. };
  248. };
  249. type: GroupActivityType.UNMERGE_DESTINATION;
  250. };
  251. type GroupActivityUnmergeSource = GroupActivityBase & {
  252. data: {
  253. fingerprints: Array<string>;
  254. destination?: {
  255. id: string;
  256. shortId: string;
  257. };
  258. };
  259. type: GroupActivityType.UNMERGE_SOURCE;
  260. };
  261. type GroupActivityMerge = GroupActivityBase & {
  262. data: {
  263. issues: Array<any>;
  264. };
  265. type: GroupActivityType.MERGE;
  266. };
  267. export type GroupActivityAssigned = GroupActivityBase & {
  268. data: {
  269. assignee: string;
  270. assigneeType: string;
  271. user: Team | User;
  272. };
  273. type: GroupActivityType.ASSIGNED;
  274. };
  275. export type GroupActivityCreateIssue = GroupActivityBase & {
  276. data: {
  277. location: string;
  278. provider: string;
  279. title: string;
  280. };
  281. type: GroupActivityType.CREATE_ISSUE;
  282. };
  283. export type GroupActivity =
  284. | GroupActivityNote
  285. | GroupActivitySetResolved
  286. | GroupActivitySetUnresolved
  287. | GroupActivitySetIgnored
  288. | GroupActivitySetByAge
  289. | GroupActivitySetByResolvedInRelease
  290. | GroupActivitySetByResolvedInCommit
  291. | GroupActivitySetByResolvedInPullRequest
  292. | GroupActivityFirstSeen
  293. | GroupActivityMerge
  294. | GroupActivityReprocess
  295. | GroupActivityUnassigned
  296. | GroupActivityMarkReviewed
  297. | GroupActivityUnmergeDestination
  298. | GroupActivitySetPublic
  299. | GroupActivitySetPrivate
  300. | GroupActivityRegression
  301. | GroupActivityUnmergeSource
  302. | GroupActivityAssigned
  303. | GroupActivityCreateIssue;
  304. export type Activity = GroupActivity;
  305. type GroupFiltered = {
  306. count: string;
  307. firstSeen: string;
  308. lastSeen: string;
  309. stats: Record<string, TimeseriesValue[]>;
  310. userCount: number;
  311. };
  312. export type GroupStats = GroupFiltered & {
  313. filtered: GroupFiltered | null;
  314. id: string;
  315. lifetime?: GroupFiltered;
  316. sessionCount?: string | null;
  317. };
  318. export type BaseGroupStatusReprocessing = {
  319. status: 'reprocessing';
  320. statusDetails: {
  321. info: {
  322. dateCreated: string;
  323. totalEvents: number;
  324. } | null;
  325. pendingEvents: number;
  326. };
  327. };
  328. /**
  329. * Issue Resolution
  330. */
  331. export enum ResolutionStatus {
  332. RESOLVED = 'resolved',
  333. UNRESOLVED = 'unresolved',
  334. IGNORED = 'ignored',
  335. }
  336. export type ResolutionStatusDetails = {
  337. actor?: AvatarUser;
  338. autoResolved?: boolean;
  339. ignoreCount?: number;
  340. // Sent in requests. ignoreUntil is used in responses.
  341. ignoreDuration?: number;
  342. ignoreUntil?: string;
  343. ignoreUserCount?: number;
  344. ignoreUserWindow?: number;
  345. ignoreWindow?: number;
  346. inCommit?: Commit;
  347. inNextRelease?: boolean;
  348. inRelease?: string;
  349. };
  350. export type UpdateResolutionStatus = {
  351. status: ResolutionStatus;
  352. statusDetails?: ResolutionStatusDetails;
  353. };
  354. type BaseGroupStatusResolution = {
  355. status: ResolutionStatus;
  356. statusDetails: ResolutionStatusDetails;
  357. };
  358. export type GroupRelease = {
  359. firstRelease: Release;
  360. lastRelease: Release;
  361. };
  362. // TODO(ts): incomplete
  363. export type BaseGroup = {
  364. activity: GroupActivity[];
  365. annotations: string[];
  366. assignedTo: Actor;
  367. culprit: string;
  368. firstSeen: string;
  369. hasSeen: boolean;
  370. id: string;
  371. isBookmarked: boolean;
  372. isPublic: boolean;
  373. isSubscribed: boolean;
  374. isUnhandled: boolean;
  375. lastSeen: string;
  376. latestEvent: Event;
  377. level: Level;
  378. logger: string;
  379. metadata: EventMetadata;
  380. numComments: number;
  381. participants: User[];
  382. permalink: string;
  383. platform: PlatformKey;
  384. pluginActions: any[]; // TODO(ts)
  385. pluginContexts: any[]; // TODO(ts)
  386. pluginIssues: any[]; // TODO(ts)
  387. project: Project;
  388. seenBy: User[];
  389. shareId: string;
  390. shortId: string;
  391. status: string;
  392. subscriptionDetails: {disabled?: boolean; reason?: string} | null;
  393. tags: Pick<Tag, 'key' | 'name' | 'totalValues'>[];
  394. title: string;
  395. type: EventOrGroupType;
  396. userReportCount: number;
  397. inbox?: InboxDetails | null | false;
  398. owners?: SuggestedOwner[] | null;
  399. } & GroupRelease;
  400. export type GroupReprocessing = BaseGroup & GroupStats & BaseGroupStatusReprocessing;
  401. export type GroupResolution = BaseGroup & GroupStats & BaseGroupStatusResolution;
  402. export type Group = GroupResolution | GroupReprocessing;
  403. export type GroupCollapseRelease = Omit<Group, keyof GroupRelease> &
  404. Partial<GroupRelease>;
  405. export type GroupTombstone = {
  406. actor: AvatarUser;
  407. culprit: string;
  408. id: string;
  409. level: Level;
  410. metadata: EventMetadata;
  411. title: string;
  412. };
  413. export type ProcessingIssueItem = {
  414. checksum: string;
  415. data: {
  416. // TODO(ts) This type is likely incomplete, but this is what
  417. // project processing issues settings uses.
  418. _scope: string;
  419. image_arch: string;
  420. image_path: string;
  421. image_uuid: string;
  422. };
  423. id: string;
  424. lastSeen: string;
  425. numEvents: number;
  426. type: string;
  427. };
  428. export type ProcessingIssue = {
  429. hasIssues: boolean;
  430. hasMoreResolveableIssues: boolean;
  431. issuesProcessing: number;
  432. lastSeen: string;
  433. numIssues: number;
  434. project: string;
  435. resolveableIssues: number;
  436. signedLink: string;
  437. issues?: ProcessingIssueItem[];
  438. };
  439. /**
  440. * Datascrubbing
  441. */
  442. export type Meta = {
  443. chunks: Array<ChunkType>;
  444. err: Array<MetaError>;
  445. len: number;
  446. rem: Array<MetaRemark>;
  447. };
  448. export type MetaError = string | [string, any];
  449. export type MetaRemark = Array<string | number>;
  450. export type ChunkType = {
  451. rule_id: string | number;
  452. text: string;
  453. type: string;
  454. remark?: string | number;
  455. };
  456. /**
  457. * User Feedback
  458. */
  459. export type UserReport = {
  460. comments: string;
  461. dateCreated: string;
  462. email: string;
  463. event: {eventID: string; id: string};
  464. eventID: string;
  465. id: string;
  466. issue: Group;
  467. name: string;
  468. user: User;
  469. };
  470. export type KeyValueListData = {
  471. key: string;
  472. subject: string;
  473. meta?: Meta;
  474. subjectDataTestId?: string;
  475. subjectIcon?: React.ReactNode;
  476. value?: React.ReactNode;
  477. }[];
  478. // Response from ShortIdLookupEndpoint
  479. // /organizations/${orgId}/shortids/${query}/
  480. export type ShortIdResponse = {
  481. group: Group;
  482. groupId: string;
  483. organizationSlug: string;
  484. projectSlug: string;
  485. shortId: string;
  486. };
  487. /**
  488. * Note used in Group Activity and Alerts for users to comment
  489. */
  490. export type Note = {
  491. /**
  492. * Array of [id, display string] tuples used for @-mentions
  493. */
  494. mentions: [string, string][];
  495. /**
  496. * Note contents (markdown allowed)
  497. */
  498. text: string;
  499. };