group.tsx 25 KB

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