group.tsx 12 KB

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