group.tsx 15 KB

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