projectAlertRuleConfiguration.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. import type {IssueAlertConfiguration} from 'sentry/types/alerts';
  2. export function ProjectAlertRuleConfigurationFixture(
  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.latest_adopted_release_filter.LatestAdoptedReleaseFilter',
  185. label:
  186. "The {oldest_or_newest} release associated with the event's issue is {older_or_newer} than the latest release in {environment}",
  187. enabled: true,
  188. formFields: {
  189. oldest_or_newest: {
  190. type: 'choice',
  191. choices: [
  192. ['oldest', 'oldest'],
  193. ['newest', 'newest'],
  194. ],
  195. },
  196. older_or_newer: {
  197. type: 'choice',
  198. choices: [
  199. ['older', 'older'],
  200. ['newer', 'newer'],
  201. ],
  202. },
  203. environment: {
  204. type: 'string',
  205. placeholder: 'value',
  206. },
  207. },
  208. },
  209. {
  210. id: 'sentry.rules.filters.event_attribute.EventAttributeFilter',
  211. label: "The event's {attribute} value {match} {value}",
  212. enabled: true,
  213. formFields: {
  214. attribute: {
  215. type: 'choice',
  216. placeholder: 'i.e. exception.type',
  217. choices: [
  218. ['message', 'message'],
  219. ['platform', 'platform'],
  220. ['environment', 'environment'],
  221. ['type', 'type'],
  222. ['exception.type', 'exception.type'],
  223. ['exception.value', 'exception.value'],
  224. ['user.id', 'user.id'],
  225. ['user.email', 'user.email'],
  226. ['user.username', 'user.username'],
  227. ['user.ip_address', 'user.ip_address'],
  228. ['http.method', 'http.method'],
  229. ['http.url', 'http.url'],
  230. ['sdk.name', 'sdk.name'],
  231. ['stacktrace.code', 'stacktrace.code'],
  232. ['stacktrace.module', 'stacktrace.module'],
  233. ['stacktrace.filename', 'stacktrace.filename'],
  234. ['stacktrace.abs_path', 'stacktrace.abs_path'],
  235. ['stacktrace.package', 'stacktrace.package'],
  236. ],
  237. },
  238. match: {
  239. type: 'choice',
  240. choices: [
  241. ['co', 'contains'],
  242. ['ew', 'ends with'],
  243. ['eq', 'equals'],
  244. ['is', 'is set'],
  245. ['nc', 'does not contain'],
  246. ['new', 'does not end with'],
  247. ['ne', 'does not equal'],
  248. ['ns', 'is not set'],
  249. ['nsw', 'does not start with'],
  250. ['sw', 'starts with'],
  251. ['in', 'is in (comma separated)'],
  252. ],
  253. },
  254. value: {type: 'string', placeholder: 'value'},
  255. },
  256. },
  257. {
  258. id: 'sentry.rules.filters.tagged_event.TaggedEventFilter',
  259. label: "The event's tags match {key} {match} {value}",
  260. enabled: true,
  261. formFields: {
  262. key: {type: 'string', placeholder: 'key'},
  263. match: {
  264. type: 'choice',
  265. choices: [
  266. ['co', 'contains'],
  267. ['ew', 'ends with'],
  268. ['eq', 'equals'],
  269. ['is', 'is set'],
  270. ['nc', 'does not contain'],
  271. ['new', 'does not end with'],
  272. ['ne', 'does not equal'],
  273. ['ns', 'is not set'],
  274. ['nsw', 'does not start with'],
  275. ['sw', 'starts with'],
  276. ['in', 'is in (comma separated)'],
  277. ],
  278. },
  279. value: {type: 'string', placeholder: 'value'},
  280. },
  281. },
  282. {
  283. id: 'sentry.rules.filters.level.LevelFilter',
  284. label: "The event's level is {match} {level}",
  285. enabled: true,
  286. formFields: {
  287. level: {
  288. type: 'choice',
  289. choices: [
  290. ['50', 'fatal'],
  291. ['40', 'error'],
  292. ['30', 'warning'],
  293. ['20', 'info'],
  294. ['10', 'debug'],
  295. ['0', 'sample'],
  296. ],
  297. },
  298. match: {
  299. type: 'choice',
  300. choices: [
  301. ['eq', 'equal to'],
  302. ['gte', 'greater than or equal to'],
  303. ['lte', 'less than or equal to'],
  304. ],
  305. },
  306. },
  307. },
  308. ],
  309. ...params,
  310. };
  311. }