group.tsx 15 KB

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