alerts.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import type {SchemaFormConfig} from 'sentry/views/settings/organizationIntegrations/sentryAppExternalForm';
  2. import type {IssueConfigField} from './integrations';
  3. type IssueAlertRuleFormField =
  4. | {
  5. type: 'choice';
  6. choices?: [string, string][];
  7. initial?: string;
  8. placeholder?: string;
  9. }
  10. | {
  11. type: 'string';
  12. initial?: string;
  13. placeholder?: string;
  14. }
  15. | {
  16. type: 'number';
  17. initial?: string;
  18. placeholder?: number | string;
  19. };
  20. /**
  21. * These templates that tell the UI how to render the action or condition
  22. * and what fields it needs
  23. */
  24. export interface IssueAlertRuleActionTemplate {
  25. enabled: boolean;
  26. id: string;
  27. label: string;
  28. name: string;
  29. actionType?: 'ticket' | 'sentryapp';
  30. formFields?:
  31. | {
  32. [key: string]: IssueAlertRuleFormField;
  33. }
  34. | SchemaFormConfig;
  35. link?: string;
  36. prompt?: string;
  37. sentryAppInstallationUuid?: string;
  38. ticketType?: string;
  39. }
  40. export type IssueAlertRuleConditionTemplate = IssueAlertRuleActionTemplate;
  41. /**
  42. * These are the action or condition data that the user is editing or has saved.
  43. */
  44. export interface IssueAlertRuleAction
  45. extends Omit<IssueAlertRuleActionTemplate, 'formFields' | 'enabled'> {
  46. // These are the same values as the keys in `formFields` for a template
  47. [key: string]: any;
  48. dynamic_form_fields?: IssueConfigField[];
  49. }
  50. export type IssueAlertRuleCondition = Omit<
  51. IssueAlertRuleConditionTemplate,
  52. 'formFields' | 'enabled'
  53. > & {
  54. dynamic_form_fields?: IssueConfigField[];
  55. } & {
  56. // These are the same values as the keys in `formFields` for a template
  57. [key: string]: number | string;
  58. };
  59. export interface UnsavedIssueAlertRule {
  60. /** When an issue matches [actionMatch] of the following */
  61. actionMatch: 'all' | 'any' | 'none';
  62. actions: IssueAlertRuleAction[];
  63. conditions: IssueAlertRuleCondition[];
  64. /** If that issue has [filterMatch] of these properties */
  65. filterMatch: 'all' | 'any' | 'none';
  66. filters: IssueAlertRuleCondition[];
  67. frequency: number;
  68. name: string;
  69. environment?: null | string;
  70. owner?: string | null;
  71. }
  72. // Issue-based alert rule
  73. export interface IssueAlertRule extends UnsavedIssueAlertRule {
  74. createdBy: {email: string; id: number; name: string} | null;
  75. dateCreated: string;
  76. id: string;
  77. projects: string[];
  78. snooze: boolean;
  79. errors?: {detail: string}[];
  80. lastTriggered?: string;
  81. snoozeCreatedBy?: string;
  82. snoozeForEveryone?: boolean;
  83. }
  84. // Project's alert rule stats
  85. export type ProjectAlertRuleStats = {
  86. count: number;
  87. date: string;
  88. };
  89. export enum MailActionTargetType {
  90. ISSUE_OWNERS = 'IssueOwners',
  91. TEAM = 'Team',
  92. MEMBER = 'Member',
  93. RELEASE_MEMBERS = 'ReleaseMembers',
  94. }
  95. export enum AssigneeTargetType {
  96. UNASSIGNED = 'Unassigned',
  97. TEAM = 'Team',
  98. MEMBER = 'Member',
  99. }
  100. export type NoteType = {
  101. mentions: string[];
  102. text: string;
  103. };
  104. /**
  105. * Used when determining what types of actions a rule has. The default action is "sentry.mail.actions.NotifyEmailAction"
  106. * while other actions can be integration (Slack, PagerDuty, etc) actions. We need to know this to determine what kind of muting
  107. * the alert should have.
  108. */
  109. export enum RuleActionsCategories {
  110. ALL_DEFAULT = 'all_default',
  111. SOME_DEFAULT = 'some_default',
  112. NO_DEFAULT = 'no_default',
  113. }