getMetricDatasetQueryExtras.tsx 918 B

1234567891011121314151617181920212223242526272829303132
  1. import {Location} from 'history';
  2. import {Organization} from 'sentry/types';
  3. import {decodeScalar} from 'sentry/utils/queryString';
  4. import {getMEPAlertsDataset} from 'sentry/views/alerts/wizard/options';
  5. import {MetricRule} from '../types';
  6. export function getMetricDatasetQueryExtras({
  7. organization,
  8. location,
  9. dataset,
  10. newAlertOrQuery,
  11. }: {
  12. dataset: MetricRule['dataset'];
  13. newAlertOrQuery: boolean;
  14. organization: Organization;
  15. location?: Location;
  16. }) {
  17. const hasMetricDataset =
  18. organization.features.includes('metrics-performance-alerts') ||
  19. organization.features.includes('mep-rollout-flag');
  20. const disableMetricDataset =
  21. decodeScalar(location?.query?.disableMetricDataset) === 'true';
  22. const queryExtras: Record<string, string> =
  23. hasMetricDataset && !disableMetricDataset
  24. ? {dataset: getMEPAlertsDataset(dataset, newAlertOrQuery)}
  25. : {};
  26. return queryExtras;
  27. }