mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import type {Location} from 'history';
|
|
|
|
import type {Organization} from 'sentry/types';
|
|
import {hasOnDemandMetricAlertFeature} from 'sentry/utils/onDemandMetrics/features';
|
|
import {decodeScalar} from 'sentry/utils/queryString';
|
|
import {getMEPAlertsDataset} from 'sentry/views/alerts/wizard/options';
|
|
|
|
import type {MetricRule} from '../types';
|
|
|
|
export function getMetricDatasetQueryExtras({
|
|
organization,
|
|
location,
|
|
dataset,
|
|
newAlertOrQuery,
|
|
useOnDemandMetrics,
|
|
}: {
|
|
dataset: MetricRule['dataset'];
|
|
newAlertOrQuery: boolean;
|
|
organization: Organization;
|
|
location?: Location;
|
|
useOnDemandMetrics?: boolean;
|
|
}) {
|
|
const hasMetricDataset =
|
|
hasOnDemandMetricAlertFeature(organization) ||
|
|
organization.features.includes('mep-rollout-flag');
|
|
const disableMetricDataset =
|
|
decodeScalar(location?.query?.disableMetricDataset) === 'true';
|
|
|
|
const queryExtras: Record<string, string> =
|
|
hasMetricDataset && !disableMetricDataset
|
|
? {dataset: getMEPAlertsDataset(dataset, newAlertOrQuery)}
|
|
: {};
|
|
|
|
if (useOnDemandMetrics) {
|
|
queryExtras.useOnDemandMetrics = 'true';
|
|
}
|
|
|
|
return queryExtras;
|
|
}
|