group.tsx 25 KB

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