@@ -19,17 +19,23 @@ import {
1919 DataConditionType ,
2020 DetectorPriorityLevel ,
2121} from 'sentry/types/workflowEngine/dataConditions' ;
22- import type { Detector , MetricDetectorConfig } from 'sentry/types/workflowEngine/detectors' ;
22+ import type {
23+ Detector ,
24+ MetricDetector ,
25+ MetricDetectorConfig ,
26+ } from 'sentry/types/workflowEngine/detectors' ;
2327import { generateFieldAsString } from 'sentry/utils/discover/fields' ;
2428import useOrganization from 'sentry/utils/useOrganization' ;
2529import {
2630 AlertRuleSensitivity ,
2731 AlertRuleThresholdType ,
32+ Dataset ,
2833} from 'sentry/views/alerts/rules/metric/types' ;
2934import { hasLogAlerts } from 'sentry/views/alerts/wizard/utils' ;
3035import { TransactionsDatasetWarning } from 'sentry/views/detectors/components/details/metric/transactionsDatasetWarning' ;
3136import { AutomateSection } from 'sentry/views/detectors/components/forms/automateSection' ;
3237import { AssignSection } from 'sentry/views/detectors/components/forms/common/assignSection' ;
38+ import { useDetectorFormContext } from 'sentry/views/detectors/components/forms/context' ;
3339import { EditDetectorLayout } from 'sentry/views/detectors/components/forms/editDetectorLayout' ;
3440import type { MetricDetectorFormData } from 'sentry/views/detectors/components/forms/metric/metricFormData' ;
3541import {
@@ -48,6 +54,7 @@ import {SectionLabel} from 'sentry/views/detectors/components/forms/sectionLabel
4854import { getDatasetConfig } from 'sentry/views/detectors/datasetConfig/getDatasetConfig' ;
4955import { DetectorDataset } from 'sentry/views/detectors/datasetConfig/types' ;
5056import { getStaticDetectorThresholdSuffix } from 'sentry/views/detectors/utils/metricDetectorSuffix' ;
57+ import { deprecateTransactionAlerts } from 'sentry/views/insights/common/utils/hasEAPAlerts' ;
5158
5259function MetricDetectorForm ( ) {
5360 return (
@@ -212,16 +219,29 @@ function IntervalPicker() {
212219function useDatasetChoices ( ) {
213220 const organization = useOrganization ( ) ;
214221
222+ const { detector} = useDetectorFormContext ( ) ;
223+ const savedDataset = ( detector as MetricDetector | undefined ) ?. dataSources [ 0 ] ?. queryObj
224+ ?. snubaQuery ?. dataset ;
225+ const isExistingTransactionsDetector =
226+ Boolean ( detector ) &&
227+ [ Dataset . TRANSACTIONS , Dataset . GENERIC_METRICS ] . includes ( savedDataset as Dataset ) ;
228+ const shouldHideTransactionsDataset =
229+ ! isExistingTransactionsDetector && deprecateTransactionAlerts ( organization ) ;
230+
215231 return useMemo ( ( ) => {
216232 const datasetChoices : Array < SelectValue < DetectorDataset > > = [
217233 {
218234 value : DetectorDataset . ERRORS ,
219235 label : t ( 'Errors' ) ,
220236 } ,
221- {
222- value : DetectorDataset . TRANSACTIONS ,
223- label : t ( 'Transactions' ) ,
224- } ,
237+ ...( shouldHideTransactionsDataset
238+ ? [ ]
239+ : [
240+ {
241+ value : DetectorDataset . TRANSACTIONS ,
242+ label : t ( 'Transactions' ) ,
243+ } ,
244+ ] ) ,
225245 ...( organization . features . includes ( 'visibility-explore-view' )
226246 ? [ { value : DetectorDataset . SPANS , label : t ( 'Spans' ) } ]
227247 : [ ] ) ,
@@ -238,7 +258,7 @@ function useDatasetChoices() {
238258 ] ;
239259
240260 return datasetChoices ;
241- } , [ organization ] ) ;
261+ } , [ organization , shouldHideTransactionsDataset ] ) ;
242262}
243263
244264function DetectSection ( ) {
0 commit comments