group.tsx 15 KB

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