group.tsx 25 KB

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