group.tsx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  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. LAST_SEEN = 'last_seen',
  341. ASSIGNED = 'assigned',
  342. UNASSIGNED = 'unassigned',
  343. MERGE = 'merge',
  344. REPROCESS = 'reprocess',
  345. MARK_REVIEWED = 'mark_reviewed',
  346. AUTO_SET_ONGOING = 'auto_set_ongoing',
  347. SET_ESCALATING = 'set_escalating',
  348. SET_PRIORITY = 'set_priority',
  349. DELETED_ATTACHMENT = 'deleted_attachment',
  350. }
  351. interface GroupActivityBase {
  352. dateCreated: string;
  353. id: string;
  354. project: Project;
  355. assignee?: string;
  356. issue?: Group;
  357. user?: null | User;
  358. }
  359. export interface GroupActivityNote extends GroupActivityBase {
  360. data: {
  361. text: string;
  362. };
  363. type: GroupActivityType.NOTE;
  364. }
  365. interface GroupActivitySetResolved extends GroupActivityBase {
  366. data: {};
  367. type: GroupActivityType.SET_RESOLVED;
  368. }
  369. /**
  370. * An integration marks an issue as resolved
  371. */
  372. interface GroupActivitySetResolvedIntegration extends GroupActivityBase {
  373. data: {
  374. integration_id: number;
  375. /**
  376. * Human readable name of the integration
  377. */
  378. provider: string;
  379. /**
  380. * The key of the integration
  381. */
  382. provider_key: string;
  383. };
  384. type: GroupActivityType.SET_RESOLVED;
  385. }
  386. interface GroupActivitySetUnresolved extends GroupActivityBase {
  387. data: {};
  388. type: GroupActivityType.SET_UNRESOLVED;
  389. }
  390. interface GroupActivitySetUnresolvedForecast extends GroupActivityBase {
  391. data: {
  392. forecast: number;
  393. };
  394. type: GroupActivityType.SET_UNRESOLVED;
  395. }
  396. /**
  397. * An integration marks an issue as unresolved
  398. */
  399. interface GroupActivitySetUnresolvedIntegration extends GroupActivityBase {
  400. data: {
  401. integration_id: number;
  402. /**
  403. * Human readable name of the integration
  404. */
  405. provider: string;
  406. /**
  407. * The key of the integration
  408. */
  409. provider_key: string;
  410. };
  411. type: GroupActivityType.SET_UNRESOLVED;
  412. }
  413. interface GroupActivitySetPublic extends GroupActivityBase {
  414. data: Record<string, any>;
  415. type: GroupActivityType.SET_PUBLIC;
  416. }
  417. interface GroupActivitySetPrivate extends GroupActivityBase {
  418. data: Record<string, any>;
  419. type: GroupActivityType.SET_PRIVATE;
  420. }
  421. interface GroupActivitySetByAge extends GroupActivityBase {
  422. data: Record<string, any>;
  423. type: GroupActivityType.SET_RESOLVED_BY_AGE;
  424. }
  425. interface GroupActivityUnassigned extends GroupActivityBase {
  426. data: Record<string, any>;
  427. type: GroupActivityType.UNASSIGNED;
  428. }
  429. interface GroupActivityFirstSeen extends GroupActivityBase {
  430. data: Record<string, any>;
  431. type: GroupActivityType.FIRST_SEEN;
  432. }
  433. interface GroupActivityLastSeen extends GroupActivityBase {
  434. data: Record<string, any>;
  435. type: GroupActivityType.LAST_SEEN;
  436. }
  437. interface GroupActivityMarkReviewed extends GroupActivityBase {
  438. data: Record<string, any>;
  439. type: GroupActivityType.MARK_REVIEWED;
  440. }
  441. interface GroupActivityRegression extends GroupActivityBase {
  442. data: {
  443. /**
  444. * True if the project is using semver to decide if the event is a regression.
  445. * Available when the issue was resolved in a release.
  446. */
  447. follows_semver?: boolean;
  448. /**
  449. * The version that the issue was previously resolved in.
  450. * Available when the issue was resolved in a release.
  451. */
  452. resolved_in_version?: string;
  453. version?: string;
  454. };
  455. type: GroupActivityType.SET_REGRESSION;
  456. }
  457. export interface GroupActivitySetByResolvedInNextSemverRelease extends GroupActivityBase {
  458. data: {
  459. // Set for semver releases
  460. current_release_version: string;
  461. };
  462. type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
  463. }
  464. export interface GroupActivitySetByResolvedInRelease extends GroupActivityBase {
  465. data: {
  466. version?: string;
  467. };
  468. type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
  469. }
  470. interface GroupActivitySetByResolvedInCommit extends GroupActivityBase {
  471. data: {
  472. commit?: Commit;
  473. };
  474. type: GroupActivityType.SET_RESOLVED_IN_COMMIT;
  475. }
  476. interface GroupActivitySetByResolvedInPullRequest extends GroupActivityBase {
  477. data: {
  478. pullRequest?: PullRequest;
  479. };
  480. type: GroupActivityType.SET_RESOLVED_IN_PULL_REQUEST;
  481. }
  482. export interface GroupActivitySetIgnored extends GroupActivityBase {
  483. data: {
  484. ignoreCount?: number;
  485. ignoreDuration?: number;
  486. ignoreUntil?: string;
  487. /** Archived until escalating */
  488. ignoreUntilEscalating?: boolean;
  489. ignoreUserCount?: number;
  490. ignoreUserWindow?: number;
  491. ignoreWindow?: number;
  492. };
  493. type: GroupActivityType.SET_IGNORED;
  494. }
  495. export interface GroupActivityReprocess extends GroupActivityBase {
  496. data: {
  497. eventCount: number;
  498. newGroupId: number;
  499. oldGroupId: number;
  500. };
  501. type: GroupActivityType.REPROCESS;
  502. }
  503. interface GroupActivityUnmergeDestination extends GroupActivityBase {
  504. data: {
  505. fingerprints: Array<string>;
  506. source?: {
  507. id: string;
  508. shortId: string;
  509. };
  510. };
  511. type: GroupActivityType.UNMERGE_DESTINATION;
  512. }
  513. interface GroupActivityUnmergeSource extends GroupActivityBase {
  514. data: {
  515. fingerprints: Array<string>;
  516. destination?: {
  517. id: string;
  518. shortId: string;
  519. };
  520. };
  521. type: GroupActivityType.UNMERGE_SOURCE;
  522. }
  523. interface GroupActivityMerge extends GroupActivityBase {
  524. data: {
  525. issues: Array<any>;
  526. };
  527. type: GroupActivityType.MERGE;
  528. }
  529. interface GroupActivityAutoSetOngoing extends GroupActivityBase {
  530. data: {
  531. afterDays?: number;
  532. };
  533. type: GroupActivityType.AUTO_SET_ONGOING;
  534. }
  535. export interface GroupActivitySetEscalating extends GroupActivityBase {
  536. data: {
  537. expired_snooze?: {
  538. count: number | null;
  539. until: Date | null;
  540. user_count: number | null;
  541. user_window: number | null;
  542. window: number | null;
  543. };
  544. forecast?: number;
  545. };
  546. type: GroupActivityType.SET_ESCALATING;
  547. }
  548. export interface GroupActivitySetPriority extends GroupActivityBase {
  549. data: {
  550. priority: PriorityLevel;
  551. reason: string;
  552. };
  553. type: GroupActivityType.SET_PRIORITY;
  554. }
  555. export interface GroupActivityAssigned extends GroupActivityBase {
  556. data: {
  557. assignee: string;
  558. assigneeType: string;
  559. user: Team | User;
  560. assigneeEmail?: string;
  561. /**
  562. * If the user was assigned via an integration
  563. */
  564. integration?:
  565. | 'projectOwnership'
  566. | 'codeowners'
  567. | 'slack'
  568. | 'msteams'
  569. | 'suspectCommitter';
  570. /** Codeowner or Project owner rule as a string */
  571. rule?: string;
  572. };
  573. type: GroupActivityType.ASSIGNED;
  574. }
  575. export interface GroupActivityCreateIssue extends GroupActivityBase {
  576. data: {
  577. location: string;
  578. provider: string;
  579. title: string;
  580. };
  581. type: GroupActivityType.CREATE_ISSUE;
  582. }
  583. interface GroupActivityDeletedAttachment extends GroupActivityBase {
  584. data: {};
  585. type: GroupActivityType.DELETED_ATTACHMENT;
  586. }
  587. export type GroupActivity =
  588. | GroupActivityNote
  589. | GroupActivitySetResolved
  590. | GroupActivitySetResolvedIntegration
  591. | GroupActivitySetUnresolved
  592. | GroupActivitySetUnresolvedForecast
  593. | GroupActivitySetUnresolvedIntegration
  594. | GroupActivitySetIgnored
  595. | GroupActivitySetByAge
  596. | GroupActivitySetByResolvedInRelease
  597. | GroupActivitySetByResolvedInNextSemverRelease
  598. | GroupActivitySetByResolvedInCommit
  599. | GroupActivitySetByResolvedInPullRequest
  600. | GroupActivityFirstSeen
  601. | GroupActivityMerge
  602. | GroupActivityReprocess
  603. | GroupActivityUnassigned
  604. | GroupActivityMarkReviewed
  605. | GroupActivityUnmergeDestination
  606. | GroupActivitySetPublic
  607. | GroupActivitySetPrivate
  608. | GroupActivityRegression
  609. | GroupActivityUnmergeSource
  610. | GroupActivityAssigned
  611. | GroupActivityCreateIssue
  612. | GroupActivityAutoSetOngoing
  613. | GroupActivitySetEscalating
  614. | GroupActivitySetPriority
  615. | GroupActivityDeletedAttachment
  616. | GroupActivityLastSeen;
  617. export type Activity = GroupActivity;
  618. interface GroupFiltered {
  619. count: string;
  620. firstSeen: string;
  621. lastSeen: string;
  622. stats: Record<string, TimeseriesValue[]>;
  623. userCount: number;
  624. }
  625. export interface GroupStats extends GroupFiltered {
  626. filtered: GroupFiltered | null;
  627. id: string;
  628. isUnhandled?: boolean;
  629. // for issue alert previews, the last time a group triggered a rule
  630. lastTriggered?: string;
  631. lifetime?: GroupFiltered;
  632. sessionCount?: string | null;
  633. }
  634. export interface IgnoredStatusDetails {
  635. actor?: AvatarUser;
  636. ignoreCount?: number;
  637. // Sent in requests. ignoreUntil is used in responses.
  638. ignoreDuration?: number;
  639. ignoreUntil?: string;
  640. ignoreUntilEscalating?: boolean;
  641. ignoreUserCount?: number;
  642. ignoreUserWindow?: number;
  643. ignoreWindow?: number;
  644. }
  645. export interface ResolvedStatusDetails {
  646. actor?: AvatarUser;
  647. autoResolved?: boolean;
  648. inCommit?: {
  649. commit?: string;
  650. dateCreated?: string;
  651. id?: string;
  652. repository?: string | Repository;
  653. };
  654. inNextRelease?: boolean;
  655. inRelease?: string;
  656. inUpcomingRelease?: boolean;
  657. repository?: string;
  658. }
  659. interface ReprocessingStatusDetails {
  660. info: {
  661. dateCreated: string;
  662. totalEvents: number;
  663. } | null;
  664. pendingEvents: number;
  665. }
  666. export interface UserParticipant extends User {
  667. type: 'user';
  668. }
  669. export interface TeamParticipant extends Team {
  670. type: 'team';
  671. }
  672. /**
  673. * The payload sent when marking reviewed
  674. */
  675. export interface MarkReviewed {
  676. inbox: false;
  677. }
  678. /**
  679. * The payload sent when updating a group's status
  680. */
  681. export interface GroupStatusResolution {
  682. status: GroupStatus.RESOLVED | GroupStatus.UNRESOLVED | GroupStatus.IGNORED;
  683. statusDetails: ResolvedStatusDetails | IgnoredStatusDetails | {};
  684. substatus?: GroupSubstatus | null;
  685. }
  686. export const enum GroupStatus {
  687. RESOLVED = 'resolved',
  688. UNRESOLVED = 'unresolved',
  689. IGNORED = 'ignored',
  690. REPROCESSING = 'reprocessing',
  691. }
  692. export const enum GroupSubstatus {
  693. ARCHIVED_UNTIL_ESCALATING = 'archived_until_escalating',
  694. ARCHIVED_UNTIL_CONDITION_MET = 'archived_until_condition_met',
  695. ARCHIVED_FOREVER = 'archived_forever',
  696. ESCALATING = 'escalating',
  697. ONGOING = 'ongoing',
  698. REGRESSED = 'regressed',
  699. NEW = 'new',
  700. }
  701. export const enum PriorityLevel {
  702. HIGH = 'high',
  703. MEDIUM = 'medium',
  704. LOW = 'low',
  705. }
  706. // TODO(ts): incomplete
  707. export interface BaseGroup {
  708. activity: GroupActivity[];
  709. annotations: Annotation[];
  710. assignedTo: Actor | null;
  711. culprit: string;
  712. firstSeen: string;
  713. hasSeen: boolean;
  714. id: string;
  715. isBookmarked: boolean;
  716. isPublic: boolean;
  717. isSubscribed: boolean;
  718. issueCategory: IssueCategory;
  719. issueType: IssueType;
  720. lastSeen: string;
  721. level: Level;
  722. logger: string | null;
  723. metadata: EventMetadata;
  724. numComments: number;
  725. participants: Array<UserParticipant | TeamParticipant>;
  726. permalink: string;
  727. platform: PlatformKey;
  728. pluginActions: TitledPlugin[];
  729. pluginContexts: any[]; // TODO(ts)
  730. pluginIssues: TitledPlugin[];
  731. priority: PriorityLevel;
  732. priorityLockedAt: string | null;
  733. project: Project;
  734. seenBy: User[];
  735. shareId: string;
  736. shortId: string;
  737. status: GroupStatus;
  738. statusDetails: IgnoredStatusDetails | ResolvedStatusDetails | ReprocessingStatusDetails;
  739. subscriptionDetails: {disabled?: boolean; reason?: string} | null;
  740. title: string;
  741. type: EventOrGroupType;
  742. userReportCount: number;
  743. inbox?: InboxDetails | null | false;
  744. integrationIssues?: ExternalIssue[];
  745. latestEvent?: Event;
  746. latestEventHasAttachments?: boolean;
  747. owners?: SuggestedOwner[] | null;
  748. sentryAppIssues?: PlatformExternalIssue[];
  749. substatus?: GroupSubstatus | null;
  750. }
  751. export interface GroupReprocessing extends BaseGroup, GroupStats {
  752. status: GroupStatus.REPROCESSING;
  753. statusDetails: ReprocessingStatusDetails;
  754. }
  755. export interface GroupResolved extends BaseGroup, GroupStats {
  756. status: GroupStatus.RESOLVED;
  757. statusDetails: ResolvedStatusDetails;
  758. }
  759. export interface GroupIgnored extends BaseGroup, GroupStats {
  760. status: GroupStatus.IGNORED;
  761. statusDetails: IgnoredStatusDetails;
  762. }
  763. export interface GroupUnresolved extends BaseGroup, GroupStats {
  764. status: GroupStatus.UNRESOLVED;
  765. statusDetails: {};
  766. }
  767. export type Group = GroupUnresolved | GroupResolved | GroupIgnored | GroupReprocessing;
  768. export interface GroupTombstone {
  769. actor: AvatarUser;
  770. culprit: string;
  771. id: string;
  772. level: Level;
  773. metadata: EventMetadata;
  774. type: EventOrGroupType;
  775. title?: string;
  776. }
  777. export interface GroupTombstoneHelper extends GroupTombstone {
  778. isTombstone: true;
  779. }
  780. /**
  781. * Datascrubbing
  782. */
  783. export type Meta = {
  784. chunks: Array<ChunkType>;
  785. err: Array<MetaError>;
  786. len: number;
  787. rem: Array<MetaRemark>;
  788. };
  789. export type MetaError = string | [string, any];
  790. export type MetaRemark = Array<string | number>;
  791. export type ChunkType = {
  792. rule_id: string | number;
  793. text: string;
  794. type: string;
  795. remark?: string | number;
  796. };
  797. /**
  798. * Old User Feedback
  799. */
  800. export type UserReport = {
  801. comments: string;
  802. dateCreated: string;
  803. email: string;
  804. event: {eventID: string; id: string};
  805. eventID: string;
  806. id: string;
  807. issue: Group;
  808. name: string;
  809. user: User;
  810. };
  811. export type KeyValueListDataItem = {
  812. key: string;
  813. subject: string;
  814. action?: {
  815. link?: string | LocationDescriptor;
  816. };
  817. actionButton?: React.ReactNode;
  818. /**
  819. * If true, the action button will always be visible, not just on hover.
  820. */
  821. actionButtonAlwaysVisible?: boolean;
  822. isContextData?: boolean;
  823. isMultiValue?: boolean;
  824. meta?: Meta;
  825. subjectDataTestId?: string;
  826. subjectIcon?: React.ReactNode;
  827. subjectNode?: React.ReactNode;
  828. value?: React.ReactNode | Record<string, string | number>;
  829. };
  830. export type KeyValueListData = KeyValueListDataItem[];
  831. // Response from ShortIdLookupEndpoint
  832. // /organizations/${orgId}/shortids/${query}/
  833. export type ShortIdResponse = {
  834. group: Group;
  835. groupId: string;
  836. organizationSlug: string;
  837. projectSlug: string;
  838. shortId: string;
  839. };
  840. /**
  841. * Note used in Group Activity and Alerts for users to comment
  842. */
  843. export type Note = {
  844. /**
  845. * Array of [id, display string] tuples used for @-mentions
  846. */
  847. mentions: [string, string][];
  848. /**
  849. * Note contents (markdown allowed)
  850. */
  851. text: string;
  852. };