getMetricDatasetQueryExtras.tsx 846 B

123456789101112131415161718192021222324252627282930
  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 = organization.features.includes('mep-rollout-flag');
  18. const disableMetricDataset =
  19. decodeScalar(location?.query?.disableMetricDataset) === 'true';
  20. const queryExtras: Record<string, string> =
  21. hasMetricDataset && !disableMetricDataset
  22. ? {dataset: getMEPAlertsDataset(dataset, newAlertOrQuery)}
  23. : {};
  24. return queryExtras;
  25. }