group.tsx 25 KB

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