group.tsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  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. 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. type GroupActivityBase = {
  156. dateCreated: string;
  157. id: string;
  158. project: Project;
  159. assignee?: string;
  160. issue?: Group;
  161. user?: null | User;
  162. };
  163. type GroupActivityNote = GroupActivityBase & {
  164. data: {
  165. text: string;
  166. };
  167. type: GroupActivityType.NOTE;
  168. };
  169. type GroupActivitySetResolved = GroupActivityBase & {
  170. data: Record<string, any>;
  171. type: GroupActivityType.SET_RESOLVED;
  172. };
  173. type GroupActivitySetUnresolved = GroupActivityBase & {
  174. data: Record<string, any>;
  175. type: GroupActivityType.SET_UNRESOLVED;
  176. };
  177. type GroupActivitySetPublic = GroupActivityBase & {
  178. data: Record<string, any>;
  179. type: GroupActivityType.SET_PUBLIC;
  180. };
  181. type GroupActivitySetPrivate = GroupActivityBase & {
  182. data: Record<string, any>;
  183. type: GroupActivityType.SET_PRIVATE;
  184. };
  185. type GroupActivitySetByAge = GroupActivityBase & {
  186. data: Record<string, any>;
  187. type: GroupActivityType.SET_RESOLVED_BY_AGE;
  188. };
  189. type GroupActivityUnassigned = GroupActivityBase & {
  190. data: Record<string, any>;
  191. type: GroupActivityType.UNASSIGNED;
  192. };
  193. type GroupActivityFirstSeen = GroupActivityBase & {
  194. data: Record<string, any>;
  195. type: GroupActivityType.FIRST_SEEN;
  196. };
  197. type GroupActivityMarkReviewed = GroupActivityBase & {
  198. data: Record<string, any>;
  199. type: GroupActivityType.MARK_REVIEWED;
  200. };
  201. type GroupActivityRegression = GroupActivityBase & {
  202. data: {
  203. version?: string;
  204. };
  205. type: GroupActivityType.SET_REGRESSION;
  206. };
  207. export type GroupActivitySetByResolvedInRelease = GroupActivityBase & {
  208. data: {
  209. current_release_version?: string;
  210. version?: string;
  211. };
  212. type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
  213. };
  214. type GroupActivitySetByResolvedInCommit = GroupActivityBase & {
  215. data: {
  216. commit: Commit;
  217. };
  218. type: GroupActivityType.SET_RESOLVED_IN_COMMIT;
  219. };
  220. type GroupActivitySetByResolvedInPullRequest = GroupActivityBase & {
  221. data: {
  222. pullRequest: PullRequest;
  223. };
  224. type: GroupActivityType.SET_RESOLVED_IN_PULL_REQUEST;
  225. };
  226. export type GroupActivitySetIgnored = 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 type GroupActivityReprocess = GroupActivityBase & {
  238. data: {
  239. eventCount: number;
  240. newGroupId: number;
  241. oldGroupId: number;
  242. };
  243. type: GroupActivityType.REPROCESS;
  244. };
  245. type GroupActivityUnmergeDestination = GroupActivityBase & {
  246. data: {
  247. fingerprints: Array<string>;
  248. source?: {
  249. id: string;
  250. shortId: string;
  251. };
  252. };
  253. type: GroupActivityType.UNMERGE_DESTINATION;
  254. };
  255. type GroupActivityUnmergeSource = GroupActivityBase & {
  256. data: {
  257. fingerprints: Array<string>;
  258. destination?: {
  259. id: string;
  260. shortId: string;
  261. };
  262. };
  263. type: GroupActivityType.UNMERGE_SOURCE;
  264. };
  265. type GroupActivityMerge = GroupActivityBase & {
  266. data: {
  267. issues: Array<any>;
  268. };
  269. type: GroupActivityType.MERGE;
  270. };
  271. export type GroupActivityAssigned = GroupActivityBase & {
  272. data: {
  273. assignee: string;
  274. assigneeType: string;
  275. user: Team | User;
  276. assigneeEmail?: string;
  277. };
  278. type: GroupActivityType.ASSIGNED;
  279. };
  280. export type GroupActivityCreateIssue = 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 UpdateResolutionStatus = {
  356. status: ResolutionStatus;
  357. statusDetails?: ResolutionStatusDetails;
  358. };
  359. type BaseGroupStatusResolution = {
  360. status: ResolutionStatus;
  361. statusDetails: ResolutionStatusDetails;
  362. };
  363. export type GroupRelease = {
  364. firstRelease: Release;
  365. lastRelease: Release;
  366. };
  367. // TODO(ts): incomplete
  368. export type BaseGroup = {
  369. activity: GroupActivity[];
  370. annotations: string[];
  371. assignedTo: Actor;
  372. culprit: string;
  373. firstSeen: string;
  374. hasSeen: boolean;
  375. id: string;
  376. isBookmarked: boolean;
  377. isPublic: boolean;
  378. isSubscribed: boolean;
  379. isUnhandled: boolean;
  380. lastSeen: string;
  381. latestEvent: Event;
  382. level: Level;
  383. logger: string;
  384. metadata: EventMetadata;
  385. numComments: number;
  386. participants: User[];
  387. permalink: string;
  388. platform: PlatformKey;
  389. pluginActions: any[]; // TODO(ts)
  390. pluginContexts: any[]; // TODO(ts)
  391. pluginIssues: any[]; // TODO(ts)
  392. project: Project;
  393. seenBy: User[];
  394. shareId: string;
  395. shortId: string;
  396. status: string;
  397. subscriptionDetails: {disabled?: boolean; reason?: string} | null;
  398. tags: Pick<Tag, 'key' | 'name' | 'totalValues'>[];
  399. title: string;
  400. type: EventOrGroupType;
  401. userReportCount: number;
  402. inbox?: InboxDetails | null | false;
  403. owners?: SuggestedOwner[] | null;
  404. } & GroupRelease;
  405. export type GroupReprocessing = BaseGroup & GroupStats & BaseGroupStatusReprocessing;
  406. export type GroupResolution = BaseGroup & GroupStats & BaseGroupStatusResolution;
  407. export type Group = GroupResolution | GroupReprocessing;
  408. export type GroupCollapseRelease = Omit<Group, keyof GroupRelease> &
  409. Partial<GroupRelease>;
  410. export type GroupTombstone = {
  411. actor: AvatarUser;
  412. culprit: string;
  413. id: string;
  414. level: Level;
  415. metadata: EventMetadata;
  416. title: string;
  417. };
  418. export type ProcessingIssueItem = {
  419. checksum: string;
  420. data: {
  421. // TODO(ts) This type is likely incomplete, but this is what
  422. // project processing issues settings uses.
  423. _scope: string;
  424. image_arch: string;
  425. image_path: string;
  426. image_uuid: string;
  427. };
  428. id: string;
  429. lastSeen: string;
  430. numEvents: number;
  431. type: string;
  432. };
  433. export type ProcessingIssue = {
  434. hasIssues: boolean;
  435. hasMoreResolveableIssues: boolean;
  436. issuesProcessing: number;
  437. lastSeen: string;
  438. numIssues: number;
  439. project: string;
  440. resolveableIssues: number;
  441. signedLink: string;
  442. issues?: ProcessingIssueItem[];
  443. };
  444. /**
  445. * Datascrubbing
  446. */
  447. export type Meta = {
  448. chunks: Array<ChunkType>;
  449. err: Array<MetaError>;
  450. len: number;
  451. rem: Array<MetaRemark>;
  452. };
  453. export type MetaError = string | [string, any];
  454. export type MetaRemark = Array<string | number>;
  455. export type ChunkType = {
  456. rule_id: string | number;
  457. text: string;
  458. type: string;
  459. remark?: string | number;
  460. };
  461. /**
  462. * User Feedback
  463. */
  464. export type UserReport = {
  465. comments: string;
  466. dateCreated: string;
  467. email: string;
  468. event: {eventID: string; id: string};
  469. eventID: string;
  470. id: string;
  471. issue: Group;
  472. name: string;
  473. user: User;
  474. };
  475. export type KeyValueListData = {
  476. key: string;
  477. subject: string;
  478. actionButton?: React.ReactNode;
  479. meta?: Meta;
  480. subjectDataTestId?: string;
  481. subjectIcon?: React.ReactNode;
  482. value?: React.ReactNode;
  483. }[];
  484. // Response from ShortIdLookupEndpoint
  485. // /organizations/${orgId}/shortids/${query}/
  486. export type ShortIdResponse = {
  487. group: Group;
  488. groupId: string;
  489. organizationSlug: string;
  490. projectSlug: string;
  491. shortId: string;
  492. };
  493. /**
  494. * Note used in Group Activity and Alerts for users to comment
  495. */
  496. export type Note = {
  497. /**
  498. * Array of [id, display string] tuples used for @-mentions
  499. */
  500. mentions: [string, string][];
  501. /**
  502. * Note contents (markdown allowed)
  503. */
  504. text: string;
  505. };