group.tsx 12 KB

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