projectAlertRuleConfiguration.ts 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. import type {IssueAlertConfiguration} from 'sentry/types/alerts';
  2. export function ProjectAlertRuleConfiguration(
  3. params: Partial<IssueAlertConfiguration> = {}
  4. ): IssueAlertConfiguration {
  5. return {
  6. actions: [
  7. {
  8. id: 'sentry.mail.actions.NotifyEmailAction',
  9. label: 'Send a notification to {targetType}',
  10. enabled: true,
  11. prompt: 'Send a notification',
  12. formFields: {
  13. targetType: {
  14. type: 'choice',
  15. placeholder: 'mailAction',
  16. choices: [
  17. ['IssueOwners', 'Issue Owners'],
  18. ['Team', 'Team'],
  19. ['Member', 'Member'],
  20. ],
  21. },
  22. },
  23. },
  24. {
  25. id: 'sentry.rules.actions.notify_event.NotifyEventAction',
  26. label: 'Send a notification (for all legacy integrations)',
  27. enabled: true,
  28. prompt: 'Send a notification to all legacy integrations',
  29. },
  30. {
  31. id: 'sentry.integrations.slack.notify_action.SlackNotifyServiceAction',
  32. label:
  33. 'Send a notification to the {workspace} Slack workspace to {channel} (optionally, an ID: {channel_id}) and show tags {tags} in notification',
  34. enabled: true,
  35. prompt: 'Send a Slack notification',
  36. formFields: {
  37. workspace: {type: 'choice', choices: [['123', 'Sentry']]},
  38. channel: {type: 'string', placeholder: 'i.e #critical, Jane Schmidt'},
  39. channel_id: {type: 'string', placeholder: 'i.e. CA2FRA079 or UA1J9RTE1'},
  40. tags: {type: 'string', placeholder: 'i.e environment,user,my_tag'},
  41. },
  42. },
  43. {
  44. id: 'sentry.integrations.pagerduty.notify_action.PagerDutyNotifyServiceAction',
  45. label: 'Send a notification to PagerDuty account {account} and service {service}',
  46. enabled: true,
  47. prompt: 'Send a PagerDuty notification',
  48. formFields: {
  49. account: {type: 'choice', choices: []},
  50. service: {type: 'choice', choices: []},
  51. },
  52. },
  53. ],
  54. conditions: [
  55. {
  56. id: 'sentry.rules.conditions.every_event.EveryEventCondition',
  57. label: 'The event occurs',
  58. enabled: false,
  59. },
  60. {
  61. id: 'sentry.rules.conditions.first_seen_event.FirstSeenEventCondition',
  62. label: 'A new issue is created',
  63. enabled: true,
  64. },
  65. {
  66. id: 'sentry.rules.conditions.regression_event.RegressionEventCondition',
  67. label: 'The issue changes state from resolved to unresolved',
  68. enabled: true,
  69. },
  70. {
  71. id: 'sentry.rules.conditions.reappeared_event.ReappearedEventCondition',
  72. label: 'The issue changes state from ignored to unresolved',
  73. enabled: true,
  74. },
  75. {
  76. id: 'sentry.rules.conditions.event_frequency.EventFrequencyCondition',
  77. label: 'The issue is seen more than {value} times in {interval}',
  78. enabled: true,
  79. formFields: {
  80. value: {type: 'number', placeholder: 100},
  81. interval: {
  82. type: 'choice',
  83. choices: [
  84. ['1m', 'one minute'],
  85. ['5m', '5 minutes'],
  86. ['15m', '15 minutes'],
  87. ['1h', 'one hour'],
  88. ['1d', 'one day'],
  89. ['1w', 'one week'],
  90. ['30d', '30 days'],
  91. ],
  92. },
  93. },
  94. },
  95. {
  96. id: 'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition',
  97. label: 'The issue is seen by more than {value} users in {interval}',
  98. enabled: true,
  99. formFields: {
  100. value: {type: 'number', placeholder: 100},
  101. interval: {
  102. type: 'choice',
  103. choices: [
  104. ['1m', 'one minute'],
  105. ['5m', '5 minutes'],
  106. ['15m', '15 minutes'],
  107. ['1h', 'one hour'],
  108. ['1d', 'one day'],
  109. ['1w', 'one week'],
  110. ['30d', '30 days'],
  111. ],
  112. },
  113. },
  114. },
  115. {
  116. id: 'sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition',
  117. label: 'The issue affects more than {value} percent of sessions in {interval}',
  118. enabled: true,
  119. formFields: {
  120. value: {type: 'number', placeholder: 100},
  121. interval: {
  122. type: 'choice',
  123. choices: [
  124. ['5m', '5 minutes'],
  125. ['10m', '10 minutes'],
  126. ['30m', '30 minutes'],
  127. ['1h', '1 hour'],
  128. ],
  129. },
  130. },
  131. },
  132. ],
  133. filters: [
  134. {
  135. id: 'sentry.rules.filters.age_comparison.AgeComparisonFilter',
  136. label: 'The issue is {comparison_type} than {value} {time}',
  137. enabled: true,
  138. prompt: 'The issue is older or newer than...',
  139. formFields: {
  140. comparison_type: {
  141. type: 'choice',
  142. choices: [
  143. ['older', 'older'],
  144. ['newer', 'newer'],
  145. ],
  146. },
  147. value: {type: 'number', placeholder: 10},
  148. time: {
  149. type: 'choice',
  150. choices: [
  151. ['minute', 'minute(s)'],
  152. ['hour', 'hour(s)'],
  153. ['day', 'day(s)'],
  154. ['week', 'week(s)'],
  155. ],
  156. },
  157. },
  158. },
  159. {
  160. id: 'sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter',
  161. label: 'The issue has happened at least {value} times',
  162. enabled: true,
  163. prompt: 'The issue has happened at least {x} times (Note: this is approximate)',
  164. formFields: {value: {type: 'number', placeholder: 10}},
  165. },
  166. {
  167. id: 'sentry.rules.filters.assigned_to.AssignedToFilter',
  168. label: 'The issue is assigned to {targetType}',
  169. enabled: true,
  170. prompt: 'The issue is assigned to {no one/team/member}',
  171. formFields: {
  172. targetType: {
  173. type: 'choice',
  174. placeholder: 'assignee',
  175. choices: [
  176. ['Unassigned', 'Unassigned'],
  177. ['Team', 'Team'],
  178. ['Member', 'Member'],
  179. ],
  180. },
  181. },
  182. },
  183. {
  184. id: 'sentry.rules.filters.event_attribute.EventAttributeFilter',
  185. label: "The event's {attribute} value {match} {value}",
  186. enabled: true,
  187. formFields: {
  188. attribute: {
  189. type: 'choice',
  190. placeholder: 'i.e. exception.type',
  191. choices: [
  192. ['message', 'message'],
  193. ['platform', 'platform'],
  194. ['environment', 'environment'],
  195. ['type', 'type'],
  196. ['exception.type', 'exception.type'],
  197. ['exception.value', 'exception.value'],
  198. ['user.id', 'user.id'],
  199. ['user.email', 'user.email'],
  200. ['user.username', 'user.username'],
  201. ['user.ip_address', 'user.ip_address'],
  202. ['http.method', 'http.method'],
  203. ['http.url', 'http.url'],
  204. ['sdk.name', 'sdk.name'],
  205. ['stacktrace.code', 'stacktrace.code'],
  206. ['stacktrace.module', 'stacktrace.module'],
  207. ['stacktrace.filename', 'stacktrace.filename'],
  208. ['stacktrace.abs_path', 'stacktrace.abs_path'],
  209. ['stacktrace.package', 'stacktrace.package'],
  210. ],
  211. },
  212. match: {
  213. type: 'choice',
  214. choices: [
  215. ['co', 'contains'],
  216. ['ew', 'ends with'],
  217. ['eq', 'equals'],
  218. ['is', 'is set'],
  219. ['nc', 'does not contain'],
  220. ['new', 'does not end with'],
  221. ['ne', 'does not equal'],
  222. ['ns', 'is not set'],
  223. ['nsw', 'does not start with'],
  224. ['sw', 'starts with'],
  225. ],
  226. },
  227. value: {type: 'string', placeholder: 'value'},
  228. },
  229. },
  230. {
  231. id: 'sentry.rules.filters.tagged_event.TaggedEventFilter',
  232. label: "The event's tags match {key} {match} {value}",
  233. enabled: true,
  234. formFields: {
  235. key: {type: 'string', placeholder: 'key'},
  236. match: {
  237. type: 'choice',
  238. choices: [
  239. ['co', 'contains'],
  240. ['ew', 'ends with'],
  241. ['eq', 'equals'],
  242. ['is', 'is set'],
  243. ['nc', 'does not contain'],
  244. ['new', 'does not end with'],
  245. ['ne', 'does not equal'],
  246. ['ns', 'is not set'],
  247. ['nsw', 'does not start with'],
  248. ['sw', 'starts with'],
  249. ],
  250. },
  251. value: {type: 'string', placeholder: 'value'},
  252. },
  253. },
  254. {
  255. id: 'sentry.rules.filters.level.LevelFilter',
  256. label: "The event's level is {match} {level}",
  257. enabled: true,
  258. formFields: {
  259. level: {
  260. type: 'choice',
  261. choices: [
  262. ['50', 'fatal'],
  263. ['40', 'error'],
  264. ['30', 'warning'],
  265. ['20', 'info'],
  266. ['10', 'debug'],
  267. ['0', 'sample'],
  268. ],
  269. },
  270. match: {
  271. type: 'choice',
  272. choices: [
  273. ['eq', 'equal to'],
  274. ['gte', 'greater than or equal to'],
  275. ['lte', 'less than or equal to'],
  276. ],
  277. },
  278. },
  279. },
  280. ],
  281. ...params,
  282. };
  283. }