data.tsx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import {t} from 'sentry/locale';
  2. import {TOP_N} from 'sentry/utils/discover/types';
  3. import {DisplayType, Widget, WidgetType} from '../types';
  4. export type WidgetTemplate = Widget & {
  5. description: string;
  6. };
  7. export const DEFAULT_WIDGETS: Readonly<Array<WidgetTemplate>> = [
  8. {
  9. id: 'duration-distribution',
  10. title: t('Duration Distribution'),
  11. description: t('Compare transaction durations across different percentiles.'),
  12. displayType: DisplayType.LINE,
  13. widgetType: WidgetType.DISCOVER,
  14. interval: '5m',
  15. queries: [
  16. {
  17. name: '',
  18. conditions: 'event.type:transaction',
  19. fields: [
  20. 'p50(transaction.duration)',
  21. 'p75(transaction.duration)',
  22. 'p95(transaction.duration)',
  23. ],
  24. aggregates: [
  25. 'p50(transaction.duration)',
  26. 'p75(transaction.duration)',
  27. 'p95(transaction.duration)',
  28. ],
  29. columns: [],
  30. orderby: '',
  31. },
  32. ],
  33. },
  34. {
  35. id: 'high-throughput-transactions',
  36. title: t('High Throughput Transactions'),
  37. description: t('Top 5 transactions with the largest volume.'),
  38. displayType: DisplayType.TOP_N,
  39. widgetType: WidgetType.DISCOVER,
  40. interval: '5m',
  41. queries: [
  42. {
  43. name: '',
  44. conditions: 'event.type:transaction',
  45. fields: ['transaction', 'count()'],
  46. aggregates: ['count()'],
  47. columns: ['transaction'],
  48. orderby: '-count()',
  49. },
  50. ],
  51. },
  52. {
  53. id: 'crash-rates-recent-releases',
  54. title: t('Crash Rates for Recent Releases'),
  55. description: t('Percentage of crashed sessions for latest releases.'),
  56. displayType: DisplayType.LINE,
  57. widgetType: WidgetType.RELEASE,
  58. interval: '5m',
  59. limit: 8,
  60. queries: [
  61. {
  62. name: '',
  63. conditions: '',
  64. fields: ['crash_rate(session)', 'release'],
  65. aggregates: ['crash_rate(session)'],
  66. columns: ['release'],
  67. orderby: '-release',
  68. },
  69. ],
  70. },
  71. {
  72. id: 'session-health',
  73. title: t('Session Health'),
  74. description: t('Number of abnormal, crashed, errored and healthy sessions.'),
  75. displayType: DisplayType.TABLE,
  76. widgetType: WidgetType.RELEASE,
  77. interval: '5m',
  78. queries: [
  79. {
  80. name: '',
  81. conditions: '',
  82. fields: ['session.status', 'sum(session)'],
  83. aggregates: ['sum(session)'],
  84. columns: ['session.status'],
  85. orderby: '',
  86. },
  87. ],
  88. },
  89. {
  90. id: 'lcp-country',
  91. title: t('LCP by Country'),
  92. description: t('Density map showing page load times by country.'),
  93. displayType: DisplayType.WORLD_MAP,
  94. widgetType: WidgetType.DISCOVER,
  95. interval: '5m',
  96. queries: [
  97. {
  98. name: '',
  99. conditions: 'has:geo.country_code',
  100. fields: ['p75(measurements.lcp)'],
  101. aggregates: ['p75(measurements.lcp)'],
  102. columns: [],
  103. orderby: '',
  104. },
  105. ],
  106. },
  107. {
  108. id: 'miserable-users',
  109. title: t('Miserable Users'),
  110. description: t('Unique users who have experienced slow load times.'),
  111. displayType: DisplayType.BIG_NUMBER,
  112. widgetType: WidgetType.DISCOVER,
  113. interval: '5m',
  114. queries: [
  115. {
  116. name: '',
  117. conditions: '',
  118. fields: ['count_miserable(user,300)'],
  119. aggregates: ['count_miserable(user,300)'],
  120. columns: [],
  121. orderby: '',
  122. },
  123. ],
  124. },
  125. {
  126. id: 'slow-vs-fast',
  127. title: t('Slow vs. Fast Transactions'),
  128. description: t('Percentage breakdown of transaction durations over and under 300ms.'),
  129. displayType: DisplayType.BAR,
  130. widgetType: WidgetType.DISCOVER,
  131. interval: '5m',
  132. queries: [
  133. {
  134. name: '',
  135. conditions: 'event.type:transaction',
  136. fields: [
  137. 'equation|(count_if(transaction.duration,greater,300) / count()) * 100',
  138. 'equation|(count_if(transaction.duration,lessOrEquals,300) / count()) * 100',
  139. ],
  140. aggregates: [
  141. 'equation|(count_if(transaction.duration,greater,300) / count()) * 100',
  142. 'equation|(count_if(transaction.duration,lessOrEquals,300) / count()) * 100',
  143. ],
  144. columns: [],
  145. orderby: '',
  146. },
  147. ],
  148. },
  149. {
  150. id: 'issue-for-review',
  151. title: t('Issues For Review'),
  152. description: t('Most recently seen unresolved issues for review.'),
  153. displayType: DisplayType.TABLE,
  154. widgetType: WidgetType.ISSUE,
  155. interval: '5m',
  156. queries: [
  157. {
  158. name: '',
  159. conditions: 'is:unresolved is:for_review',
  160. fields: ['issue', 'assignee', 'events', 'title'],
  161. aggregates: [],
  162. columns: ['issue', 'assignee', 'events', 'title'],
  163. orderby: 'date',
  164. },
  165. ],
  166. },
  167. {
  168. id: 'top-unhandled',
  169. title: t('Top Unhandled Error Types'),
  170. description: t('Most frequently encountered unhandled errors.'),
  171. displayType: DisplayType.TOP_N,
  172. widgetType: WidgetType.DISCOVER,
  173. interval: '5m',
  174. queries: [
  175. {
  176. name: '',
  177. conditions: 'error.unhandled:true',
  178. fields: ['error.type', 'count()'],
  179. aggregates: ['count()'],
  180. columns: ['error.type'],
  181. orderby: '-count()',
  182. },
  183. ],
  184. },
  185. {
  186. id: 'users-affected',
  187. title: t('Users Affected by Errors'),
  188. description: t('Footprint of unique users affected by errors.'),
  189. displayType: DisplayType.LINE,
  190. widgetType: WidgetType.DISCOVER,
  191. interval: '5m',
  192. queries: [
  193. {
  194. name: '',
  195. conditions: 'event.type:error',
  196. fields: ['count_unique(user)', 'count()'],
  197. aggregates: ['count_unique(user)', 'count()'],
  198. columns: [],
  199. orderby: '',
  200. },
  201. ],
  202. },
  203. ];
  204. export function getTopNConvertedDefaultWidgets(): Readonly<Array<WidgetTemplate>> {
  205. return DEFAULT_WIDGETS.map(widget => {
  206. if (widget.displayType === DisplayType.TOP_N) {
  207. return {
  208. ...widget,
  209. displayType: DisplayType.AREA,
  210. limit: TOP_N,
  211. };
  212. }
  213. return widget;
  214. });
  215. }