types.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import type {AlertRuleActivation, IssueAlertRule} from 'sentry/types/alerts';
  2. import type {User} from 'sentry/types/user';
  3. import type {MetricRule} from 'sentry/views/alerts/rules/metric/types';
  4. type Data = [number, {count: number}[]][];
  5. export enum AlertRuleType {
  6. METRIC = 'metric',
  7. ISSUE = 'issue',
  8. }
  9. export type Incident = {
  10. alertRule: MetricRule;
  11. dateClosed: string | null;
  12. dateCreated: string;
  13. dateDetected: string;
  14. dateStarted: string;
  15. // Array of group ids
  16. discoverQuery: string;
  17. groups: string[];
  18. hasSeen: boolean;
  19. id: string;
  20. identifier: string;
  21. isSubscribed: boolean;
  22. organizationId: string;
  23. projects: string[];
  24. // Array of slugs
  25. seenBy: User[];
  26. status: IncidentStatus;
  27. statusMethod: IncidentStatusMethod;
  28. title: string;
  29. activation?: AlertRuleActivation;
  30. activities?: ActivityType[];
  31. };
  32. export type IncidentStats = {
  33. eventStats: {
  34. data: Data;
  35. };
  36. totalEvents: number;
  37. uniqueUsers: number;
  38. };
  39. export type ActivityTypeDraft = {
  40. comment: null | string;
  41. dateCreated: string;
  42. id: string;
  43. incidentIdentifier: string;
  44. type: IncidentActivityType;
  45. user: User | null;
  46. };
  47. export type ActivityType = ActivityTypeDraft & {
  48. previousValue: string | null;
  49. value: string | null; // determines IncidentStatus of the activity (CRITICAL/WARNING/etc.)
  50. eventStats?: {data: Data};
  51. };
  52. export enum IncidentActivityType {
  53. CREATED = 0,
  54. DETECTED = 1,
  55. STATUS_CHANGE = 2,
  56. COMMENT = 3,
  57. STARTED = 4,
  58. }
  59. export enum IncidentStatus {
  60. OPENED = 1,
  61. CLOSED = 2,
  62. WARNING = 10,
  63. CRITICAL = 20,
  64. }
  65. export enum ActivationStatus {
  66. WAITING = 0,
  67. MONITORING = 1,
  68. }
  69. export enum IncidentStatusMethod {
  70. MANUAL = 1,
  71. RULE_UPDATED = 2,
  72. RULE_TRIGGERED = 3,
  73. }
  74. export enum AlertRuleStatus {
  75. PENDING = 0,
  76. SNAPSHOT = 4,
  77. DISABLED = 5,
  78. }
  79. export enum CombinedAlertType {
  80. METRIC = 'alert_rule',
  81. ISSUE = 'rule',
  82. }
  83. interface IssueAlert extends IssueAlertRule {
  84. type: CombinedAlertType.ISSUE;
  85. latestIncident?: Incident | null;
  86. }
  87. export interface MetricAlert extends MetricRule {
  88. type: CombinedAlertType.METRIC;
  89. }
  90. export type CombinedMetricIssueAlerts = IssueAlert | MetricAlert;