transformMetricsResponseToSeries.spec.tsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. import {transformMetricsResponseToSeries} from 'sentry/utils/metrics/transformMetricsResponseToSeries';
  2. describe('transformMetricsResponseToSeries', function () {
  3. it('transforms metrics into series', () => {
  4. expect(
  5. transformMetricsResponseToSeries(
  6. TestStubs.MetricsSessionUserCountByStatusByRelease()
  7. )
  8. ).toEqual([
  9. {
  10. seriesName: 'sum(sentry.sessions.session)|session.status:crashed|release:1',
  11. data: [
  12. {name: '2022-01-15T00:00:00Z', value: 0},
  13. {name: '2022-01-16T00:00:00Z', value: 0},
  14. {name: '2022-01-17T00:00:00Z', value: 0},
  15. {name: '2022-01-18T00:00:00Z', value: 0},
  16. {name: '2022-01-19T00:00:00Z', value: 0},
  17. {name: '2022-01-20T00:00:00Z', value: 0},
  18. {name: '2022-01-21T00:00:00Z', value: 0},
  19. {name: '2022-01-22T00:00:00Z', value: 0},
  20. {name: '2022-01-23T00:00:00Z', value: 0},
  21. {name: '2022-01-24T00:00:00Z', value: 23},
  22. {name: '2022-01-25T00:00:00Z', value: 11},
  23. {name: '2022-01-26T00:00:00Z', value: 0},
  24. {name: '2022-01-27T00:00:00Z', value: 0},
  25. {name: '2022-01-28T00:00:00Z', value: 0},
  26. ],
  27. },
  28. {
  29. seriesName: 'count_unique(sentry.sessions.user)|session.status:crashed|release:1',
  30. data: [
  31. {name: '2022-01-15T00:00:00Z', value: 0},
  32. {name: '2022-01-16T00:00:00Z', value: 0},
  33. {name: '2022-01-17T00:00:00Z', value: 0},
  34. {name: '2022-01-18T00:00:00Z', value: 0},
  35. {name: '2022-01-19T00:00:00Z', value: 0},
  36. {name: '2022-01-20T00:00:00Z', value: 0},
  37. {name: '2022-01-21T00:00:00Z', value: 0},
  38. {name: '2022-01-22T00:00:00Z', value: 0},
  39. {name: '2022-01-23T00:00:00Z', value: 0},
  40. {name: '2022-01-24T00:00:00Z', value: 1},
  41. {name: '2022-01-25T00:00:00Z', value: 1},
  42. {name: '2022-01-26T00:00:00Z', value: 0},
  43. {name: '2022-01-27T00:00:00Z', value: 0},
  44. {name: '2022-01-28T00:00:00Z', value: 0},
  45. ],
  46. },
  47. {
  48. seriesName: 'sum(sentry.sessions.session)|session.status:abnormal|release:1',
  49. data: [
  50. {name: '2022-01-15T00:00:00Z', value: 1},
  51. {name: '2022-01-16T00:00:00Z', value: 0},
  52. {name: '2022-01-17T00:00:00Z', value: 0},
  53. {name: '2022-01-18T00:00:00Z', value: 0},
  54. {name: '2022-01-19T00:00:00Z', value: 0},
  55. {name: '2022-01-20T00:00:00Z', value: 0},
  56. {name: '2022-01-21T00:00:00Z', value: 0},
  57. {name: '2022-01-22T00:00:00Z', value: 0},
  58. {name: '2022-01-23T00:00:00Z', value: 0},
  59. {name: '2022-01-24T00:00:00Z', value: 0},
  60. {name: '2022-01-25T00:00:00Z', value: 0},
  61. {name: '2022-01-26T00:00:00Z', value: 0},
  62. {name: '2022-01-27T00:00:00Z', value: 0},
  63. {name: '2022-01-28T00:00:00Z', value: 0},
  64. ],
  65. },
  66. {
  67. seriesName:
  68. 'count_unique(sentry.sessions.user)|session.status:abnormal|release:1',
  69. data: [
  70. {name: '2022-01-15T00:00:00Z', value: 1},
  71. {name: '2022-01-16T00:00:00Z', value: 0},
  72. {name: '2022-01-17T00:00:00Z', value: 0},
  73. {name: '2022-01-18T00:00:00Z', value: 0},
  74. {name: '2022-01-19T00:00:00Z', value: 0},
  75. {name: '2022-01-20T00:00:00Z', value: 0},
  76. {name: '2022-01-21T00:00:00Z', value: 0},
  77. {name: '2022-01-22T00:00:00Z', value: 0},
  78. {name: '2022-01-23T00:00:00Z', value: 0},
  79. {name: '2022-01-24T00:00:00Z', value: 0},
  80. {name: '2022-01-25T00:00:00Z', value: 0},
  81. {name: '2022-01-26T00:00:00Z', value: 0},
  82. {name: '2022-01-27T00:00:00Z', value: 0},
  83. {name: '2022-01-28T00:00:00Z', value: 0},
  84. ],
  85. },
  86. {
  87. seriesName: 'sum(sentry.sessions.session)|session.status:errored|release:1',
  88. data: [
  89. {name: '2022-01-15T00:00:00Z', value: 0},
  90. {name: '2022-01-16T00:00:00Z', value: 0},
  91. {name: '2022-01-17T00:00:00Z', value: 0},
  92. {name: '2022-01-18T00:00:00Z', value: 0},
  93. {name: '2022-01-19T00:00:00Z', value: 0},
  94. {name: '2022-01-20T00:00:00Z', value: 37},
  95. {name: '2022-01-21T00:00:00Z', value: 0},
  96. {name: '2022-01-22T00:00:00Z', value: 0},
  97. {name: '2022-01-23T00:00:00Z', value: 0},
  98. {name: '2022-01-24T00:00:00Z', value: 335},
  99. {name: '2022-01-25T00:00:00Z', value: 79},
  100. {name: '2022-01-26T00:00:00Z', value: 0},
  101. {name: '2022-01-27T00:00:00Z', value: 0},
  102. {name: '2022-01-28T00:00:00Z', value: 0},
  103. ],
  104. },
  105. {
  106. seriesName: 'count_unique(sentry.sessions.user)|session.status:errored|release:1',
  107. data: [
  108. {name: '2022-01-15T00:00:00Z', value: 0},
  109. {name: '2022-01-16T00:00:00Z', value: 0},
  110. {name: '2022-01-17T00:00:00Z', value: 0},
  111. {name: '2022-01-18T00:00:00Z', value: 0},
  112. {name: '2022-01-19T00:00:00Z', value: 0},
  113. {name: '2022-01-20T00:00:00Z', value: 1},
  114. {name: '2022-01-21T00:00:00Z', value: 0},
  115. {name: '2022-01-22T00:00:00Z', value: 0},
  116. {name: '2022-01-23T00:00:00Z', value: 0},
  117. {name: '2022-01-24T00:00:00Z', value: 2},
  118. {name: '2022-01-25T00:00:00Z', value: 2},
  119. {name: '2022-01-26T00:00:00Z', value: 0},
  120. {name: '2022-01-27T00:00:00Z', value: 0},
  121. {name: '2022-01-28T00:00:00Z', value: 0},
  122. ],
  123. },
  124. {
  125. seriesName: 'sum(sentry.sessions.session)|session.status:healthy|release:1',
  126. data: [
  127. {name: '2022-01-15T00:00:00Z', value: 0},
  128. {name: '2022-01-16T00:00:00Z', value: 0},
  129. {name: '2022-01-17T00:00:00Z', value: 0},
  130. {name: '2022-01-18T00:00:00Z', value: 0},
  131. {name: '2022-01-19T00:00:00Z', value: 0},
  132. {name: '2022-01-20T00:00:00Z', value: 2503},
  133. {name: '2022-01-21T00:00:00Z', value: 661},
  134. {name: '2022-01-22T00:00:00Z', value: 0},
  135. {name: '2022-01-23T00:00:00Z', value: 0},
  136. {name: '2022-01-24T00:00:00Z', value: 1464},
  137. {name: '2022-01-25T00:00:00Z', value: 430},
  138. {name: '2022-01-26T00:00:00Z', value: 0},
  139. {name: '2022-01-27T00:00:00Z', value: 0},
  140. {name: '2022-01-28T00:00:00Z', value: 0},
  141. ],
  142. },
  143. {
  144. seriesName: 'count_unique(sentry.sessions.user)|session.status:healthy|release:1',
  145. data: [
  146. {name: '2022-01-15T00:00:00Z', value: 0},
  147. {name: '2022-01-16T00:00:00Z', value: 0},
  148. {name: '2022-01-17T00:00:00Z', value: 0},
  149. {name: '2022-01-18T00:00:00Z', value: 0},
  150. {name: '2022-01-19T00:00:00Z', value: 0},
  151. {name: '2022-01-20T00:00:00Z', value: 3},
  152. {name: '2022-01-21T00:00:00Z', value: 3},
  153. {name: '2022-01-22T00:00:00Z', value: 0},
  154. {name: '2022-01-23T00:00:00Z', value: 0},
  155. {name: '2022-01-24T00:00:00Z', value: 1},
  156. {name: '2022-01-25T00:00:00Z', value: 1},
  157. {name: '2022-01-26T00:00:00Z', value: 0},
  158. {name: '2022-01-27T00:00:00Z', value: 0},
  159. {name: '2022-01-28T00:00:00Z', value: 0},
  160. ],
  161. },
  162. {
  163. seriesName: 'sum(sentry.sessions.session)|session.status:crashed|release:2',
  164. data: [
  165. {name: '2022-01-15T00:00:00Z', value: 1},
  166. {name: '2022-01-16T00:00:00Z', value: 0},
  167. {name: '2022-01-17T00:00:00Z', value: 0},
  168. {name: '2022-01-18T00:00:00Z', value: 0},
  169. {name: '2022-01-19T00:00:00Z', value: 0},
  170. {name: '2022-01-20T00:00:00Z', value: 0},
  171. {name: '2022-01-21T00:00:00Z', value: 0},
  172. {name: '2022-01-22T00:00:00Z', value: 0},
  173. {name: '2022-01-23T00:00:00Z', value: 0},
  174. {name: '2022-01-24T00:00:00Z', value: 23},
  175. {name: '2022-01-25T00:00:00Z', value: 11},
  176. {name: '2022-01-26T00:00:00Z', value: 0},
  177. {name: '2022-01-27T00:00:00Z', value: 0},
  178. {name: '2022-01-28T00:00:00Z', value: 0},
  179. ],
  180. },
  181. {
  182. seriesName: 'count_unique(sentry.sessions.user)|session.status:crashed|release:2',
  183. data: [
  184. {name: '2022-01-15T00:00:00Z', value: 1},
  185. {name: '2022-01-16T00:00:00Z', value: 0},
  186. {name: '2022-01-17T00:00:00Z', value: 0},
  187. {name: '2022-01-18T00:00:00Z', value: 0},
  188. {name: '2022-01-19T00:00:00Z', value: 0},
  189. {name: '2022-01-20T00:00:00Z', value: 0},
  190. {name: '2022-01-21T00:00:00Z', value: 0},
  191. {name: '2022-01-22T00:00:00Z', value: 0},
  192. {name: '2022-01-23T00:00:00Z', value: 0},
  193. {name: '2022-01-24T00:00:00Z', value: 2},
  194. {name: '2022-01-25T00:00:00Z', value: 2},
  195. {name: '2022-01-26T00:00:00Z', value: 0},
  196. {name: '2022-01-27T00:00:00Z', value: 0},
  197. {name: '2022-01-28T00:00:00Z', value: 0},
  198. ],
  199. },
  200. {
  201. seriesName: 'sum(sentry.sessions.session)|session.status:abnormal|release:2',
  202. data: [
  203. {name: '2022-01-15T00:00:00Z', value: 1},
  204. {name: '2022-01-16T00:00:00Z', value: 0},
  205. {name: '2022-01-17T00:00:00Z', value: 0},
  206. {name: '2022-01-18T00:00:00Z', value: 0},
  207. {name: '2022-01-19T00:00:00Z', value: 0},
  208. {name: '2022-01-20T00:00:00Z', value: 0},
  209. {name: '2022-01-21T00:00:00Z', value: 0},
  210. {name: '2022-01-22T00:00:00Z', value: 0},
  211. {name: '2022-01-23T00:00:00Z', value: 0},
  212. {name: '2022-01-24T00:00:00Z', value: 0},
  213. {name: '2022-01-25T00:00:00Z', value: 0},
  214. {name: '2022-01-26T00:00:00Z', value: 0},
  215. {name: '2022-01-27T00:00:00Z', value: 0},
  216. {name: '2022-01-28T00:00:00Z', value: 0},
  217. ],
  218. },
  219. {
  220. seriesName:
  221. 'count_unique(sentry.sessions.user)|session.status:abnormal|release:2',
  222. data: [
  223. {name: '2022-01-15T00:00:00Z', value: 1},
  224. {name: '2022-01-16T00:00:00Z', value: 0},
  225. {name: '2022-01-17T00:00:00Z', value: 0},
  226. {name: '2022-01-18T00:00:00Z', value: 0},
  227. {name: '2022-01-19T00:00:00Z', value: 0},
  228. {name: '2022-01-20T00:00:00Z', value: 0},
  229. {name: '2022-01-21T00:00:00Z', value: 0},
  230. {name: '2022-01-22T00:00:00Z', value: 0},
  231. {name: '2022-01-23T00:00:00Z', value: 0},
  232. {name: '2022-01-24T00:00:00Z', value: 0},
  233. {name: '2022-01-25T00:00:00Z', value: 0},
  234. {name: '2022-01-26T00:00:00Z', value: 0},
  235. {name: '2022-01-27T00:00:00Z', value: 0},
  236. {name: '2022-01-28T00:00:00Z', value: 0},
  237. ],
  238. },
  239. {
  240. seriesName: 'sum(sentry.sessions.session)|session.status:errored|release:2',
  241. data: [
  242. {name: '2022-01-15T00:00:00Z', value: 1},
  243. {name: '2022-01-16T00:00:00Z', value: 0},
  244. {name: '2022-01-17T00:00:00Z', value: 0},
  245. {name: '2022-01-18T00:00:00Z', value: 0},
  246. {name: '2022-01-19T00:00:00Z', value: 0},
  247. {name: '2022-01-20T00:00:00Z', value: 37},
  248. {name: '2022-01-21T00:00:00Z', value: 0},
  249. {name: '2022-01-22T00:00:00Z', value: 0},
  250. {name: '2022-01-23T00:00:00Z', value: 0},
  251. {name: '2022-01-24T00:00:00Z', value: 335},
  252. {name: '2022-01-25T00:00:00Z', value: 79},
  253. {name: '2022-01-26T00:00:00Z', value: 0},
  254. {name: '2022-01-27T00:00:00Z', value: 0},
  255. {name: '2022-01-28T00:00:00Z', value: 0},
  256. ],
  257. },
  258. {
  259. seriesName: 'count_unique(sentry.sessions.user)|session.status:errored|release:2',
  260. data: [
  261. {name: '2022-01-15T00:00:00Z', value: 1},
  262. {name: '2022-01-16T00:00:00Z', value: 0},
  263. {name: '2022-01-17T00:00:00Z', value: 0},
  264. {name: '2022-01-18T00:00:00Z', value: 0},
  265. {name: '2022-01-19T00:00:00Z', value: 0},
  266. {name: '2022-01-20T00:00:00Z', value: 1},
  267. {name: '2022-01-21T00:00:00Z', value: 0},
  268. {name: '2022-01-22T00:00:00Z', value: 0},
  269. {name: '2022-01-23T00:00:00Z', value: 0},
  270. {name: '2022-01-24T00:00:00Z', value: 1},
  271. {name: '2022-01-25T00:00:00Z', value: 1},
  272. {name: '2022-01-26T00:00:00Z', value: 0},
  273. {name: '2022-01-27T00:00:00Z', value: 0},
  274. {name: '2022-01-28T00:00:00Z', value: 0},
  275. ],
  276. },
  277. {
  278. seriesName: 'sum(sentry.sessions.session)|session.status:healthy|release:2',
  279. data: [
  280. {name: '2022-01-15T00:00:00Z', value: 1},
  281. {name: '2022-01-16T00:00:00Z', value: 0},
  282. {name: '2022-01-17T00:00:00Z', value: 0},
  283. {name: '2022-01-18T00:00:00Z', value: 0},
  284. {name: '2022-01-19T00:00:00Z', value: 0},
  285. {name: '2022-01-20T00:00:00Z', value: 2503},
  286. {name: '2022-01-21T00:00:00Z', value: 661},
  287. {name: '2022-01-22T00:00:00Z', value: 0},
  288. {name: '2022-01-23T00:00:00Z', value: 0},
  289. {name: '2022-01-24T00:00:00Z', value: 1464},
  290. {name: '2022-01-25T00:00:00Z', value: 430},
  291. {name: '2022-01-26T00:00:00Z', value: 0},
  292. {name: '2022-01-27T00:00:00Z', value: 0},
  293. {name: '2022-01-28T00:00:00Z', value: 0},
  294. ],
  295. },
  296. {
  297. seriesName: 'count_unique(sentry.sessions.user)|session.status:healthy|release:2',
  298. data: [
  299. {name: '2022-01-15T00:00:00Z', value: 1},
  300. {name: '2022-01-16T00:00:00Z', value: 0},
  301. {name: '2022-01-17T00:00:00Z', value: 0},
  302. {name: '2022-01-18T00:00:00Z', value: 0},
  303. {name: '2022-01-19T00:00:00Z', value: 0},
  304. {name: '2022-01-20T00:00:00Z', value: 10},
  305. {name: '2022-01-21T00:00:00Z', value: 3},
  306. {name: '2022-01-22T00:00:00Z', value: 0},
  307. {name: '2022-01-23T00:00:00Z', value: 0},
  308. {name: '2022-01-24T00:00:00Z', value: 4},
  309. {name: '2022-01-25T00:00:00Z', value: 3},
  310. {name: '2022-01-26T00:00:00Z', value: 0},
  311. {name: '2022-01-27T00:00:00Z', value: 0},
  312. {name: '2022-01-28T00:00:00Z', value: 0},
  313. ],
  314. },
  315. ]);
  316. });
  317. it('supports legend aliases', () => {
  318. expect(
  319. transformMetricsResponseToSeries(
  320. TestStubs.MetricsSessionUserCountByStatusByRelease(),
  321. 'Lorem'
  322. )[0]
  323. ).toEqual(
  324. expect.objectContaining({
  325. seriesName:
  326. 'Lorem: sum(sentry.sessions.session)|session.status:crashed|release:1',
  327. })
  328. );
  329. });
  330. });