group.tsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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 {AvatarUser, User} from './user';
  9. export type EntryData = Record<string, any | Array<any>>;
  10. /**
  11. * Saved issues searches
  12. */
  13. export type RecentSearch = {
  14. dateCreated: string;
  15. id: string;
  16. lastSeen: string;
  17. organizationId: string;
  18. query: string;
  19. type: SavedSearchType;
  20. };
  21. // XXX: Deprecated Sentry 9 attributes are not included here.
  22. export type SavedSearch = {
  23. dateCreated: string;
  24. id: string;
  25. isGlobal: boolean;
  26. isPinned: boolean;
  27. name: string;
  28. query: string;
  29. sort: string;
  30. type: SavedSearchType;
  31. visibility: SavedSearchVisibility;
  32. };
  33. export enum SavedSearchVisibility {
  34. Organization = 'organization',
  35. Owner = 'owner',
  36. OwnerPinned = 'owner_pinned',
  37. }
  38. export enum SavedSearchType {
  39. ISSUE = 0,
  40. EVENT = 1,
  41. SESSION = 2,
  42. REPLAY = 3,
  43. }
  44. export enum IssueCategory {
  45. PERFORMANCE = 'performance',
  46. ERROR = 'error',
  47. PROFILE = 'profile',
  48. }
  49. export enum IssueType {
  50. // Error
  51. ERROR = 'error',
  52. // Performance
  53. PERFORMANCE_CONSECUTIVE_DB_QUERIES = 'performance_consecutive_db_queries',
  54. PERFORMANCE_CONSECUTIVE_HTTP = 'performance_consecutive_http',
  55. PERFORMANCE_FILE_IO_MAIN_THREAD = 'performance_file_io_main_thread',
  56. PERFORMANCE_DB_MAIN_THREAD = 'performance_db_main_thread',
  57. PERFORMANCE_N_PLUS_ONE_API_CALLS = 'performance_n_plus_one_api_calls',
  58. PERFORMANCE_N_PLUS_ONE_DB_QUERIES = 'performance_n_plus_one_db_queries',
  59. PERFORMANCE_SLOW_DB_QUERY = 'performance_slow_db_query',
  60. PERFORMANCE_RENDER_BLOCKING_ASSET = 'performance_render_blocking_asset_span',
  61. PERFORMANCE_UNCOMPRESSED_ASSET = 'performance_uncompressed_assets',
  62. PERFORMANCE_LARGE_HTTP_PAYLOAD = 'performance_large_http_payload',
  63. // Profile
  64. PROFILE_FILE_IO_MAIN_THREAD = 'profile_file_io_main_thread',
  65. PROFILE_IMAGE_DECODE_MAIN_THREAD = 'profile_image_decode_main_thread',
  66. PROFILE_JSON_DECODE_MAIN_THREAD = 'profile_json_decode_main_thread',
  67. }
  68. export const getIssueTypeFromOccurenceType = (
  69. typeId: number | undefined
  70. ): IssueType | null => {
  71. const occurrenceTypeToIssueIdMap = {
  72. 1001: IssueType.PERFORMANCE_SLOW_DB_QUERY,
  73. 1004: IssueType.PERFORMANCE_RENDER_BLOCKING_ASSET,
  74. 1006: IssueType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES,
  75. 1007: IssueType.PERFORMANCE_CONSECUTIVE_DB_QUERIES,
  76. 1008: IssueType.PERFORMANCE_FILE_IO_MAIN_THREAD,
  77. 1009: IssueType.PERFORMANCE_CONSECUTIVE_HTTP,
  78. 1010: IssueType.PERFORMANCE_N_PLUS_ONE_API_CALLS,
  79. 1012: IssueType.PERFORMANCE_UNCOMPRESSED_ASSET,
  80. 1015: IssueType.PERFORMANCE_LARGE_HTTP_PAYLOAD,
  81. };
  82. if (!typeId) {
  83. return null;
  84. }
  85. return occurrenceTypeToIssueIdMap[typeId] ?? null;
  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. export const enum GroupSubstatus {
  152. ARCHIVED_UNTIL_ESCALATING = 'archived_until_escalating',
  153. ARCHIVED_UNTIL_CONDITION_MET = 'archived_until_condition_met',
  154. ARCHIVED_FOREVER = 'archived_forever',
  155. ESCALATING = 'escalating',
  156. ONGOING = 'ongoing',
  157. REGRESSED = 'regressed',
  158. NEW = 'new',
  159. }
  160. /**
  161. * Inbox, issue owners and Activity
  162. */
  163. export type InboxReasonDetails = {
  164. count?: number | null;
  165. until?: string | null;
  166. user_count?: number | null;
  167. user_window?: number | null;
  168. window?: number | null;
  169. };
  170. export const enum GroupInboxReason {
  171. NEW = 0,
  172. UNIGNORED = 1,
  173. REGRESSION = 2,
  174. MANUAL = 3,
  175. REPROCESSED = 4,
  176. ESCALATING = 5,
  177. ONGOING = 6,
  178. }
  179. export type InboxDetails = {
  180. date_added?: string;
  181. reason?: GroupInboxReason;
  182. reason_details?: InboxReasonDetails | null;
  183. };
  184. export type SuggestedOwnerReason =
  185. | 'suspectCommit'
  186. | 'ownershipRule'
  187. | 'projectOwnership'
  188. // TODO: codeowners may no longer exist
  189. | 'codeowners';
  190. // Received from the backend to denote suggested owners of an issue
  191. export type SuggestedOwner = {
  192. date_added: string;
  193. owner: string;
  194. type: SuggestedOwnerReason;
  195. };
  196. export interface ParsedOwnershipRule {
  197. matcher: {pattern: string; type: string};
  198. owners: Actor[];
  199. }
  200. export type IssueOwnership = {
  201. autoAssignment:
  202. | 'Auto Assign to Suspect Commits'
  203. | 'Auto Assign to Issue Owner'
  204. | 'Turn off Auto-Assignment';
  205. codeownersAutoSync: boolean;
  206. dateCreated: string | null;
  207. fallthrough: boolean;
  208. isActive: boolean;
  209. lastUpdated: string | null;
  210. raw: string | null;
  211. schema?: {rules: ParsedOwnershipRule[]; version: number};
  212. };
  213. export enum GroupActivityType {
  214. NOTE = 'note',
  215. SET_RESOLVED = 'set_resolved',
  216. SET_RESOLVED_BY_AGE = 'set_resolved_by_age',
  217. SET_RESOLVED_IN_RELEASE = 'set_resolved_in_release',
  218. SET_RESOLVED_IN_COMMIT = 'set_resolved_in_commit',
  219. SET_RESOLVED_IN_PULL_REQUEST = 'set_resolved_in_pull_request',
  220. SET_UNRESOLVED = 'set_unresolved',
  221. SET_IGNORED = 'set_ignored',
  222. SET_PUBLIC = 'set_public',
  223. SET_PRIVATE = 'set_private',
  224. SET_REGRESSION = 'set_regression',
  225. CREATE_ISSUE = 'create_issue',
  226. UNMERGE_SOURCE = 'unmerge_source',
  227. UNMERGE_DESTINATION = 'unmerge_destination',
  228. FIRST_SEEN = 'first_seen',
  229. ASSIGNED = 'assigned',
  230. UNASSIGNED = 'unassigned',
  231. MERGE = 'merge',
  232. REPROCESS = 'reprocess',
  233. MARK_REVIEWED = 'mark_reviewed',
  234. AUTO_SET_ONGOING = 'auto_set_ongoing',
  235. SET_ESCALATING = 'set_escalating',
  236. }
  237. interface GroupActivityBase {
  238. dateCreated: string;
  239. id: string;
  240. project: Project;
  241. assignee?: string;
  242. issue?: Group;
  243. user?: null | User;
  244. }
  245. interface GroupActivityNote extends GroupActivityBase {
  246. data: {
  247. text: string;
  248. };
  249. type: GroupActivityType.NOTE;
  250. }
  251. interface GroupActivitySetResolved extends GroupActivityBase {
  252. data: Record<string, any>;
  253. type: GroupActivityType.SET_RESOLVED;
  254. }
  255. interface GroupActivitySetUnresolved extends GroupActivityBase {
  256. data: Record<string, any>;
  257. type: GroupActivityType.SET_UNRESOLVED;
  258. }
  259. interface GroupActivitySetPublic extends GroupActivityBase {
  260. data: Record<string, any>;
  261. type: GroupActivityType.SET_PUBLIC;
  262. }
  263. interface GroupActivitySetPrivate extends GroupActivityBase {
  264. data: Record<string, any>;
  265. type: GroupActivityType.SET_PRIVATE;
  266. }
  267. interface GroupActivitySetByAge extends GroupActivityBase {
  268. data: Record<string, any>;
  269. type: GroupActivityType.SET_RESOLVED_BY_AGE;
  270. }
  271. interface GroupActivityUnassigned extends GroupActivityBase {
  272. data: Record<string, any>;
  273. type: GroupActivityType.UNASSIGNED;
  274. }
  275. interface GroupActivityFirstSeen extends GroupActivityBase {
  276. data: Record<string, any>;
  277. type: GroupActivityType.FIRST_SEEN;
  278. }
  279. interface GroupActivityMarkReviewed extends GroupActivityBase {
  280. data: Record<string, any>;
  281. type: GroupActivityType.MARK_REVIEWED;
  282. }
  283. interface GroupActivityRegression extends GroupActivityBase {
  284. data: {
  285. version?: string;
  286. };
  287. type: GroupActivityType.SET_REGRESSION;
  288. }
  289. export interface GroupActivitySetByResolvedInRelease extends GroupActivityBase {
  290. data: {
  291. current_release_version?: string;
  292. version?: string;
  293. };
  294. type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
  295. }
  296. interface GroupActivitySetByResolvedInCommit extends GroupActivityBase {
  297. data: {
  298. commit?: Commit;
  299. };
  300. type: GroupActivityType.SET_RESOLVED_IN_COMMIT;
  301. }
  302. interface GroupActivitySetByResolvedInPullRequest extends GroupActivityBase {
  303. data: {
  304. pullRequest?: PullRequest;
  305. };
  306. type: GroupActivityType.SET_RESOLVED_IN_PULL_REQUEST;
  307. }
  308. export interface GroupActivitySetIgnored extends GroupActivityBase {
  309. data: {
  310. ignoreCount?: number;
  311. ignoreDuration?: number;
  312. ignoreUntil?: string;
  313. /** Archived until escalating */
  314. ignoreUntilEscalating?: boolean;
  315. ignoreUserCount?: number;
  316. ignoreUserWindow?: number;
  317. ignoreWindow?: number;
  318. };
  319. type: GroupActivityType.SET_IGNORED;
  320. }
  321. export interface GroupActivityReprocess extends GroupActivityBase {
  322. data: {
  323. eventCount: number;
  324. newGroupId: number;
  325. oldGroupId: number;
  326. };
  327. type: GroupActivityType.REPROCESS;
  328. }
  329. interface GroupActivityUnmergeDestination extends GroupActivityBase {
  330. data: {
  331. fingerprints: Array<string>;
  332. source?: {
  333. id: string;
  334. shortId: string;
  335. };
  336. };
  337. type: GroupActivityType.UNMERGE_DESTINATION;
  338. }
  339. interface GroupActivityUnmergeSource extends GroupActivityBase {
  340. data: {
  341. fingerprints: Array<string>;
  342. destination?: {
  343. id: string;
  344. shortId: string;
  345. };
  346. };
  347. type: GroupActivityType.UNMERGE_SOURCE;
  348. }
  349. interface GroupActivityMerge extends GroupActivityBase {
  350. data: {
  351. issues: Array<any>;
  352. };
  353. type: GroupActivityType.MERGE;
  354. }
  355. interface GroupActivityAutoSetOngoing extends GroupActivityBase {
  356. data: {
  357. afterDays?: number;
  358. };
  359. type: GroupActivityType.AUTO_SET_ONGOING;
  360. }
  361. interface GroupActivitySetEscalating extends GroupActivityBase {
  362. data: {
  363. forecast: number;
  364. };
  365. type: GroupActivityType.SET_ESCALATING;
  366. }
  367. export interface GroupActivityAssigned extends GroupActivityBase {
  368. data: {
  369. assignee: string;
  370. assigneeType: string;
  371. user: Team | User;
  372. assigneeEmail?: string;
  373. /**
  374. * If the user was assigned via an integration
  375. */
  376. integration?: 'projectOwnership' | 'codeowners' | 'slack' | 'msteams';
  377. /** Codeowner or Project owner rule as a string */
  378. rule?: string;
  379. };
  380. type: GroupActivityType.ASSIGNED;
  381. }
  382. export interface GroupActivityCreateIssue extends GroupActivityBase {
  383. data: {
  384. location: string;
  385. provider: string;
  386. title: string;
  387. };
  388. type: GroupActivityType.CREATE_ISSUE;
  389. }
  390. export type GroupActivity =
  391. | GroupActivityNote
  392. | GroupActivitySetResolved
  393. | GroupActivitySetUnresolved
  394. | GroupActivitySetIgnored
  395. | GroupActivitySetByAge
  396. | GroupActivitySetByResolvedInRelease
  397. | GroupActivitySetByResolvedInCommit
  398. | GroupActivitySetByResolvedInPullRequest
  399. | GroupActivityFirstSeen
  400. | GroupActivityMerge
  401. | GroupActivityReprocess
  402. | GroupActivityUnassigned
  403. | GroupActivityMarkReviewed
  404. | GroupActivityUnmergeDestination
  405. | GroupActivitySetPublic
  406. | GroupActivitySetPrivate
  407. | GroupActivityRegression
  408. | GroupActivityUnmergeSource
  409. | GroupActivityAssigned
  410. | GroupActivityCreateIssue
  411. | GroupActivityAutoSetOngoing
  412. | GroupActivitySetEscalating;
  413. export type Activity = GroupActivity;
  414. interface GroupFiltered {
  415. count: string;
  416. firstSeen: string;
  417. lastSeen: string;
  418. stats: Record<string, TimeseriesValue[]>;
  419. userCount: number;
  420. }
  421. export interface GroupStats extends GroupFiltered {
  422. filtered: GroupFiltered | null;
  423. id: string;
  424. // for issue alert previews, the last time a group triggered a rule
  425. lastTriggered?: string;
  426. lifetime?: GroupFiltered;
  427. sessionCount?: string | null;
  428. }
  429. export interface BaseGroupStatusReprocessing {
  430. status: 'reprocessing';
  431. statusDetails: {
  432. info: {
  433. dateCreated: string;
  434. totalEvents: number;
  435. } | null;
  436. pendingEvents: number;
  437. };
  438. }
  439. /**
  440. * Issue Resolution
  441. */
  442. export enum ResolutionStatus {
  443. RESOLVED = 'resolved',
  444. UNRESOLVED = 'unresolved',
  445. IGNORED = 'ignored',
  446. }
  447. export type ResolutionStatusDetails = {
  448. actor?: AvatarUser;
  449. autoResolved?: boolean;
  450. ignoreCount?: number;
  451. // Sent in requests. ignoreUntil is used in responses.
  452. ignoreDuration?: number;
  453. ignoreUntil?: string;
  454. ignoreUntilEscalating?: boolean;
  455. ignoreUserCount?: number;
  456. ignoreUserWindow?: number;
  457. ignoreWindow?: number;
  458. inCommit?: {
  459. commit?: string;
  460. dateCreated?: string;
  461. id?: string;
  462. repository?: string | Repository;
  463. };
  464. inNextRelease?: boolean;
  465. inRelease?: string;
  466. repository?: string;
  467. };
  468. export type GroupStatusResolution = {
  469. status: ResolutionStatus;
  470. statusDetails: ResolutionStatusDetails;
  471. substatus?: GroupSubstatus;
  472. };
  473. // TODO(ts): incomplete
  474. export interface BaseGroup {
  475. activity: GroupActivity[];
  476. annotations: string[];
  477. assignedTo: Actor;
  478. culprit: string;
  479. firstSeen: string;
  480. hasSeen: boolean;
  481. id: string;
  482. isBookmarked: boolean;
  483. isPublic: boolean;
  484. isSubscribed: boolean;
  485. isUnhandled: boolean;
  486. issueCategory: IssueCategory;
  487. issueType: IssueType;
  488. lastSeen: string;
  489. latestEvent: Event;
  490. level: Level;
  491. logger: string;
  492. metadata: EventMetadata;
  493. numComments: number;
  494. participants: User[];
  495. permalink: string;
  496. platform: PlatformKey;
  497. pluginActions: any[]; // TODO(ts)
  498. pluginContexts: any[]; // TODO(ts)
  499. pluginIssues: any[]; // TODO(ts)
  500. project: Project;
  501. seenBy: User[];
  502. shareId: string;
  503. shortId: string;
  504. status: string;
  505. subscriptionDetails: {disabled?: boolean; reason?: string} | null;
  506. title: string;
  507. type: EventOrGroupType;
  508. userReportCount: number;
  509. inbox?: InboxDetails | null | false;
  510. owners?: SuggestedOwner[] | null;
  511. substatus?: GroupSubstatus;
  512. }
  513. export interface GroupReprocessing
  514. // BaseGroupStatusReprocessing status field (enum) incorrectly extends the BaseGroup status field (string) so we omit it.
  515. // A proper fix for this would be to make the status field an enum or string and correctly extend it.
  516. extends Omit<BaseGroup, 'status'>,
  517. GroupStats,
  518. BaseGroupStatusReprocessing {}
  519. export interface GroupResolution
  520. // GroupStatusResolution status field (enum) incorrectly extends the BaseGroup status field (string) so we omit it.
  521. // A proper fix for this would be to make the status field an enum or string and correctly extend it.
  522. extends Omit<BaseGroup, 'status'>,
  523. GroupStats,
  524. GroupStatusResolution {}
  525. export type Group = GroupResolution | GroupReprocessing;
  526. export interface GroupTombstone {
  527. actor: AvatarUser;
  528. culprit: string;
  529. id: string;
  530. level: Level;
  531. metadata: EventMetadata;
  532. type: EventOrGroupType;
  533. title?: string;
  534. }
  535. export interface GroupTombstoneHelper extends GroupTombstone {
  536. isTombstone: true;
  537. }
  538. export type ProcessingIssueItem = {
  539. checksum: string;
  540. data: {
  541. // TODO(ts) This type is likely incomplete, but this is what
  542. // project processing issues settings uses.
  543. _scope: string;
  544. image_arch: string;
  545. image_path: string;
  546. image_uuid: string;
  547. dist?: string;
  548. release?: string;
  549. };
  550. id: string;
  551. lastSeen: string;
  552. numEvents: number;
  553. type: string;
  554. };
  555. export type ProcessingIssue = {
  556. hasIssues: boolean;
  557. hasMoreResolveableIssues: boolean;
  558. issuesProcessing: number;
  559. lastSeen: string;
  560. numIssues: number;
  561. project: string;
  562. resolveableIssues: number;
  563. signedLink: string;
  564. issues?: ProcessingIssueItem[];
  565. };
  566. /**
  567. * Datascrubbing
  568. */
  569. export type Meta = {
  570. chunks: Array<ChunkType>;
  571. err: Array<MetaError>;
  572. len: number;
  573. rem: Array<MetaRemark>;
  574. };
  575. export type MetaError = string | [string, any];
  576. export type MetaRemark = Array<string | number>;
  577. export type ChunkType = {
  578. rule_id: string | number;
  579. text: string;
  580. type: string;
  581. remark?: string | number;
  582. };
  583. /**
  584. * User Feedback
  585. */
  586. export type UserReport = {
  587. comments: string;
  588. dateCreated: string;
  589. email: string;
  590. event: {eventID: string; id: string};
  591. eventID: string;
  592. id: string;
  593. issue: Group;
  594. name: string;
  595. user: User;
  596. };
  597. export type KeyValueListDataItem = {
  598. key: string;
  599. subject: string;
  600. actionButton?: React.ReactNode;
  601. isContextData?: boolean;
  602. isMultiValue?: boolean;
  603. meta?: Meta;
  604. subjectDataTestId?: string;
  605. subjectIcon?: React.ReactNode;
  606. value?: React.ReactNode;
  607. };
  608. export type KeyValueListData = KeyValueListDataItem[];
  609. // Response from ShortIdLookupEndpoint
  610. // /organizations/${orgId}/shortids/${query}/
  611. export type ShortIdResponse = {
  612. group: Group;
  613. groupId: string;
  614. organizationSlug: string;
  615. projectSlug: string;
  616. shortId: string;
  617. };
  618. /**
  619. * Note used in Group Activity and Alerts for users to comment
  620. */
  621. export type Note = {
  622. /**
  623. * Array of [id, display string] tuples used for @-mentions
  624. */
  625. mentions: [string, string][];
  626. /**
  627. * Note contents (markdown allowed)
  628. */
  629. text: string;
  630. };