ruleConditions.ts 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. const DEFAULT_INTERVAL_CHOICES = [
  2. ['1m', 'one minute'],
  3. ['1h', 'one hour'],
  4. ['1d', 'one day'],
  5. ['1w', 'one week'],
  6. ['30d', '30 days'],
  7. ];
  8. const DEFAULT_PLACEHOLDER = 100;
  9. const EVENT_FREQUENCY_CONDITION =
  10. 'sentry.rules.conditions.event_frequency.EventFrequencyCondition';
  11. const UNIQUE_USER_FREQUENCY_CONDITION =
  12. 'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition';
  13. export const MOCK_RESP_VERBOSE = [
  14. {
  15. id: 'sentry.rules.conditions.every_event.EveryEventCondition',
  16. label: 'An event occurs',
  17. },
  18. {
  19. id: 'sentry.rules.conditions.first_seen_event.FirstSeenEventCondition',
  20. label: 'A new issue is created',
  21. },
  22. {
  23. id: 'sentry.rules.conditions.regression_event.RegressionEventCondition',
  24. label: 'The issue changes state from resolved to unresolved',
  25. },
  26. {
  27. id: 'sentry.rules.conditions.reappeared_event.ReappearedEventCondition',
  28. label: 'The issue changes state from ignored to unresolved',
  29. },
  30. {
  31. formFields: {
  32. value: {
  33. placeholder: 'value',
  34. type: 'string',
  35. },
  36. match: {
  37. type: 'choice',
  38. choices: [
  39. ['eq', 'equals'],
  40. ['ne', 'does not equal'],
  41. ['sw', 'starts with'],
  42. ['ew', 'ends with'],
  43. ['co', 'contains'],
  44. ['nc', 'does not contain'],
  45. ['is', 'is set'],
  46. ['ns', 'is not set'],
  47. ],
  48. },
  49. key: {
  50. placeholder: 'key',
  51. type: 'string',
  52. },
  53. },
  54. id: 'sentry.rules.conditions.tagged_event.TaggedEventCondition',
  55. label: "An event's tags match {key} {match} {value}",
  56. },
  57. {
  58. formFields: {
  59. interval: {
  60. type: 'choice',
  61. choices: DEFAULT_INTERVAL_CHOICES,
  62. },
  63. value: {
  64. placeholder: DEFAULT_PLACEHOLDER,
  65. type: 'number',
  66. },
  67. },
  68. id: EVENT_FREQUENCY_CONDITION,
  69. label: 'The issue is seen more than {value} times in {interval}',
  70. },
  71. {
  72. formFields: {
  73. interval: {
  74. type: 'choice',
  75. choices: DEFAULT_INTERVAL_CHOICES,
  76. },
  77. value: {
  78. placeholder: DEFAULT_PLACEHOLDER,
  79. type: 'number',
  80. },
  81. },
  82. id: UNIQUE_USER_FREQUENCY_CONDITION,
  83. label: 'The issue is seen by more than {value} users in {interval}',
  84. },
  85. {
  86. formFields: {
  87. attribute: {
  88. placeholder: 'i.e. exception.type',
  89. type: 'choice',
  90. choices: [
  91. ['message', 'message'],
  92. ['platform', 'platform'],
  93. ['environment', 'environment'],
  94. ['type', 'type'],
  95. ['exception.type', 'exception.type'],
  96. ['exception.value', 'exception.value'],
  97. ['user.id', 'user.id'],
  98. ['user.email', 'user.email'],
  99. ['user.username', 'user.username'],
  100. ['user.ip_address', 'user.ip_address'],
  101. ['http.method', 'http.method'],
  102. ['http.url', 'http.url'],
  103. ['stacktrace.code', 'stacktrace.code'],
  104. ['stacktrace.module', 'stacktrace.module'],
  105. ['stacktrace.filename', 'stacktrace.filename'],
  106. ],
  107. },
  108. value: {
  109. placeholder: 'value',
  110. type: 'string',
  111. },
  112. match: {
  113. type: 'choice',
  114. choices: [
  115. ['eq', 'equals'],
  116. ['ne', 'does not equal'],
  117. ['sw', 'starts with'],
  118. ['ew', 'ends with'],
  119. ['co', 'contains'],
  120. ['nc', 'does not contain'],
  121. ['is', 'is set'],
  122. ['ns', 'is not set'],
  123. ],
  124. },
  125. },
  126. id: 'sentry.rules.conditions.event_attribute.EventAttributeCondition',
  127. label: "An event's {attribute} value {match} {value}",
  128. },
  129. {
  130. formFields: {
  131. match: {
  132. type: 'choice',
  133. choices: [
  134. ['eq', 'equal to'],
  135. ['lte', 'less than or equal to'],
  136. ['gte', 'greater than or equal to'],
  137. ],
  138. },
  139. level: {
  140. type: 'choice',
  141. choices: [
  142. ['50', 'fatal'],
  143. ['40', 'error'],
  144. ['30', 'warning'],
  145. ['20', 'info'],
  146. ['10', 'debug'],
  147. ['0', 'sample'],
  148. ],
  149. },
  150. },
  151. id: 'sentry.rules.conditions.level.LevelCondition',
  152. label: "An event's level is {match} {level}",
  153. },
  154. ];
  155. export const MOCK_RESP_ONLY_IGNORED_CONDITIONS_INVALID = [
  156. {
  157. formFields: {
  158. interval: {
  159. type: 'choice',
  160. choices: [['@*(&^#$!', 'Invalid choice']],
  161. },
  162. value: {
  163. placeholder: DEFAULT_PLACEHOLDER,
  164. type: 'number',
  165. },
  166. },
  167. id: 'cinnamon.rules.conditions.infinite_eclair.A19SeanBanIsabelle',
  168. label: 'The issue is seen more than {value} times in {interval}',
  169. },
  170. {
  171. formFields: {
  172. interval: {
  173. type: 'choice',
  174. choices: [
  175. ['1m', 'one minute'],
  176. ['1h', 'one hour'],
  177. ['30d', '30 days'],
  178. ],
  179. },
  180. value: {
  181. placeholder: DEFAULT_PLACEHOLDER,
  182. type: 'number',
  183. },
  184. },
  185. id: UNIQUE_USER_FREQUENCY_CONDITION,
  186. label: 'The issue is seen by more than {value} users in {interval}',
  187. },
  188. ];
  189. export const MOCK_RESP_INCONSISTENT_PLACEHOLDERS = [
  190. {
  191. formFields: {
  192. interval: {
  193. type: 'choice',
  194. choices: DEFAULT_INTERVAL_CHOICES,
  195. },
  196. value: {
  197. placeholder: 80696,
  198. type: 'number',
  199. },
  200. },
  201. id: EVENT_FREQUENCY_CONDITION,
  202. label: 'The issue is seen more than {value} times in {interval}',
  203. },
  204. {
  205. formFields: {
  206. interval: {
  207. type: 'choice',
  208. choices: DEFAULT_INTERVAL_CHOICES,
  209. },
  210. value: {
  211. placeholder: DEFAULT_PLACEHOLDER,
  212. type: 'number',
  213. },
  214. },
  215. id: UNIQUE_USER_FREQUENCY_CONDITION,
  216. label: 'The issue is seen by more than {value} users in {interval}',
  217. },
  218. ];
  219. export const MOCK_RESP_INCONSISTENT_INTERVALS = [
  220. {
  221. formFields: {
  222. interval: {
  223. type: 'choice',
  224. choices: [
  225. ['1m', 'one minute'],
  226. ['1h', 'one hour'],
  227. ['12h', 'high noon'],
  228. ['1d', 'one day'],
  229. ['1w', 'one week'],
  230. ['30d', '30 days'],
  231. ],
  232. },
  233. value: {
  234. placeholder: DEFAULT_PLACEHOLDER,
  235. type: 'number',
  236. },
  237. },
  238. id: EVENT_FREQUENCY_CONDITION,
  239. label: 'The issue is seen more than {value} times in {interval}',
  240. },
  241. {
  242. formFields: {
  243. interval: {
  244. type: 'choice',
  245. choices: DEFAULT_INTERVAL_CHOICES,
  246. },
  247. value: {
  248. placeholder: DEFAULT_PLACEHOLDER,
  249. type: 'number',
  250. },
  251. },
  252. id: UNIQUE_USER_FREQUENCY_CONDITION,
  253. label: 'The issue is seen by more than {value} users in {interval}',
  254. },
  255. ];