group.tsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. import type {PlatformKey} from 'sentry/data/platformCategories';
  2. import {FieldValueKind} from 'sentry/views/eventsV2/table/types';
  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?: FieldValueKind;
  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. dateCreated: string;
  127. fallthrough: boolean;
  128. isActive: boolean;
  129. lastUpdated: string;
  130. raw: string;
  131. };
  132. export enum GroupActivityType {
  133. NOTE = 'note',
  134. SET_RESOLVED = 'set_resolved',
  135. SET_RESOLVED_BY_AGE = 'set_resolved_by_age',
  136. SET_RESOLVED_IN_RELEASE = 'set_resolved_in_release',
  137. SET_RESOLVED_IN_COMMIT = 'set_resolved_in_commit',
  138. SET_RESOLVED_IN_PULL_REQUEST = 'set_resolved_in_pull_request',
  139. SET_UNRESOLVED = 'set_unresolved',
  140. SET_IGNORED = 'set_ignored',
  141. SET_PUBLIC = 'set_public',
  142. SET_PRIVATE = 'set_private',
  143. SET_REGRESSION = 'set_regression',
  144. CREATE_ISSUE = 'create_issue',
  145. UNMERGE_SOURCE = 'unmerge_source',
  146. UNMERGE_DESTINATION = 'unmerge_destination',
  147. FIRST_SEEN = 'first_seen',
  148. ASSIGNED = 'assigned',
  149. UNASSIGNED = 'unassigned',
  150. MERGE = 'merge',
  151. REPROCESS = 'reprocess',
  152. MARK_REVIEWED = 'mark_reviewed',
  153. }
  154. type GroupActivityBase = {
  155. dateCreated: string;
  156. id: string;
  157. project: Project;
  158. assignee?: string;
  159. issue?: Group;
  160. user?: null | User;
  161. };
  162. type GroupActivityNote = GroupActivityBase & {
  163. data: {
  164. text: string;
  165. };
  166. type: GroupActivityType.NOTE;
  167. };
  168. type GroupActivitySetResolved = GroupActivityBase & {
  169. data: Record<string, any>;
  170. type: GroupActivityType.SET_RESOLVED;
  171. };
  172. type GroupActivitySetUnresolved = GroupActivityBase & {
  173. data: Record<string, any>;
  174. type: GroupActivityType.SET_UNRESOLVED;
  175. };
  176. type GroupActivitySetPublic = GroupActivityBase & {
  177. data: Record<string, any>;
  178. type: GroupActivityType.SET_PUBLIC;
  179. };
  180. type GroupActivitySetPrivate = GroupActivityBase & {
  181. data: Record<string, any>;
  182. type: GroupActivityType.SET_PRIVATE;
  183. };
  184. type GroupActivitySetByAge = GroupActivityBase & {
  185. data: Record<string, any>;
  186. type: GroupActivityType.SET_RESOLVED_BY_AGE;
  187. };
  188. type GroupActivityUnassigned = GroupActivityBase & {
  189. data: Record<string, any>;
  190. type: GroupActivityType.UNASSIGNED;
  191. };
  192. type GroupActivityFirstSeen = GroupActivityBase & {
  193. data: Record<string, any>;
  194. type: GroupActivityType.FIRST_SEEN;
  195. };
  196. type GroupActivityMarkReviewed = GroupActivityBase & {
  197. data: Record<string, any>;
  198. type: GroupActivityType.MARK_REVIEWED;
  199. };
  200. type GroupActivityRegression = GroupActivityBase & {
  201. data: {
  202. version?: string;
  203. };
  204. type: GroupActivityType.SET_REGRESSION;
  205. };
  206. export type GroupActivitySetByResolvedInRelease = GroupActivityBase & {
  207. data: {
  208. current_release_version?: string;
  209. version?: string;
  210. };
  211. type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
  212. };
  213. type GroupActivitySetByResolvedInCommit = GroupActivityBase & {
  214. data: {
  215. commit: Commit;
  216. };
  217. type: GroupActivityType.SET_RESOLVED_IN_COMMIT;
  218. };
  219. type GroupActivitySetByResolvedInPullRequest = GroupActivityBase & {
  220. data: {
  221. pullRequest: PullRequest;
  222. };
  223. type: GroupActivityType.SET_RESOLVED_IN_PULL_REQUEST;
  224. };
  225. export type GroupActivitySetIgnored = GroupActivityBase & {
  226. data: {
  227. ignoreCount?: number;
  228. ignoreDuration?: number;
  229. ignoreUntil?: string;
  230. ignoreUserCount?: number;
  231. ignoreUserWindow?: number;
  232. ignoreWindow?: number;
  233. };
  234. type: GroupActivityType.SET_IGNORED;
  235. };
  236. export type GroupActivityReprocess = GroupActivityBase & {
  237. data: {
  238. eventCount: number;
  239. newGroupId: number;
  240. oldGroupId: number;
  241. };
  242. type: GroupActivityType.REPROCESS;
  243. };
  244. type GroupActivityUnmergeDestination = GroupActivityBase & {
  245. data: {
  246. fingerprints: Array<string>;
  247. source?: {
  248. id: string;
  249. shortId: string;
  250. };
  251. };
  252. type: GroupActivityType.UNMERGE_DESTINATION;
  253. };
  254. type GroupActivityUnmergeSource = GroupActivityBase & {
  255. data: {
  256. fingerprints: Array<string>;
  257. destination?: {
  258. id: string;
  259. shortId: string;
  260. };
  261. };
  262. type: GroupActivityType.UNMERGE_SOURCE;
  263. };
  264. type GroupActivityMerge = GroupActivityBase & {
  265. data: {
  266. issues: Array<any>;
  267. };
  268. type: GroupActivityType.MERGE;
  269. };
  270. export type GroupActivityAssigned = GroupActivityBase & {
  271. data: {
  272. assignee: string;
  273. assigneeType: string;
  274. user: Team | User;
  275. assigneeEmail?: string;
  276. };
  277. type: GroupActivityType.ASSIGNED;
  278. };
  279. export type GroupActivityCreateIssue = GroupActivityBase & {
  280. data: {
  281. location: string;
  282. provider: string;
  283. title: string;
  284. };
  285. type: GroupActivityType.CREATE_ISSUE;
  286. };
  287. export type GroupActivity =
  288. | GroupActivityNote
  289. | GroupActivitySetResolved
  290. | GroupActivitySetUnresolved
  291. | GroupActivitySetIgnored
  292. | GroupActivitySetByAge
  293. | GroupActivitySetByResolvedInRelease
  294. | GroupActivitySetByResolvedInCommit
  295. | GroupActivitySetByResolvedInPullRequest
  296. | GroupActivityFirstSeen
  297. | GroupActivityMerge
  298. | GroupActivityReprocess
  299. | GroupActivityUnassigned
  300. | GroupActivityMarkReviewed
  301. | GroupActivityUnmergeDestination
  302. | GroupActivitySetPublic
  303. | GroupActivitySetPrivate
  304. | GroupActivityRegression
  305. | GroupActivityUnmergeSource
  306. | GroupActivityAssigned
  307. | GroupActivityCreateIssue;
  308. export type Activity = GroupActivity;
  309. type GroupFiltered = {
  310. count: string;
  311. firstSeen: string;
  312. lastSeen: string;
  313. stats: Record<string, TimeseriesValue[]>;
  314. userCount: number;
  315. };
  316. export type GroupStats = GroupFiltered & {
  317. filtered: GroupFiltered | null;
  318. id: string;
  319. lifetime?: GroupFiltered;
  320. sessionCount?: string | null;
  321. };
  322. export type BaseGroupStatusReprocessing = {
  323. status: 'reprocessing';
  324. statusDetails: {
  325. info: {
  326. dateCreated: string;
  327. totalEvents: number;
  328. } | null;
  329. pendingEvents: number;
  330. };
  331. };
  332. /**
  333. * Issue Resolution
  334. */
  335. export enum ResolutionStatus {
  336. RESOLVED = 'resolved',
  337. UNRESOLVED = 'unresolved',
  338. IGNORED = 'ignored',
  339. }
  340. export type ResolutionStatusDetails = {
  341. actor?: AvatarUser;
  342. autoResolved?: boolean;
  343. ignoreCount?: number;
  344. // Sent in requests. ignoreUntil is used in responses.
  345. ignoreDuration?: number;
  346. ignoreUntil?: string;
  347. ignoreUserCount?: number;
  348. ignoreUserWindow?: number;
  349. ignoreWindow?: number;
  350. inCommit?: Commit;
  351. inNextRelease?: boolean;
  352. inRelease?: string;
  353. };
  354. export type UpdateResolutionStatus = {
  355. status: ResolutionStatus;
  356. statusDetails?: ResolutionStatusDetails;
  357. };
  358. type BaseGroupStatusResolution = {
  359. status: ResolutionStatus;
  360. statusDetails: ResolutionStatusDetails;
  361. };
  362. export type GroupRelease = {
  363. firstRelease: Release;
  364. lastRelease: Release;
  365. };
  366. // TODO(ts): incomplete
  367. export type BaseGroup = {
  368. activity: GroupActivity[];
  369. annotations: string[];
  370. assignedTo: Actor;
  371. culprit: string;
  372. firstSeen: string;
  373. hasSeen: boolean;
  374. id: string;
  375. isBookmarked: boolean;
  376. isPublic: boolean;
  377. isSubscribed: boolean;
  378. isUnhandled: boolean;
  379. lastSeen: string;
  380. latestEvent: Event;
  381. level: Level;
  382. logger: string;
  383. metadata: EventMetadata;
  384. numComments: number;
  385. participants: User[];
  386. permalink: string;
  387. platform: PlatformKey;
  388. pluginActions: any[]; // TODO(ts)
  389. pluginContexts: any[]; // TODO(ts)
  390. pluginIssues: any[]; // TODO(ts)
  391. project: Project;
  392. seenBy: User[];
  393. shareId: string;
  394. shortId: string;
  395. status: string;
  396. subscriptionDetails: {disabled?: boolean; reason?: string} | null;
  397. tags: Pick<Tag, 'key' | 'name' | 'totalValues'>[];
  398. title: string;
  399. type: EventOrGroupType;
  400. userReportCount: number;
  401. inbox?: InboxDetails | null | false;
  402. owners?: SuggestedOwner[] | null;
  403. } & GroupRelease;
  404. export type GroupReprocessing = BaseGroup & GroupStats & BaseGroupStatusReprocessing;
  405. export type GroupResolution = BaseGroup & GroupStats & BaseGroupStatusResolution;
  406. export type Group = GroupResolution | GroupReprocessing;
  407. export type GroupCollapseRelease = Omit<Group, keyof GroupRelease> &
  408. Partial<GroupRelease>;
  409. export type GroupTombstone = {
  410. actor: AvatarUser;
  411. culprit: string;
  412. id: string;
  413. level: Level;
  414. metadata: EventMetadata;
  415. title: string;
  416. };
  417. export type ProcessingIssueItem = {
  418. checksum: string;
  419. data: {
  420. // TODO(ts) This type is likely incomplete, but this is what
  421. // project processing issues settings uses.
  422. _scope: string;
  423. image_arch: string;
  424. image_path: string;
  425. image_uuid: string;
  426. };
  427. id: string;
  428. lastSeen: string;
  429. numEvents: number;
  430. type: string;
  431. };
  432. export type ProcessingIssue = {
  433. hasIssues: boolean;
  434. hasMoreResolveableIssues: boolean;
  435. issuesProcessing: number;
  436. lastSeen: string;
  437. numIssues: number;
  438. project: string;
  439. resolveableIssues: number;
  440. signedLink: string;
  441. issues?: ProcessingIssueItem[];
  442. };
  443. /**
  444. * Datascrubbing
  445. */
  446. export type Meta = {
  447. chunks: Array<ChunkType>;
  448. err: Array<MetaError>;
  449. len: number;
  450. rem: Array<MetaRemark>;
  451. };
  452. export type MetaError = string | [string, any];
  453. export type MetaRemark = Array<string | number>;
  454. export type ChunkType = {
  455. rule_id: string | number;
  456. text: string;
  457. type: string;
  458. remark?: string | number;
  459. };
  460. /**
  461. * User Feedback
  462. */
  463. export type UserReport = {
  464. comments: string;
  465. dateCreated: string;
  466. email: string;
  467. event: {eventID: string; id: string};
  468. eventID: string;
  469. id: string;
  470. issue: Group;
  471. name: string;
  472. user: User;
  473. };
  474. export type KeyValueListData = {
  475. key: string;
  476. subject: string;
  477. actionButton?: React.ReactNode;
  478. meta?: Meta;
  479. subjectDataTestId?: string;
  480. subjectIcon?: React.ReactNode;
  481. value?: React.ReactNode;
  482. }[];
  483. // Response from ShortIdLookupEndpoint
  484. // /organizations/${orgId}/shortids/${query}/
  485. export type ShortIdResponse = {
  486. group: Group;
  487. groupId: string;
  488. organizationSlug: string;
  489. projectSlug: string;
  490. shortId: string;
  491. };
  492. /**
  493. * Note used in Group Activity and Alerts for users to comment
  494. */
  495. export type Note = {
  496. /**
  497. * Array of [id, display string] tuples used for @-mentions
  498. */
  499. mentions: [string, string][];
  500. /**
  501. * Note contents (markdown allowed)
  502. */
  503. text: string;
  504. };