group.tsx 15 KB

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