utils.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type {Organization} from 'sentry/types/organization';
  2. import type {MetricsCardinalityContext} from 'sentry/utils/performance/contexts/metricsCardinality';
  3. import type {MetricsEnhancedPerformanceDataContext} from 'sentry/utils/performance/contexts/metricsEnhancedPerformanceDataContext';
  4. import type {MetricsEnhancedSettingContext} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  5. import {canUseMetricsData} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  6. import {getMEPQueryParams} from 'sentry/views/performance/landing/widgets/utils';
  7. export function canUseTransactionMetricsData(
  8. organization: Organization,
  9. mepDataContext: MetricsEnhancedPerformanceDataContext
  10. ) {
  11. const isUsingMetrics = canUseMetricsData(organization);
  12. if (!isUsingMetrics) {
  13. return false;
  14. }
  15. if (mepDataContext.isMetricsData === false) {
  16. return false;
  17. }
  18. return true;
  19. }
  20. export function getTransactionMEPParamsIfApplicable(
  21. mepSetting: MetricsEnhancedSettingContext,
  22. mepCardinality: MetricsCardinalityContext,
  23. organization: Organization
  24. ) {
  25. if (!canUseMetricsData(organization)) {
  26. return undefined;
  27. }
  28. if (mepCardinality.outcome?.forceTransactionsOnly) {
  29. return undefined;
  30. }
  31. return getMEPQueryParams(mepSetting, true);
  32. }