group.tsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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. reason_details: InboxReasonDetails;
  182. date_added?: string;
  183. reason?: GroupInboxReason;
  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. }
  236. interface GroupActivityBase {
  237. dateCreated: string;
  238. id: string;
  239. project: Project;
  240. assignee?: string;
  241. issue?: Group;
  242. user?: null | User;
  243. }
  244. interface GroupActivityNote extends GroupActivityBase {
  245. data: {
  246. text: string;
  247. };
  248. type: GroupActivityType.NOTE;
  249. }
  250. interface GroupActivitySetResolved extends GroupActivityBase {
  251. data: Record<string, any>;
  252. type: GroupActivityType.SET_RESOLVED;
  253. }
  254. interface GroupActivitySetUnresolved extends GroupActivityBase {
  255. data: Record<string, any>;
  256. type: GroupActivityType.SET_UNRESOLVED;
  257. }
  258. interface GroupActivitySetPublic extends GroupActivityBase {
  259. data: Record<string, any>;
  260. type: GroupActivityType.SET_PUBLIC;
  261. }
  262. interface GroupActivitySetPrivate extends GroupActivityBase {
  263. data: Record<string, any>;
  264. type: GroupActivityType.SET_PRIVATE;
  265. }
  266. interface GroupActivitySetByAge extends GroupActivityBase {
  267. data: Record<string, any>;
  268. type: GroupActivityType.SET_RESOLVED_BY_AGE;
  269. }
  270. interface GroupActivityUnassigned extends GroupActivityBase {
  271. data: Record<string, any>;
  272. type: GroupActivityType.UNASSIGNED;
  273. }
  274. interface GroupActivityFirstSeen extends GroupActivityBase {
  275. data: Record<string, any>;
  276. type: GroupActivityType.FIRST_SEEN;
  277. }
  278. interface GroupActivityMarkReviewed extends GroupActivityBase {
  279. data: Record<string, any>;
  280. type: GroupActivityType.MARK_REVIEWED;
  281. }
  282. interface GroupActivityRegression extends GroupActivityBase {
  283. data: {
  284. version?: string;
  285. };
  286. type: GroupActivityType.SET_REGRESSION;
  287. }
  288. export interface GroupActivitySetByResolvedInRelease extends GroupActivityBase {
  289. data: {
  290. current_release_version?: string;
  291. version?: string;
  292. };
  293. type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
  294. }
  295. interface GroupActivitySetByResolvedInCommit extends GroupActivityBase {
  296. data: {
  297. commit?: Commit;
  298. };
  299. type: GroupActivityType.SET_RESOLVED_IN_COMMIT;
  300. }
  301. interface GroupActivitySetByResolvedInPullRequest extends GroupActivityBase {
  302. data: {
  303. pullRequest?: PullRequest;
  304. };
  305. type: GroupActivityType.SET_RESOLVED_IN_PULL_REQUEST;
  306. }
  307. export interface GroupActivitySetIgnored extends GroupActivityBase {
  308. data: {
  309. ignoreCount?: number;
  310. ignoreDuration?: number;
  311. ignoreUntil?: string;
  312. /** Archived until escalating */
  313. ignoreUntilEscalating?: boolean;
  314. ignoreUserCount?: number;
  315. ignoreUserWindow?: number;
  316. ignoreWindow?: number;
  317. };
  318. type: GroupActivityType.SET_IGNORED;
  319. }
  320. export interface GroupActivityReprocess extends GroupActivityBase {
  321. data: {
  322. eventCount: number;
  323. newGroupId: number;
  324. oldGroupId: number;
  325. };
  326. type: GroupActivityType.REPROCESS;
  327. }
  328. interface GroupActivityUnmergeDestination extends GroupActivityBase {
  329. data: {
  330. fingerprints: Array<string>;
  331. source?: {
  332. id: string;
  333. shortId: string;
  334. };
  335. };
  336. type: GroupActivityType.UNMERGE_DESTINATION;
  337. }
  338. interface GroupActivityUnmergeSource extends GroupActivityBase {
  339. data: {
  340. fingerprints: Array<string>;
  341. destination?: {
  342. id: string;
  343. shortId: string;
  344. };
  345. };
  346. type: GroupActivityType.UNMERGE_SOURCE;
  347. }
  348. interface GroupActivityMerge extends GroupActivityBase {
  349. data: {
  350. issues: Array<any>;
  351. };
  352. type: GroupActivityType.MERGE;
  353. }
  354. export interface GroupActivityAssigned extends GroupActivityBase {
  355. data: {
  356. assignee: string;
  357. assigneeType: string;
  358. user: Team | User;
  359. assigneeEmail?: string;
  360. /**
  361. * If the user was assigned via an integration
  362. */
  363. integration?: 'projectOwnership' | 'codeowners' | 'slack' | 'msteams';
  364. /** Codeowner or Project owner rule as a string */
  365. rule?: string;
  366. };
  367. type: GroupActivityType.ASSIGNED;
  368. }
  369. export interface GroupActivityCreateIssue extends GroupActivityBase {
  370. data: {
  371. location: string;
  372. provider: string;
  373. title: string;
  374. };
  375. type: GroupActivityType.CREATE_ISSUE;
  376. }
  377. export type GroupActivity =
  378. | GroupActivityNote
  379. | GroupActivitySetResolved
  380. | GroupActivitySetUnresolved
  381. | GroupActivitySetIgnored
  382. | GroupActivitySetByAge
  383. | GroupActivitySetByResolvedInRelease
  384. | GroupActivitySetByResolvedInCommit
  385. | GroupActivitySetByResolvedInPullRequest
  386. | GroupActivityFirstSeen
  387. | GroupActivityMerge
  388. | GroupActivityReprocess
  389. | GroupActivityUnassigned
  390. | GroupActivityMarkReviewed
  391. | GroupActivityUnmergeDestination
  392. | GroupActivitySetPublic
  393. | GroupActivitySetPrivate
  394. | GroupActivityRegression
  395. | GroupActivityUnmergeSource
  396. | GroupActivityAssigned
  397. | GroupActivityCreateIssue;
  398. export type Activity = GroupActivity;
  399. interface GroupFiltered {
  400. count: string;
  401. firstSeen: string;
  402. lastSeen: string;
  403. stats: Record<string, TimeseriesValue[]>;
  404. userCount: number;
  405. }
  406. export interface GroupStats extends GroupFiltered {
  407. filtered: GroupFiltered | null;
  408. id: string;
  409. // for issue alert previews, the last time a group triggered a rule
  410. lastTriggered?: string;
  411. lifetime?: GroupFiltered;
  412. sessionCount?: string | null;
  413. }
  414. export interface BaseGroupStatusReprocessing {
  415. status: 'reprocessing';
  416. statusDetails: {
  417. info: {
  418. dateCreated: string;
  419. totalEvents: number;
  420. } | null;
  421. pendingEvents: number;
  422. };
  423. }
  424. /**
  425. * Issue Resolution
  426. */
  427. export enum ResolutionStatus {
  428. RESOLVED = 'resolved',
  429. UNRESOLVED = 'unresolved',
  430. IGNORED = 'ignored',
  431. }
  432. export type ResolutionStatusDetails = {
  433. actor?: AvatarUser;
  434. autoResolved?: boolean;
  435. ignoreCount?: number;
  436. // Sent in requests. ignoreUntil is used in responses.
  437. ignoreDuration?: number;
  438. ignoreUntil?: string;
  439. ignoreUntilEscalating?: boolean;
  440. ignoreUserCount?: number;
  441. ignoreUserWindow?: number;
  442. ignoreWindow?: number;
  443. inCommit?: {
  444. commit?: string;
  445. dateCreated?: string;
  446. id?: string;
  447. repository?: string | Repository;
  448. };
  449. inNextRelease?: boolean;
  450. inRelease?: string;
  451. repository?: string;
  452. };
  453. export type GroupStatusResolution = {
  454. status: ResolutionStatus;
  455. statusDetails: ResolutionStatusDetails;
  456. substatus?: 'until_escalating';
  457. };
  458. export type GroupRelease = {
  459. firstRelease: Release;
  460. lastRelease: Release;
  461. };
  462. // TODO(ts): incomplete
  463. export interface BaseGroup extends GroupRelease {
  464. activity: GroupActivity[];
  465. annotations: string[];
  466. assignedTo: Actor;
  467. culprit: string;
  468. firstSeen: string;
  469. hasSeen: boolean;
  470. id: string;
  471. isBookmarked: boolean;
  472. isPublic: boolean;
  473. isSubscribed: boolean;
  474. isUnhandled: boolean;
  475. issueCategory: IssueCategory;
  476. issueType: IssueType;
  477. lastSeen: string;
  478. latestEvent: Event;
  479. level: Level;
  480. logger: string;
  481. metadata: EventMetadata;
  482. numComments: number;
  483. participants: User[];
  484. permalink: string;
  485. platform: PlatformKey;
  486. pluginActions: any[]; // TODO(ts)
  487. pluginContexts: any[]; // TODO(ts)
  488. pluginIssues: any[]; // TODO(ts)
  489. project: Project;
  490. seenBy: User[];
  491. shareId: string;
  492. shortId: string;
  493. status: string;
  494. subscriptionDetails: {disabled?: boolean; reason?: string} | null;
  495. title: string;
  496. type: EventOrGroupType;
  497. userReportCount: number;
  498. inbox?: InboxDetails | null | false;
  499. owners?: SuggestedOwner[] | null;
  500. substatus?: GroupSubstatus;
  501. }
  502. export interface GroupReprocessing
  503. // BaseGroupStatusReprocessing status field (enum) incorrectly extends the BaseGroup status field (string) so we omit it.
  504. // A proper fix for this would be to make the status field an enum or string and correctly extend it.
  505. extends Omit<BaseGroup, 'status'>,
  506. GroupStats,
  507. BaseGroupStatusReprocessing {}
  508. export interface GroupResolution
  509. // GroupStatusResolution status field (enum) incorrectly extends the BaseGroup status field (string) so we omit it.
  510. // A proper fix for this would be to make the status field an enum or string and correctly extend it.
  511. extends Omit<BaseGroup, 'status'>,
  512. GroupStats,
  513. Omit<GroupStatusResolution, 'substatus'> {}
  514. export type Group = GroupResolution | GroupReprocessing;
  515. export interface GroupCollapseRelease
  516. extends Omit<Group, keyof GroupRelease>,
  517. Partial<GroupRelease> {}
  518. export type GroupTombstone = {
  519. actor: AvatarUser;
  520. culprit: string;
  521. id: string;
  522. level: Level;
  523. metadata: EventMetadata;
  524. title: string;
  525. };
  526. export type ProcessingIssueItem = {
  527. checksum: string;
  528. data: {
  529. // TODO(ts) This type is likely incomplete, but this is what
  530. // project processing issues settings uses.
  531. _scope: string;
  532. image_arch: string;
  533. image_path: string;
  534. image_uuid: string;
  535. dist?: string;
  536. release?: string;
  537. };
  538. id: string;
  539. lastSeen: string;
  540. numEvents: number;
  541. type: string;
  542. };
  543. export type ProcessingIssue = {
  544. hasIssues: boolean;
  545. hasMoreResolveableIssues: boolean;
  546. issuesProcessing: number;
  547. lastSeen: string;
  548. numIssues: number;
  549. project: string;
  550. resolveableIssues: number;
  551. signedLink: string;
  552. issues?: ProcessingIssueItem[];
  553. };
  554. /**
  555. * Datascrubbing
  556. */
  557. export type Meta = {
  558. chunks: Array<ChunkType>;
  559. err: Array<MetaError>;
  560. len: number;
  561. rem: Array<MetaRemark>;
  562. };
  563. export type MetaError = string | [string, any];
  564. export type MetaRemark = Array<string | number>;
  565. export type ChunkType = {
  566. rule_id: string | number;
  567. text: string;
  568. type: string;
  569. remark?: string | number;
  570. };
  571. /**
  572. * User Feedback
  573. */
  574. export type UserReport = {
  575. comments: string;
  576. dateCreated: string;
  577. email: string;
  578. event: {eventID: string; id: string};
  579. eventID: string;
  580. id: string;
  581. issue: Group;
  582. name: string;
  583. user: User;
  584. };
  585. export type KeyValueListDataItem = {
  586. key: string;
  587. subject: string;
  588. actionButton?: React.ReactNode;
  589. isContextData?: boolean;
  590. isMultiValue?: boolean;
  591. meta?: Meta;
  592. subjectDataTestId?: string;
  593. subjectIcon?: React.ReactNode;
  594. value?: React.ReactNode;
  595. };
  596. export type KeyValueListData = KeyValueListDataItem[];
  597. // Response from ShortIdLookupEndpoint
  598. // /organizations/${orgId}/shortids/${query}/
  599. export type ShortIdResponse = {
  600. group: Group;
  601. groupId: string;
  602. organizationSlug: string;
  603. projectSlug: string;
  604. shortId: string;
  605. };
  606. /**
  607. * Note used in Group Activity and Alerts for users to comment
  608. */
  609. export type Note = {
  610. /**
  611. * Array of [id, display string] tuples used for @-mentions
  612. */
  613. mentions: [string, string][];
  614. /**
  615. * Note contents (markdown allowed)
  616. */
  617. text: string;
  618. };