data.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import {t} from 'sentry/locale';
  2. import type {NewQuery, Organization} from 'sentry/types/organization';
  3. import {SavedQueryDatasets} from 'sentry/utils/discover/types';
  4. import {hasDatasetSelector} from 'sentry/views/dashboards/utils';
  5. export const DEFAULT_EVENT_VIEW: Readonly<NewQuery> = {
  6. id: undefined,
  7. name: t('All Events'),
  8. query: '',
  9. projects: [],
  10. fields: ['title', 'event.type', 'project', 'user.display', 'timestamp'],
  11. orderby: '-timestamp',
  12. version: 2,
  13. range: '24h',
  14. queryDataset: SavedQueryDatasets.ERRORS,
  15. };
  16. const DEFAULT_TRANSACTION_VIEW: Readonly<NewQuery> = {
  17. id: undefined,
  18. name: t('All Transactions'),
  19. query: '',
  20. projects: [],
  21. fields: ['title', 'project', 'user.display', 'timestamp'],
  22. orderby: '-timestamp',
  23. version: 2,
  24. range: '24h',
  25. queryDataset: SavedQueryDatasets.TRANSACTIONS,
  26. };
  27. const DEFAULT_ERROR_VIEW: Readonly<NewQuery> = {
  28. id: undefined,
  29. name: t('All Errors'),
  30. query: '',
  31. projects: [],
  32. fields: ['title', 'project', 'user.display', 'timestamp'],
  33. orderby: '-timestamp',
  34. version: 2,
  35. range: '24h',
  36. queryDataset: SavedQueryDatasets.ERRORS,
  37. };
  38. export const DEFAULT_EVENT_VIEW_MAP: Record<SavedQueryDatasets, Readonly<NewQuery>> = {
  39. [SavedQueryDatasets.DISCOVER]: DEFAULT_EVENT_VIEW,
  40. [SavedQueryDatasets.ERRORS]: DEFAULT_ERROR_VIEW,
  41. [SavedQueryDatasets.TRANSACTIONS]: DEFAULT_TRANSACTION_VIEW,
  42. };
  43. export const getTransactionViews = (organization: Organization) => {
  44. const hasDatasetSelectorFeature = hasDatasetSelector(organization);
  45. return [
  46. {
  47. id: undefined,
  48. name: t('Transactions by Volume'),
  49. fields: [
  50. 'transaction',
  51. 'project',
  52. 'count()',
  53. 'avg(transaction.duration)',
  54. 'p75()',
  55. 'p95()',
  56. ],
  57. orderby: '-count',
  58. query: hasDatasetSelectorFeature ? '' : 'event.type:transaction',
  59. projects: [],
  60. version: 2,
  61. range: '24h',
  62. queryDataset: SavedQueryDatasets.TRANSACTIONS,
  63. },
  64. ] as Readonly<Array<NewQuery>>;
  65. };
  66. export const getWebVitalsViews = (organization: Organization) => {
  67. const hasDatasetSelectorFeature = hasDatasetSelector(organization);
  68. return [
  69. {
  70. id: undefined,
  71. name: t('Web Vitals'),
  72. fields: [
  73. 'transaction',
  74. 'epm()',
  75. 'p75(measurements.fp)',
  76. 'p75(measurements.fcp)',
  77. 'p75(measurements.lcp)',
  78. 'p75(measurements.fid)',
  79. 'p75(measurements.cls)',
  80. ],
  81. orderby: '-epm',
  82. query: hasDatasetSelectorFeature
  83. ? 'transaction.op:pageload'
  84. : 'event.type:transaction transaction.op:pageload',
  85. projects: [],
  86. version: 2,
  87. range: '24h',
  88. yAxis: ['epm()'],
  89. queryDataset: SavedQueryDatasets.TRANSACTIONS,
  90. },
  91. ] as Readonly<Array<NewQuery>>;
  92. };
  93. export const getAllViews = (organization: Organization) => {
  94. const hasDatasetSelectorFeature = hasDatasetSelector(organization);
  95. return [
  96. DEFAULT_EVENT_VIEW,
  97. {
  98. id: undefined,
  99. name: t('Errors by Title'),
  100. fields: ['title', 'count()', 'count_unique(user)', 'project'],
  101. orderby: '-count',
  102. query: hasDatasetSelectorFeature ? '' : 'event.type:error',
  103. projects: [],
  104. version: 2,
  105. range: '24h',
  106. display: 'top5',
  107. queryDataset: SavedQueryDatasets.ERRORS,
  108. },
  109. {
  110. id: undefined,
  111. name: t('Errors by URL'),
  112. fields: ['url', 'count()', 'count_unique(issue)'],
  113. orderby: '-count',
  114. query: hasDatasetSelectorFeature ? 'has:url' : 'event.type:error has:url',
  115. projects: [],
  116. version: 2,
  117. range: '24h',
  118. display: 'top5',
  119. queryDataset: SavedQueryDatasets.ERRORS,
  120. },
  121. ] as Readonly<Array<NewQuery>>;
  122. };