group.tsx 16 KB

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