group.tsx 25 KB

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