group.tsx 15 KB

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