group.tsx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. import type {LocationDescriptor} from 'history';
  2. import type {TitledPlugin} from 'sentry/components/group/pluginActions';
  3. import type {SearchGroup} from 'sentry/components/smartSearchBar/types';
  4. import type {FieldKind} from 'sentry/utils/fields';
  5. import type {Actor, TimeseriesValue} from './core';
  6. import type {Event, EventMetadata, EventOrGroupType, Level} from './event';
  7. import type {
  8. Commit,
  9. ExternalIssue,
  10. PlatformExternalIssue,
  11. PullRequest,
  12. Repository,
  13. } from './integrations';
  14. import type {Team} from './organization';
  15. import type {PlatformKey, Project} from './project';
  16. import type {AvatarUser, User} from './user';
  17. export type EntryData = Record<string, any | Array<any>>;
  18. /**
  19. * Saved issues searches
  20. */
  21. export type RecentSearch = {
  22. dateCreated: string;
  23. id: string;
  24. lastSeen: string;
  25. organizationId: string;
  26. query: string;
  27. type: SavedSearchType;
  28. };
  29. // XXX: Deprecated Sentry 9 attributes are not included here.
  30. export type SavedSearch = {
  31. dateCreated: string;
  32. id: string;
  33. isGlobal: boolean;
  34. isPinned: boolean;
  35. name: string;
  36. query: string;
  37. sort: string;
  38. type: SavedSearchType;
  39. visibility: SavedSearchVisibility;
  40. };
  41. export enum SavedSearchVisibility {
  42. ORGANIZATION = 'organization',
  43. OWNER = 'owner',
  44. OWNER_PINNED = 'owner_pinned',
  45. }
  46. export enum SavedSearchType {
  47. ISSUE = 0,
  48. EVENT = 1,
  49. SESSION = 2,
  50. REPLAY = 3,
  51. METRIC = 4,
  52. }
  53. export enum IssueCategory {
  54. PERFORMANCE = 'performance',
  55. ERROR = 'error',
  56. CRON = 'cron',
  57. PROFILE = 'profile',
  58. REPLAY = 'replay',
  59. }
  60. export enum IssueType {
  61. // Error
  62. ERROR = 'error',
  63. // Performance
  64. PERFORMANCE_CONSECUTIVE_DB_QUERIES = 'performance_consecutive_db_queries',
  65. PERFORMANCE_CONSECUTIVE_HTTP = 'performance_consecutive_http',
  66. PERFORMANCE_FILE_IO_MAIN_THREAD = 'performance_file_io_main_thread',
  67. PERFORMANCE_DB_MAIN_THREAD = 'performance_db_main_thread',
  68. PERFORMANCE_N_PLUS_ONE_API_CALLS = 'performance_n_plus_one_api_calls',
  69. PERFORMANCE_N_PLUS_ONE_DB_QUERIES = 'performance_n_plus_one_db_queries',
  70. PERFORMANCE_SLOW_DB_QUERY = 'performance_slow_db_query',
  71. PERFORMANCE_RENDER_BLOCKING_ASSET = 'performance_render_blocking_asset_span',
  72. PERFORMANCE_UNCOMPRESSED_ASSET = 'performance_uncompressed_assets',
  73. PERFORMANCE_LARGE_HTTP_PAYLOAD = 'performance_large_http_payload',
  74. PERFORMANCE_HTTP_OVERHEAD = 'performance_http_overhead',
  75. PERFORMANCE_DURATION_REGRESSION = 'performance_duration_regression',
  76. PERFORMANCE_ENDPOINT_REGRESSION = 'performance_p95_endpoint_regression',
  77. // Profile
  78. PROFILE_FILE_IO_MAIN_THREAD = 'profile_file_io_main_thread',
  79. PROFILE_IMAGE_DECODE_MAIN_THREAD = 'profile_image_decode_main_thread',
  80. PROFILE_JSON_DECODE_MAIN_THREAD = 'profile_json_decode_main_thread',
  81. PROFILE_REGEX_MAIN_THREAD = 'profile_regex_main_thread',
  82. PROFILE_FRAME_DROP = 'profile_frame_drop',
  83. PROFILE_FRAME_DROP_EXPERIMENTAL = 'profile_frame_drop_experimental',
  84. PROFILE_FUNCTION_REGRESSION = 'profile_function_regression',
  85. PROFILE_FUNCTION_REGRESSION_EXPERIMENTAL = 'profile_function_regression_exp',
  86. // Replay
  87. REPLAY_RAGE_CLICK = 'replay_click_rage',
  88. REPLAY_HYDRATION_ERROR = 'replay_hydration_error',
  89. }
  90. export enum IssueTitle {
  91. // Performance
  92. PERFORMANCE_CONSECUTIVE_DB_QUERIES = 'Consecutive DB Queries',
  93. PERFORMANCE_CONSECUTIVE_HTTP = 'Consecutive HTTP',
  94. PERFORMANCE_FILE_IO_MAIN_THREAD = 'File IO on Main Thread',
  95. PERFORMANCE_DB_MAIN_THREAD = 'DB on Main Thread',
  96. PERFORMANCE_N_PLUS_ONE_API_CALLS = 'N+1 API Call',
  97. PERFORMANCE_N_PLUS_ONE_DB_QUERIES = 'N+1 Query',
  98. PERFORMANCE_SLOW_DB_QUERY = 'Slow DB Query',
  99. PERFORMANCE_RENDER_BLOCKING_ASSET = 'Large Render Blocking Asset',
  100. PERFORMANCE_UNCOMPRESSED_ASSET = 'Uncompressed Asset',
  101. PERFORMANCE_LARGE_HTTP_PAYLOAD = 'Large HTTP payload',
  102. PERFORMANCE_HTTP_OVERHEAD = 'HTTP/1.1 Overhead',
  103. PERFORMANCE_DURATION_REGRESSION = 'Duration Regression',
  104. PERFORMANCE_ENDPOINT_REGRESSION = 'Endpoint Regression',
  105. // Profile
  106. PROFILE_FILE_IO_MAIN_THREAD = 'File I/O on Main Thread',
  107. PROFILE_IMAGE_DECODE_MAIN_THREAD = 'Image Decoding on Main Thread',
  108. PROFILE_JSON_DECODE_MAIN_THREAD = 'JSON Decoding on Main Thread',
  109. PROFILE_REGEX_MAIN_THREAD = 'Regex on Main Thread',
  110. PROFILE_FRAME_DROP = 'Frame Drop',
  111. PROFILE_FRAME_DROP_EXPERIMENTAL = 'Frame Drop',
  112. PROFILE_FUNCTION_REGRESSION = 'Function Regression',
  113. PROFILE_FUNCTION_REGRESSION_EXPERIMENTAL = 'Function Duration Regression (Experimental)',
  114. // Replay
  115. REPLAY_RAGE_CLICK = 'Rage Click Detected',
  116. REPLAY_HYDRATION_ERROR = 'Hydration Error Detected',
  117. }
  118. const ISSUE_TYPE_TO_ISSUE_TITLE = {
  119. performance_consecutive_db_queries: IssueTitle.PERFORMANCE_CONSECUTIVE_DB_QUERIES,
  120. performance_consecutive_http: IssueTitle.PERFORMANCE_CONSECUTIVE_HTTP,
  121. performance_file_io_main_thread: IssueTitle.PERFORMANCE_FILE_IO_MAIN_THREAD,
  122. performance_db_main_thread: IssueTitle.PERFORMANCE_DB_MAIN_THREAD,
  123. performance_n_plus_one_api_calls: IssueTitle.PERFORMANCE_N_PLUS_ONE_API_CALLS,
  124. performance_n_plus_one_db_queries: IssueTitle.PERFORMANCE_N_PLUS_ONE_DB_QUERIES,
  125. performance_slow_db_query: IssueTitle.PERFORMANCE_SLOW_DB_QUERY,
  126. performance_render_blocking_asset_span: IssueTitle.PERFORMANCE_RENDER_BLOCKING_ASSET,
  127. performance_uncompressed_assets: IssueTitle.PERFORMANCE_UNCOMPRESSED_ASSET,
  128. performance_large_http_payload: IssueTitle.PERFORMANCE_LARGE_HTTP_PAYLOAD,
  129. performance_http_overhead: IssueTitle.PERFORMANCE_HTTP_OVERHEAD,
  130. performance_duration_regression: IssueTitle.PERFORMANCE_DURATION_REGRESSION,
  131. performance_p95_endpoint_regression: IssueTitle.PERFORMANCE_ENDPOINT_REGRESSION,
  132. profile_file_io_main_thread: IssueTitle.PROFILE_FILE_IO_MAIN_THREAD,
  133. profile_image_decode_main_thread: IssueTitle.PROFILE_IMAGE_DECODE_MAIN_THREAD,
  134. profile_json_decode_main_thread: IssueTitle.PROFILE_JSON_DECODE_MAIN_THREAD,
  135. profile_regex_main_thread: IssueTitle.PROFILE_REGEX_MAIN_THREAD,
  136. profile_frame_drop: IssueTitle.PROFILE_FRAME_DROP,
  137. profile_frame_drop_experimental: IssueTitle.PROFILE_FRAME_DROP_EXPERIMENTAL,
  138. profile_function_regression: IssueTitle.PROFILE_FUNCTION_REGRESSION,
  139. profile_function_regression_exp: IssueTitle.PROFILE_FUNCTION_REGRESSION_EXPERIMENTAL,
  140. replay_click_rage: IssueTitle.REPLAY_RAGE_CLICK,
  141. replay_hydration_error: IssueTitle.REPLAY_HYDRATION_ERROR,
  142. };
  143. export function getIssueTitleFromType(issueType: string): IssueTitle | undefined {
  144. if (issueType in ISSUE_TYPE_TO_ISSUE_TITLE) {
  145. return ISSUE_TYPE_TO_ISSUE_TITLE[issueType];
  146. }
  147. return undefined;
  148. }
  149. const OCCURRENCE_TYPE_TO_ISSUE_TYPE = {
  150. 1001: IssueType.PERFORMANCE_SLOW_DB_QUERY,
  151. 1004: IssueType.PERFORMANCE_RENDER_BLOCKING_ASSET,
  152. 1006: IssueType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES,
  153. 1007: IssueType.PERFORMANCE_CONSECUTIVE_DB_QUERIES,
  154. 1008: IssueType.PERFORMANCE_FILE_IO_MAIN_THREAD,
  155. 1009: IssueType.PERFORMANCE_CONSECUTIVE_HTTP,
  156. 1010: IssueType.PERFORMANCE_N_PLUS_ONE_API_CALLS,
  157. 1012: IssueType.PERFORMANCE_UNCOMPRESSED_ASSET,
  158. 1013: IssueType.PERFORMANCE_DB_MAIN_THREAD,
  159. 1015: IssueType.PERFORMANCE_LARGE_HTTP_PAYLOAD,
  160. 1016: IssueType.PERFORMANCE_HTTP_OVERHEAD,
  161. 1017: IssueType.PERFORMANCE_DURATION_REGRESSION,
  162. 1018: IssueType.PERFORMANCE_ENDPOINT_REGRESSION,
  163. 2001: IssueType.PROFILE_FILE_IO_MAIN_THREAD,
  164. 2002: IssueType.PROFILE_IMAGE_DECODE_MAIN_THREAD,
  165. 2003: IssueType.PROFILE_JSON_DECODE_MAIN_THREAD,
  166. 2007: IssueType.PROFILE_REGEX_MAIN_THREAD,
  167. 2008: IssueType.PROFILE_FRAME_DROP,
  168. 2009: IssueType.PROFILE_FRAME_DROP_EXPERIMENTAL,
  169. 2010: IssueType.PROFILE_FUNCTION_REGRESSION,
  170. 2011: IssueType.PROFILE_FUNCTION_REGRESSION_EXPERIMENTAL,
  171. };
  172. const PERFORMANCE_REGRESSION_TYPE_IDS = new Set([1017, 1018, 2010, 2011]);
  173. export function getIssueTypeFromOccurrenceType(
  174. typeId: number | undefined
  175. ): IssueType | null {
  176. if (!typeId) {
  177. return null;
  178. }
  179. return OCCURRENCE_TYPE_TO_ISSUE_TYPE[typeId] ?? null;
  180. }
  181. export function isTransactionBased(typeId: number | undefined): boolean {
  182. if (!typeId) {
  183. return false;
  184. }
  185. // the 1xxx type ids are transaction based performance issues
  186. return typeId >= 1000 && typeId < 2000;
  187. }
  188. export function isOccurrenceBased(typeId: number | undefined): boolean {
  189. if (!typeId) {
  190. return false;
  191. }
  192. // these are regression type performance issues
  193. return !PERFORMANCE_REGRESSION_TYPE_IDS.has(typeId);
  194. }
  195. // endpoint: /api/0/issues/:issueId/attachments/?limit=50
  196. export type IssueAttachment = {
  197. dateCreated: string;
  198. event_id: string;
  199. headers: object;
  200. id: string;
  201. mimetype: string;
  202. name: string;
  203. sha1: string;
  204. size: number;
  205. type: string;
  206. };
  207. // endpoint: /api/0/projects/:orgSlug/:projSlug/events/:eventId/attachments/
  208. export type EventAttachment = IssueAttachment;
  209. /**
  210. * Issue Tags
  211. */
  212. export type Tag = {
  213. key: string;
  214. name: string;
  215. alias?: string;
  216. isInput?: boolean;
  217. kind?: FieldKind;
  218. /**
  219. * How many values should be suggested in autocomplete.
  220. * Overrides SmartSearchBar's `maxSearchItems` prop.
  221. */
  222. maxSuggestedValues?: number;
  223. predefined?: boolean;
  224. totalValues?: number;
  225. /**
  226. * Usually values are strings, but a predefined tag can define its SearchGroups
  227. */
  228. values?: string[] | SearchGroup[];
  229. };
  230. export type TagCollection = Record<string, Tag>;
  231. export type TagValue = {
  232. count: number;
  233. firstSeen: string;
  234. lastSeen: string;
  235. name: string;
  236. value: string;
  237. email?: string;
  238. identifier?: string;
  239. ipAddress?: string;
  240. key?: string;
  241. query?: string;
  242. username?: string;
  243. } & AvatarUser;
  244. type Topvalue = {
  245. count: number;
  246. firstSeen: string;
  247. key: string;
  248. lastSeen: string;
  249. name: string;
  250. value: string;
  251. // Might not actually exist.
  252. query?: string;
  253. readable?: string;
  254. };
  255. export type TagWithTopValues = {
  256. key: string;
  257. name: string;
  258. topValues: Array<Topvalue>;
  259. totalValues: number;
  260. uniqueValues: number;
  261. canDelete?: boolean;
  262. };
  263. /**
  264. * Inbox, issue owners and Activity
  265. */
  266. export type InboxReasonDetails = {
  267. count?: number | null;
  268. until?: string | null;
  269. user_count?: number | null;
  270. user_window?: number | null;
  271. window?: number | null;
  272. };
  273. export const enum GroupInboxReason {
  274. NEW = 0,
  275. UNIGNORED = 1,
  276. REGRESSION = 2,
  277. MANUAL = 3,
  278. REPROCESSED = 4,
  279. ESCALATING = 5,
  280. ONGOING = 6,
  281. }
  282. export type InboxDetails = {
  283. date_added?: string;
  284. reason?: GroupInboxReason;
  285. reason_details?: InboxReasonDetails | null;
  286. };
  287. export type SuggestedOwnerReason =
  288. | 'suspectCommit'
  289. | 'ownershipRule'
  290. | 'projectOwnership'
  291. // TODO: codeowners may no longer exist
  292. | 'codeowners';
  293. // Received from the backend to denote suggested owners of an issue
  294. export type SuggestedOwner = {
  295. date_added: string;
  296. owner: string;
  297. type: SuggestedOwnerReason;
  298. };
  299. export interface ParsedOwnershipRule {
  300. matcher: {pattern: string; type: string};
  301. owners: Actor[];
  302. }
  303. export type IssueOwnership = {
  304. autoAssignment:
  305. | 'Auto Assign to Suspect Commits'
  306. | 'Auto Assign to Issue Owner'
  307. | 'Turn off Auto-Assignment';
  308. codeownersAutoSync: boolean;
  309. dateCreated: string | null;
  310. fallthrough: boolean;
  311. isActive: boolean;
  312. lastUpdated: string | null;
  313. raw: string | null;
  314. schema?: {rules: ParsedOwnershipRule[]; version: number};
  315. };
  316. export enum GroupActivityType {
  317. NOTE = 'note',
  318. SET_RESOLVED = 'set_resolved',
  319. SET_RESOLVED_BY_AGE = 'set_resolved_by_age',
  320. SET_RESOLVED_IN_RELEASE = 'set_resolved_in_release',
  321. SET_RESOLVED_IN_COMMIT = 'set_resolved_in_commit',
  322. SET_RESOLVED_IN_PULL_REQUEST = 'set_resolved_in_pull_request',
  323. SET_UNRESOLVED = 'set_unresolved',
  324. SET_IGNORED = 'set_ignored',
  325. SET_PUBLIC = 'set_public',
  326. SET_PRIVATE = 'set_private',
  327. SET_REGRESSION = 'set_regression',
  328. CREATE_ISSUE = 'create_issue',
  329. UNMERGE_SOURCE = 'unmerge_source',
  330. UNMERGE_DESTINATION = 'unmerge_destination',
  331. FIRST_SEEN = 'first_seen',
  332. ASSIGNED = 'assigned',
  333. UNASSIGNED = 'unassigned',
  334. MERGE = 'merge',
  335. REPROCESS = 'reprocess',
  336. MARK_REVIEWED = 'mark_reviewed',
  337. AUTO_SET_ONGOING = 'auto_set_ongoing',
  338. SET_ESCALATING = 'set_escalating',
  339. SET_PRIORITY = 'set_priority',
  340. DELETED_ATTACHMENT = 'deleted_attachment',
  341. }
  342. interface GroupActivityBase {
  343. dateCreated: string;
  344. id: string;
  345. project: Project;
  346. assignee?: string;
  347. issue?: Group;
  348. user?: null | User;
  349. }
  350. export interface GroupActivityNote extends GroupActivityBase {
  351. data: {
  352. text: string;
  353. };
  354. type: GroupActivityType.NOTE;
  355. }
  356. interface GroupActivitySetResolved extends GroupActivityBase {
  357. data: {};
  358. type: GroupActivityType.SET_RESOLVED;
  359. }
  360. /**
  361. * An integration marks an issue as resolved
  362. */
  363. interface GroupActivitySetResolvedIntegration extends GroupActivityBase {
  364. data: {
  365. integration_id: number;
  366. /**
  367. * Human readable name of the integration
  368. */
  369. provider: string;
  370. /**
  371. * The key of the integration
  372. */
  373. provider_key: string;
  374. };
  375. type: GroupActivityType.SET_RESOLVED;
  376. }
  377. interface GroupActivitySetUnresolved extends GroupActivityBase {
  378. data: {};
  379. type: GroupActivityType.SET_UNRESOLVED;
  380. }
  381. interface GroupActivitySetUnresolvedForecast extends GroupActivityBase {
  382. data: {
  383. forecast: number;
  384. };
  385. type: GroupActivityType.SET_UNRESOLVED;
  386. }
  387. /**
  388. * An integration marks an issue as unresolved
  389. */
  390. interface GroupActivitySetUnresolvedIntegration extends GroupActivityBase {
  391. data: {
  392. integration_id: number;
  393. /**
  394. * Human readable name of the integration
  395. */
  396. provider: string;
  397. /**
  398. * The key of the integration
  399. */
  400. provider_key: string;
  401. };
  402. type: GroupActivityType.SET_UNRESOLVED;
  403. }
  404. interface GroupActivitySetPublic extends GroupActivityBase {
  405. data: Record<string, any>;
  406. type: GroupActivityType.SET_PUBLIC;
  407. }
  408. interface GroupActivitySetPrivate extends GroupActivityBase {
  409. data: Record<string, any>;
  410. type: GroupActivityType.SET_PRIVATE;
  411. }
  412. interface GroupActivitySetByAge extends GroupActivityBase {
  413. data: Record<string, any>;
  414. type: GroupActivityType.SET_RESOLVED_BY_AGE;
  415. }
  416. interface GroupActivityUnassigned extends GroupActivityBase {
  417. data: Record<string, any>;
  418. type: GroupActivityType.UNASSIGNED;
  419. }
  420. interface GroupActivityFirstSeen extends GroupActivityBase {
  421. data: Record<string, any>;
  422. type: GroupActivityType.FIRST_SEEN;
  423. }
  424. interface GroupActivityMarkReviewed extends GroupActivityBase {
  425. data: Record<string, any>;
  426. type: GroupActivityType.MARK_REVIEWED;
  427. }
  428. interface GroupActivityRegression extends GroupActivityBase {
  429. data: {
  430. /**
  431. * True if the project is using semver to decide if the event is a regression.
  432. * Available when the issue was resolved in a release.
  433. */
  434. follows_semver?: boolean;
  435. /**
  436. * The version that the issue was previously resolved in.
  437. * Available when the issue was resolved in a release.
  438. */
  439. resolved_in_version?: string;
  440. version?: string;
  441. };
  442. type: GroupActivityType.SET_REGRESSION;
  443. }
  444. export interface GroupActivitySetByResolvedInNextSemverRelease extends GroupActivityBase {
  445. data: {
  446. // Set for semver releases
  447. current_release_version: string;
  448. };
  449. type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
  450. }
  451. export interface GroupActivitySetByResolvedInRelease extends GroupActivityBase {
  452. data: {
  453. version?: string;
  454. };
  455. type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
  456. }
  457. interface GroupActivitySetByResolvedInCommit extends GroupActivityBase {
  458. data: {
  459. commit?: Commit;
  460. };
  461. type: GroupActivityType.SET_RESOLVED_IN_COMMIT;
  462. }
  463. interface GroupActivitySetByResolvedInPullRequest extends GroupActivityBase {
  464. data: {
  465. pullRequest?: PullRequest;
  466. };
  467. type: GroupActivityType.SET_RESOLVED_IN_PULL_REQUEST;
  468. }
  469. export interface GroupActivitySetIgnored extends GroupActivityBase {
  470. data: {
  471. ignoreCount?: number;
  472. ignoreDuration?: number;
  473. ignoreUntil?: string;
  474. /** Archived until escalating */
  475. ignoreUntilEscalating?: boolean;
  476. ignoreUserCount?: number;
  477. ignoreUserWindow?: number;
  478. ignoreWindow?: number;
  479. };
  480. type: GroupActivityType.SET_IGNORED;
  481. }
  482. export interface GroupActivityReprocess extends GroupActivityBase {
  483. data: {
  484. eventCount: number;
  485. newGroupId: number;
  486. oldGroupId: number;
  487. };
  488. type: GroupActivityType.REPROCESS;
  489. }
  490. interface GroupActivityUnmergeDestination extends GroupActivityBase {
  491. data: {
  492. fingerprints: Array<string>;
  493. source?: {
  494. id: string;
  495. shortId: string;
  496. };
  497. };
  498. type: GroupActivityType.UNMERGE_DESTINATION;
  499. }
  500. interface GroupActivityUnmergeSource extends GroupActivityBase {
  501. data: {
  502. fingerprints: Array<string>;
  503. destination?: {
  504. id: string;
  505. shortId: string;
  506. };
  507. };
  508. type: GroupActivityType.UNMERGE_SOURCE;
  509. }
  510. interface GroupActivityMerge extends GroupActivityBase {
  511. data: {
  512. issues: Array<any>;
  513. };
  514. type: GroupActivityType.MERGE;
  515. }
  516. interface GroupActivityAutoSetOngoing extends GroupActivityBase {
  517. data: {
  518. afterDays?: number;
  519. };
  520. type: GroupActivityType.AUTO_SET_ONGOING;
  521. }
  522. export interface GroupActivitySetEscalating extends GroupActivityBase {
  523. data: {
  524. expired_snooze?: {
  525. count: number | null;
  526. until: Date | null;
  527. user_count: number | null;
  528. user_window: number | null;
  529. window: number | null;
  530. };
  531. forecast?: number;
  532. };
  533. type: GroupActivityType.SET_ESCALATING;
  534. }
  535. export interface GroupActivitySetPriority extends GroupActivityBase {
  536. data: {
  537. priority: PriorityLevel;
  538. reason: string;
  539. };
  540. type: GroupActivityType.SET_PRIORITY;
  541. }
  542. export interface GroupActivityAssigned extends GroupActivityBase {
  543. data: {
  544. assignee: string;
  545. assigneeType: string;
  546. user: Team | User;
  547. assigneeEmail?: string;
  548. /**
  549. * If the user was assigned via an integration
  550. */
  551. integration?:
  552. | 'projectOwnership'
  553. | 'codeowners'
  554. | 'slack'
  555. | 'msteams'
  556. | 'suspectCommitter';
  557. /** Codeowner or Project owner rule as a string */
  558. rule?: string;
  559. };
  560. type: GroupActivityType.ASSIGNED;
  561. }
  562. export interface GroupActivityCreateIssue extends GroupActivityBase {
  563. data: {
  564. location: string;
  565. provider: string;
  566. title: string;
  567. };
  568. type: GroupActivityType.CREATE_ISSUE;
  569. }
  570. interface GroupActivityDeletedAttachment extends GroupActivityBase {
  571. data: {};
  572. type: GroupActivityType.DELETED_ATTACHMENT;
  573. }
  574. export type GroupActivity =
  575. | GroupActivityNote
  576. | GroupActivitySetResolved
  577. | GroupActivitySetResolvedIntegration
  578. | GroupActivitySetUnresolved
  579. | GroupActivitySetUnresolvedForecast
  580. | GroupActivitySetUnresolvedIntegration
  581. | GroupActivitySetIgnored
  582. | GroupActivitySetByAge
  583. | GroupActivitySetByResolvedInRelease
  584. | GroupActivitySetByResolvedInNextSemverRelease
  585. | GroupActivitySetByResolvedInCommit
  586. | GroupActivitySetByResolvedInPullRequest
  587. | GroupActivityFirstSeen
  588. | GroupActivityMerge
  589. | GroupActivityReprocess
  590. | GroupActivityUnassigned
  591. | GroupActivityMarkReviewed
  592. | GroupActivityUnmergeDestination
  593. | GroupActivitySetPublic
  594. | GroupActivitySetPrivate
  595. | GroupActivityRegression
  596. | GroupActivityUnmergeSource
  597. | GroupActivityAssigned
  598. | GroupActivityCreateIssue
  599. | GroupActivityAutoSetOngoing
  600. | GroupActivitySetEscalating
  601. | GroupActivitySetPriority
  602. | GroupActivityDeletedAttachment;
  603. export type Activity = GroupActivity;
  604. interface GroupFiltered {
  605. count: string;
  606. firstSeen: string;
  607. lastSeen: string;
  608. stats: Record<string, TimeseriesValue[]>;
  609. userCount: number;
  610. }
  611. export interface GroupStats extends GroupFiltered {
  612. filtered: GroupFiltered | null;
  613. id: string;
  614. isUnhandled?: boolean;
  615. // for issue alert previews, the last time a group triggered a rule
  616. lastTriggered?: string;
  617. lifetime?: GroupFiltered;
  618. sessionCount?: string | null;
  619. }
  620. export interface IgnoredStatusDetails {
  621. actor?: AvatarUser;
  622. ignoreCount?: number;
  623. // Sent in requests. ignoreUntil is used in responses.
  624. ignoreDuration?: number;
  625. ignoreUntil?: string;
  626. ignoreUntilEscalating?: boolean;
  627. ignoreUserCount?: number;
  628. ignoreUserWindow?: number;
  629. ignoreWindow?: number;
  630. }
  631. export interface ResolvedStatusDetails {
  632. actor?: AvatarUser;
  633. autoResolved?: boolean;
  634. inCommit?: {
  635. commit?: string;
  636. dateCreated?: string;
  637. id?: string;
  638. repository?: string | Repository;
  639. };
  640. inNextRelease?: boolean;
  641. inRelease?: string;
  642. repository?: string;
  643. }
  644. interface ReprocessingStatusDetails {
  645. info: {
  646. dateCreated: string;
  647. totalEvents: number;
  648. } | null;
  649. pendingEvents: number;
  650. }
  651. export interface UserParticipant extends User {
  652. type: 'user';
  653. }
  654. export interface TeamParticipant extends Team {
  655. type: 'team';
  656. }
  657. /**
  658. * The payload sent when marking reviewed
  659. */
  660. export interface MarkReviewed {
  661. inbox: false;
  662. }
  663. /**
  664. * The payload sent when updating a group's status
  665. */
  666. export interface GroupStatusResolution {
  667. status: GroupStatus.RESOLVED | GroupStatus.UNRESOLVED | GroupStatus.IGNORED;
  668. statusDetails: ResolvedStatusDetails | IgnoredStatusDetails | {};
  669. substatus?: GroupSubstatus | null;
  670. }
  671. export const enum GroupStatus {
  672. RESOLVED = 'resolved',
  673. UNRESOLVED = 'unresolved',
  674. IGNORED = 'ignored',
  675. REPROCESSING = 'reprocessing',
  676. }
  677. export const enum GroupSubstatus {
  678. ARCHIVED_UNTIL_ESCALATING = 'archived_until_escalating',
  679. ARCHIVED_UNTIL_CONDITION_MET = 'archived_until_condition_met',
  680. ARCHIVED_FOREVER = 'archived_forever',
  681. ESCALATING = 'escalating',
  682. ONGOING = 'ongoing',
  683. REGRESSED = 'regressed',
  684. NEW = 'new',
  685. }
  686. export const enum PriorityLevel {
  687. HIGH = 'high',
  688. MEDIUM = 'medium',
  689. LOW = 'low',
  690. }
  691. // TODO(ts): incomplete
  692. export interface BaseGroup {
  693. activity: GroupActivity[];
  694. annotations: string[];
  695. assignedTo: Actor | null;
  696. culprit: string;
  697. firstSeen: string;
  698. hasSeen: boolean;
  699. id: string;
  700. isBookmarked: boolean;
  701. isPublic: boolean;
  702. isSubscribed: boolean;
  703. issueCategory: IssueCategory;
  704. issueType: IssueType;
  705. lastSeen: string;
  706. level: Level;
  707. logger: string | null;
  708. metadata: EventMetadata;
  709. numComments: number;
  710. participants: Array<UserParticipant | TeamParticipant>;
  711. permalink: string;
  712. platform: PlatformKey;
  713. pluginActions: TitledPlugin[];
  714. pluginContexts: any[]; // TODO(ts)
  715. pluginIssues: TitledPlugin[];
  716. priority: PriorityLevel;
  717. priorityLockedAt: string | null;
  718. project: Project;
  719. seenBy: User[];
  720. shareId: string;
  721. shortId: string;
  722. status: GroupStatus;
  723. statusDetails: IgnoredStatusDetails | ResolvedStatusDetails | ReprocessingStatusDetails;
  724. subscriptionDetails: {disabled?: boolean; reason?: string} | null;
  725. title: string;
  726. type: EventOrGroupType;
  727. userReportCount: number;
  728. inbox?: InboxDetails | null | false;
  729. integrationIssues?: ExternalIssue[];
  730. latestEvent?: Event;
  731. latestEventHasAttachments?: boolean;
  732. owners?: SuggestedOwner[] | null;
  733. sentryAppIssues?: PlatformExternalIssue[];
  734. substatus?: GroupSubstatus | null;
  735. }
  736. export interface GroupReprocessing extends BaseGroup, GroupStats {
  737. status: GroupStatus.REPROCESSING;
  738. statusDetails: ReprocessingStatusDetails;
  739. }
  740. export interface GroupResolved extends BaseGroup, GroupStats {
  741. status: GroupStatus.RESOLVED;
  742. statusDetails: ResolvedStatusDetails;
  743. }
  744. export interface GroupIgnored extends BaseGroup, GroupStats {
  745. status: GroupStatus.IGNORED;
  746. statusDetails: IgnoredStatusDetails;
  747. }
  748. export interface GroupUnresolved extends BaseGroup, GroupStats {
  749. status: GroupStatus.UNRESOLVED;
  750. statusDetails: {};
  751. }
  752. export type Group = GroupUnresolved | GroupResolved | GroupIgnored | GroupReprocessing;
  753. export interface GroupTombstone {
  754. actor: AvatarUser;
  755. culprit: string;
  756. id: string;
  757. level: Level;
  758. metadata: EventMetadata;
  759. type: EventOrGroupType;
  760. title?: string;
  761. }
  762. export interface GroupTombstoneHelper extends GroupTombstone {
  763. isTombstone: true;
  764. }
  765. export type ProcessingIssueItem = {
  766. checksum: string;
  767. data: {
  768. // TODO(ts) This type is likely incomplete, but this is what
  769. // project processing issues settings uses.
  770. _scope: string;
  771. image_arch: string;
  772. image_path: string;
  773. image_uuid: string;
  774. dist?: string;
  775. release?: string;
  776. };
  777. id: string;
  778. lastSeen: string;
  779. numEvents: number;
  780. type: string;
  781. };
  782. export type ProcessingIssue = {
  783. hasIssues: boolean;
  784. hasMoreResolveableIssues: boolean;
  785. issuesProcessing: number;
  786. lastSeen: string;
  787. numIssues: number;
  788. project: string;
  789. resolveableIssues: number;
  790. signedLink: string;
  791. issues?: ProcessingIssueItem[];
  792. };
  793. /**
  794. * Datascrubbing
  795. */
  796. export type Meta = {
  797. chunks: Array<ChunkType>;
  798. err: Array<MetaError>;
  799. len: number;
  800. rem: Array<MetaRemark>;
  801. };
  802. export type MetaError = string | [string, any];
  803. export type MetaRemark = Array<string | number>;
  804. export type ChunkType = {
  805. rule_id: string | number;
  806. text: string;
  807. type: string;
  808. remark?: string | number;
  809. };
  810. /**
  811. * Old User Feedback
  812. */
  813. export type UserReport = {
  814. comments: string;
  815. dateCreated: string;
  816. email: string;
  817. event: {eventID: string; id: string};
  818. eventID: string;
  819. id: string;
  820. issue: Group;
  821. name: string;
  822. user: User;
  823. };
  824. export type KeyValueListDataItem = {
  825. key: string;
  826. subject: string;
  827. action?: {
  828. link?: string | LocationDescriptor;
  829. };
  830. actionButton?: React.ReactNode;
  831. isContextData?: boolean;
  832. isMultiValue?: boolean;
  833. meta?: Meta;
  834. subjectDataTestId?: string;
  835. subjectIcon?: React.ReactNode;
  836. subjectNode?: React.ReactNode;
  837. value?: React.ReactNode | Record<string, string | number>;
  838. };
  839. export type KeyValueListData = KeyValueListDataItem[];
  840. // Response from ShortIdLookupEndpoint
  841. // /organizations/${orgId}/shortids/${query}/
  842. export type ShortIdResponse = {
  843. group: Group;
  844. groupId: string;
  845. organizationSlug: string;
  846. projectSlug: string;
  847. shortId: string;
  848. };
  849. /**
  850. * Note used in Group Activity and Alerts for users to comment
  851. */
  852. export type Note = {
  853. /**
  854. * Array of [id, display string] tuples used for @-mentions
  855. */
  856. mentions: [string, string][];
  857. /**
  858. * Note contents (markdown allowed)
  859. */
  860. text: string;
  861. };