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 {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_CONSECUTIVE_HTTP = 'performance_consecutive_http',
  56. PERFORMANCE_FILE_IO_MAIN_THREAD = 'performance_file_io_main_thread',
  57. PERFORMANCE_DB_MAIN_THREAD = 'performance_db_main_thread',
  58. PERFORMANCE_N_PLUS_ONE_API_CALLS = 'performance_n_plus_one_api_calls',
  59. PERFORMANCE_N_PLUS_ONE_DB_QUERIES = 'performance_n_plus_one_db_queries',
  60. PERFORMANCE_SLOW_DB_QUERY = 'performance_slow_db_query',
  61. PERFORMANCE_RENDER_BLOCKING_ASSET = 'performance_render_blocking_asset_span',
  62. PERFORMANCE_UNCOMPRESSED_ASSET = 'performance_uncompressed_assets',
  63. PERFORMANCE_LARGE_HTTP_PAYLOAD = 'performance_large_http_payload',
  64. // Profile
  65. PROFILE_FILE_IO_MAIN_THREAD = 'profile_file_io_main_thread',
  66. PROFILE_IMAGE_DECODE_MAIN_THREAD = 'profile_image_decode_main_thread',
  67. PROFILE_JSON_DECODE_MAIN_THREAD = 'profile_json_decode_main_thread',
  68. }
  69. export const getIssueTypeFromOccurenceType = (
  70. typeId: number | undefined
  71. ): IssueType | null => {
  72. const occurrenceTypeToIssueIdMap = {
  73. 1001: IssueType.PERFORMANCE_SLOW_DB_QUERY,
  74. 1004: IssueType.PERFORMANCE_RENDER_BLOCKING_ASSET,
  75. 1006: IssueType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES,
  76. 1007: IssueType.PERFORMANCE_CONSECUTIVE_DB_QUERIES,
  77. 1008: IssueType.PERFORMANCE_FILE_IO_MAIN_THREAD,
  78. 1009: IssueType.PERFORMANCE_CONSECUTIVE_HTTP,
  79. 1010: IssueType.PERFORMANCE_N_PLUS_ONE_API_CALLS,
  80. 1012: IssueType.PERFORMANCE_UNCOMPRESSED_ASSET,
  81. 1015: IssueType.PERFORMANCE_LARGE_HTTP_PAYLOAD,
  82. };
  83. if (!typeId) {
  84. return null;
  85. }
  86. return occurrenceTypeToIssueIdMap[typeId] ?? null;
  87. };
  88. // endpoint: /api/0/issues/:issueId/attachments/?limit=50
  89. export type IssueAttachment = {
  90. dateCreated: string;
  91. event_id: string;
  92. headers: object;
  93. id: string;
  94. mimetype: string;
  95. name: string;
  96. sha1: string;
  97. size: number;
  98. type: string;
  99. };
  100. // endpoint: /api/0/projects/:orgSlug/:projSlug/events/:eventId/attachments/
  101. export type EventAttachment = IssueAttachment;
  102. /**
  103. * Issue Tags
  104. */
  105. export type Tag = {
  106. key: string;
  107. name: string;
  108. isInput?: boolean;
  109. kind?: FieldKind;
  110. /**
  111. * How many values should be suggested in autocomplete.
  112. * Overrides SmartSearchBar's `maxSearchItems` prop.
  113. */
  114. maxSuggestedValues?: number;
  115. predefined?: boolean;
  116. totalValues?: number;
  117. values?: string[];
  118. };
  119. export type TagCollection = Record<string, Tag>;
  120. export type TagValue = {
  121. count: number;
  122. firstSeen: string;
  123. lastSeen: string;
  124. name: string;
  125. value: string;
  126. email?: string;
  127. identifier?: string;
  128. ipAddress?: string;
  129. key?: string;
  130. query?: string;
  131. username?: string;
  132. } & AvatarUser;
  133. type Topvalue = {
  134. count: number;
  135. firstSeen: string;
  136. key: string;
  137. lastSeen: string;
  138. name: string;
  139. value: string;
  140. // Might not actually exist.
  141. query?: string;
  142. readable?: string;
  143. };
  144. export type TagWithTopValues = {
  145. key: string;
  146. name: string;
  147. topValues: Array<Topvalue>;
  148. totalValues: number;
  149. uniqueValues: number;
  150. canDelete?: boolean;
  151. };
  152. export const enum GroupSubstatus {
  153. ARCHIVED_UNTIL_ESCALATING = 'archived_until_escalating',
  154. ARCHIVED_UNTIL_CONDITION_MET = 'archived_until_condition_met',
  155. ARCHIVED_FOREVER = 'archived_forever',
  156. ESCALATING = 'escalating',
  157. ONGOING = 'ongoing',
  158. REGRESSED = 'regressed',
  159. NEW = 'new',
  160. }
  161. /**
  162. * Inbox, issue owners and Activity
  163. */
  164. export type InboxReasonDetails = {
  165. count?: number | null;
  166. until?: string | null;
  167. user_count?: number | null;
  168. user_window?: number | null;
  169. window?: number | null;
  170. };
  171. export const enum GroupInboxReason {
  172. NEW = 0,
  173. UNIGNORED = 1,
  174. REGRESSION = 2,
  175. MANUAL = 3,
  176. REPROCESSED = 4,
  177. ESCALATING = 5,
  178. ONGOING = 6,
  179. }
  180. export type InboxDetails = {
  181. date_added?: string;
  182. reason?: GroupInboxReason;
  183. reason_details?: InboxReasonDetails | null;
  184. };
  185. export type SuggestedOwnerReason =
  186. | 'suspectCommit'
  187. | 'ownershipRule'
  188. | 'projectOwnership'
  189. // TODO: codeowners may no longer exist
  190. | 'codeowners';
  191. // Received from the backend to denote suggested owners of an issue
  192. export type SuggestedOwner = {
  193. date_added: string;
  194. owner: string;
  195. type: SuggestedOwnerReason;
  196. };
  197. export interface ParsedOwnershipRule {
  198. matcher: {pattern: string; type: string};
  199. owners: Actor[];
  200. }
  201. export type IssueOwnership = {
  202. autoAssignment:
  203. | 'Auto Assign to Suspect Commits'
  204. | 'Auto Assign to Issue Owner'
  205. | 'Turn off Auto-Assignment';
  206. codeownersAutoSync: boolean;
  207. dateCreated: string | null;
  208. fallthrough: boolean;
  209. isActive: boolean;
  210. lastUpdated: string | null;
  211. raw: string | null;
  212. schema?: {rules: ParsedOwnershipRule[]; version: number};
  213. };
  214. export enum GroupActivityType {
  215. NOTE = 'note',
  216. SET_RESOLVED = 'set_resolved',
  217. SET_RESOLVED_BY_AGE = 'set_resolved_by_age',
  218. SET_RESOLVED_IN_RELEASE = 'set_resolved_in_release',
  219. SET_RESOLVED_IN_COMMIT = 'set_resolved_in_commit',
  220. SET_RESOLVED_IN_PULL_REQUEST = 'set_resolved_in_pull_request',
  221. SET_UNRESOLVED = 'set_unresolved',
  222. SET_IGNORED = 'set_ignored',
  223. SET_PUBLIC = 'set_public',
  224. SET_PRIVATE = 'set_private',
  225. SET_REGRESSION = 'set_regression',
  226. CREATE_ISSUE = 'create_issue',
  227. UNMERGE_SOURCE = 'unmerge_source',
  228. UNMERGE_DESTINATION = 'unmerge_destination',
  229. FIRST_SEEN = 'first_seen',
  230. ASSIGNED = 'assigned',
  231. UNASSIGNED = 'unassigned',
  232. MERGE = 'merge',
  233. REPROCESS = 'reprocess',
  234. MARK_REVIEWED = 'mark_reviewed',
  235. AUTO_SET_ONGOING = 'auto_set_ongoing',
  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. export interface GroupActivityAssigned extends GroupActivityBase {
  362. data: {
  363. assignee: string;
  364. assigneeType: string;
  365. user: Team | User;
  366. assigneeEmail?: string;
  367. /**
  368. * If the user was assigned via an integration
  369. */
  370. integration?: 'projectOwnership' | 'codeowners' | 'slack' | 'msteams';
  371. /** Codeowner or Project owner rule as a string */
  372. rule?: string;
  373. };
  374. type: GroupActivityType.ASSIGNED;
  375. }
  376. export interface GroupActivityCreateIssue extends GroupActivityBase {
  377. data: {
  378. location: string;
  379. provider: string;
  380. title: string;
  381. };
  382. type: GroupActivityType.CREATE_ISSUE;
  383. }
  384. export type GroupActivity =
  385. | GroupActivityNote
  386. | GroupActivitySetResolved
  387. | GroupActivitySetUnresolved
  388. | GroupActivitySetIgnored
  389. | GroupActivitySetByAge
  390. | GroupActivitySetByResolvedInRelease
  391. | GroupActivitySetByResolvedInCommit
  392. | GroupActivitySetByResolvedInPullRequest
  393. | GroupActivityFirstSeen
  394. | GroupActivityMerge
  395. | GroupActivityReprocess
  396. | GroupActivityUnassigned
  397. | GroupActivityMarkReviewed
  398. | GroupActivityUnmergeDestination
  399. | GroupActivitySetPublic
  400. | GroupActivitySetPrivate
  401. | GroupActivityRegression
  402. | GroupActivityUnmergeSource
  403. | GroupActivityAssigned
  404. | GroupActivityCreateIssue
  405. | GroupActivityAutoSetOngoing;
  406. export type Activity = GroupActivity;
  407. interface GroupFiltered {
  408. count: string;
  409. firstSeen: string;
  410. lastSeen: string;
  411. stats: Record<string, TimeseriesValue[]>;
  412. userCount: number;
  413. }
  414. export interface GroupStats extends GroupFiltered {
  415. filtered: GroupFiltered | null;
  416. id: string;
  417. // for issue alert previews, the last time a group triggered a rule
  418. lastTriggered?: string;
  419. lifetime?: GroupFiltered;
  420. sessionCount?: string | null;
  421. }
  422. export interface BaseGroupStatusReprocessing {
  423. status: 'reprocessing';
  424. statusDetails: {
  425. info: {
  426. dateCreated: string;
  427. totalEvents: number;
  428. } | null;
  429. pendingEvents: number;
  430. };
  431. }
  432. /**
  433. * Issue Resolution
  434. */
  435. export enum ResolutionStatus {
  436. RESOLVED = 'resolved',
  437. UNRESOLVED = 'unresolved',
  438. IGNORED = 'ignored',
  439. }
  440. export type ResolutionStatusDetails = {
  441. actor?: AvatarUser;
  442. autoResolved?: boolean;
  443. ignoreCount?: number;
  444. // Sent in requests. ignoreUntil is used in responses.
  445. ignoreDuration?: number;
  446. ignoreUntil?: string;
  447. ignoreUntilEscalating?: boolean;
  448. ignoreUserCount?: number;
  449. ignoreUserWindow?: number;
  450. ignoreWindow?: number;
  451. inCommit?: {
  452. commit?: string;
  453. dateCreated?: string;
  454. id?: string;
  455. repository?: string | Repository;
  456. };
  457. inNextRelease?: boolean;
  458. inRelease?: string;
  459. repository?: string;
  460. };
  461. export type GroupStatusResolution = {
  462. status: ResolutionStatus;
  463. statusDetails: ResolutionStatusDetails;
  464. substatus?: GroupSubstatus;
  465. };
  466. export type GroupRelease = {
  467. firstRelease: Release;
  468. lastRelease: Release;
  469. };
  470. // TODO(ts): incomplete
  471. export interface BaseGroup extends GroupRelease {
  472. activity: GroupActivity[];
  473. annotations: string[];
  474. assignedTo: Actor;
  475. culprit: string;
  476. firstSeen: string;
  477. hasSeen: boolean;
  478. id: string;
  479. isBookmarked: boolean;
  480. isPublic: boolean;
  481. isSubscribed: boolean;
  482. isUnhandled: boolean;
  483. issueCategory: IssueCategory;
  484. issueType: IssueType;
  485. lastSeen: string;
  486. latestEvent: Event;
  487. level: Level;
  488. logger: string;
  489. metadata: EventMetadata;
  490. numComments: number;
  491. participants: User[];
  492. permalink: string;
  493. platform: PlatformKey;
  494. pluginActions: any[]; // TODO(ts)
  495. pluginContexts: any[]; // TODO(ts)
  496. pluginIssues: any[]; // TODO(ts)
  497. project: Project;
  498. seenBy: User[];
  499. shareId: string;
  500. shortId: string;
  501. status: string;
  502. subscriptionDetails: {disabled?: boolean; reason?: string} | null;
  503. title: string;
  504. type: EventOrGroupType;
  505. userReportCount: number;
  506. inbox?: InboxDetails | null | false;
  507. owners?: SuggestedOwner[] | null;
  508. substatus?: GroupSubstatus;
  509. }
  510. export interface GroupReprocessing
  511. // BaseGroupStatusReprocessing status field (enum) incorrectly extends the BaseGroup status field (string) so we omit it.
  512. // A proper fix for this would be to make the status field an enum or string and correctly extend it.
  513. extends Omit<BaseGroup, 'status'>,
  514. GroupStats,
  515. BaseGroupStatusReprocessing {}
  516. export interface GroupResolution
  517. // GroupStatusResolution status field (enum) incorrectly extends the BaseGroup status field (string) so we omit it.
  518. // A proper fix for this would be to make the status field an enum or string and correctly extend it.
  519. extends Omit<BaseGroup, 'status'>,
  520. GroupStats,
  521. GroupStatusResolution {}
  522. export type Group = GroupResolution | GroupReprocessing;
  523. export interface GroupCollapseRelease
  524. extends Omit<Group, keyof GroupRelease>,
  525. Partial<GroupRelease> {}
  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. };