group.tsx 25 KB

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