Skip to content

Commit dc9bf43

Browse files
authored
chore(anomaly detection): Remove unused code (#89998)
An attempt at the FE counterpart to https://github.com/getsentry/sentry/pull/89406/files to remove code around a feature flag that we never ended up using.
1 parent 4042a01 commit dc9bf43

File tree

4 files changed

+7
-83
lines changed

4 files changed

+7
-83
lines changed

static/app/views/alerts/rules/metric/details/index.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ import {
2424
AlertRuleComparisonType,
2525
TimePeriod,
2626
} from 'sentry/views/alerts/rules/metric/types';
27-
import type {Anomaly, Incident} from 'sentry/views/alerts/types';
27+
import type {Incident} from 'sentry/views/alerts/types';
2828
import {
2929
fetchAlertRule,
30-
fetchAnomaliesForRule,
3130
fetchIncident,
3231
fetchIncidentsForRule,
3332
} from 'sentry/views/alerts/utils/apiCalls';
@@ -51,7 +50,6 @@ interface State {
5150
hasError: boolean;
5251
isLoading: boolean;
5352
selectedIncident: Incident | null;
54-
anomalies?: Anomaly[];
5553
incidents?: Incident[];
5654
rule?: MetricRule;
5755
warning?: string;
@@ -217,24 +215,16 @@ class MetricAlertDetails extends Component<Props, State> {
217215
const timePeriod = this.getTimePeriod(selectedIncident);
218216
const {start, end} = timePeriod;
219217
try {
220-
const [incidents, rule, anomalies] = await Promise.all([
218+
const [incidents, rule] = await Promise.all([
221219
fetchIncidentsForRule(organization.slug, ruleId, start, end),
222220
rulePromise,
223-
organization.features.includes('anomaly-detection-alerts-charts')
224-
? fetchAnomaliesForRule(organization.slug, ruleId, start, end)
225-
: undefined, // NOTE: there's no way for us to determine the alert rule detection type here.
226-
// proxy API will need to determine whether to fetch anomalies or not
227221
]);
228-
// NOTE: 'anomaly-detection-alerts-charts' flag does not exist
229-
// Flag can be enabled IF we want to enable marked lines/areas for anomalies in the future
230-
// For now, we defer to incident lines as indicators for anomalies
231222
let warning: any;
232223
if (rule.status === ALERT_RULE_STATUS.NOT_ENOUGH_DATA) {
233224
warning =
234225
'Insufficient data for anomaly detection. This feature will enable automatically when more data is available.';
235226
}
236227
this.setState({
237-
anomalies,
238228
incidents,
239229
rule,
240230
warning,
@@ -264,7 +254,7 @@ class MetricAlertDetails extends Component<Props, State> {
264254
}
265255

266256
render() {
267-
const {rule, incidents, hasError, selectedIncident, anomalies, warning} = this.state;
257+
const {rule, incidents, hasError, selectedIncident, warning} = this.state;
268258
const {organization, projects, loadingProjects} = this.props;
269259
const timePeriod = this.getTimePeriod(selectedIncident);
270260

@@ -302,7 +292,6 @@ class MetricAlertDetails extends Component<Props, State> {
302292
rule={rule}
303293
project={project}
304294
incidents={incidents}
305-
anomalies={anomalies}
306295
timePeriod={timePeriod}
307296
selectedIncident={selectedIncident}
308297
/>

static/app/views/alerts/utils/apiCalls.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Client} from 'sentry/api';
22
import type {MetricRule} from 'sentry/views/alerts/rules/metric/types';
3-
import type {Anomaly, Incident} from 'sentry/views/alerts/types';
3+
import type {Incident} from 'sentry/views/alerts/types';
44

55
// Use this api for requests that are getting cancelled
66
const uncancellableApi = new Client();
@@ -41,20 +41,3 @@ export function fetchIncident(
4141
): Promise<Incident> {
4242
return api.requestPromise(`/organizations/${orgId}/incidents/${alertId}/`);
4343
}
44-
45-
export function fetchAnomaliesForRule(
46-
orgId: string,
47-
ruleId: string,
48-
start: string,
49-
end: string
50-
): Promise<Anomaly[]> {
51-
return uncancellableApi.requestPromise(
52-
`/organizations/${orgId}/alert-rules/${ruleId}/anomalies/`,
53-
{
54-
query: {
55-
start,
56-
end,
57-
},
58-
}
59-
);
60-
}

static/app/views/issueDetails/metricIssues/metricIssueChart.tsx

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import useOrganization from 'sentry/utils/useOrganization';
1212
import type {TimePeriodType} from 'sentry/views/alerts/rules/metric/details/constants';
1313
import type {MetricRule} from 'sentry/views/alerts/rules/metric/types';
1414
import {useMetricRule} from 'sentry/views/alerts/rules/metric/utils/useMetricRule';
15-
import type {Anomaly, Incident} from 'sentry/views/alerts/types';
16-
import {useMetricAnomalies} from 'sentry/views/issueDetails/metricIssues/useMetricAnomalies';
15+
import type {Incident} from 'sentry/views/alerts/types';
1716
import {useMetricIncidents} from 'sentry/views/issueDetails/metricIssues/useMetricIncidents';
1817
import {useMetricStatsChart} from 'sentry/views/issueDetails/metricIssues/useMetricStatsChart';
1918
import {
@@ -49,20 +48,7 @@ export function MetricIssueChart({group, project}: MetricIssueChartProps) {
4948
enabled: !!ruleId,
5049
}
5150
);
52-
const {data: anomalies = [], isLoading: isAnomaliesLoading} = useMetricAnomalies(
53-
{
54-
orgSlug: organization.slug,
55-
ruleId: ruleId ?? '',
56-
query: {
57-
start: timePeriod.start,
58-
end: timePeriod.end,
59-
},
60-
},
61-
{
62-
enabled:
63-
!!ruleId && organization.features.includes('anomaly-detection-alerts-charts'),
64-
}
65-
);
51+
6652
const {data: incidents = [], isLoading: isIncidentsLoading} = useMetricIncidents(
6753
{
6854
orgSlug: organization.slug,
@@ -78,7 +64,7 @@ export function MetricIssueChart({group, project}: MetricIssueChartProps) {
7864
}
7965
);
8066

81-
if (isRuleLoading || isAnomaliesLoading || isIncidentsLoading || !rule) {
67+
if (isRuleLoading || isIncidentsLoading || !rule) {
8268
return (
8369
<MetricChartSection>
8470
<MetricIssuePlaceholder type="loading" />
@@ -96,7 +82,6 @@ export function MetricIssueChart({group, project}: MetricIssueChartProps) {
9682
rule={rule}
9783
timePeriod={timePeriod}
9884
project={project}
99-
anomalies={anomalies}
10085
incidents={incidents}
10186
/>
10287
</MetricChartSection>
@@ -110,21 +95,18 @@ function MetricIssueChartContent({
11095
rule,
11196
timePeriod,
11297
project,
113-
anomalies,
11498
incidents,
11599
}: {
116100
project: Project;
117101
rule: MetricRule;
118102
timePeriod: TimePeriodType;
119-
anomalies?: Anomaly[];
120103
incidents?: Incident[];
121104
}) {
122105
const chartZoomProps = useChartZoom({saveOnZoom: true});
123106
const {chartProps, queryResult} = useMetricStatsChart({
124107
project,
125108
rule,
126109
timePeriod,
127-
anomalies,
128110
incidents,
129111
referrer: 'metric-issue-chart',
130112
});

static/app/views/issueDetails/metricIssues/useMetricAnomalies.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)