group.tsx 15 KB

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