Skip to content

Commit fac6fc6

Browse files
malwilleyandrewshie-sentry
authored andcommitted
fix(alerts): Display correct filter key options for sessions data (#97352)
Crash free session/user rate uses the metrics dataset, which only has a few valid options. Attempting to save with anything else will result in an error. This updates the autocomplete so that it limits to these options when that dataset is selected.
1 parent c5f33ad commit fac6fc6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

static/app/views/alerts/rules/metric/ruleConditionsForm.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import {
6666
getSupportedAndOmittedTags,
6767
} from 'sentry/views/alerts/wizard/options';
6868
import {getTraceItemTypeForDatasetAndEventType} from 'sentry/views/alerts/wizard/utils';
69+
import {SESSIONS_FILTER_TAGS} from 'sentry/views/dashboards/widgetBuilder/releaseWidget/fields';
6970
import {TraceItemSearchQueryBuilder} from 'sentry/views/explore/components/traceItemSearchQueryBuilder';
7071
import {
7172
TraceItemAttributeProvider,
@@ -137,7 +138,7 @@ class RuleConditionsForm extends PureComponent<Props, State> {
137138
}
138139

139140
componentDidUpdate(prevProps: Props) {
140-
if (prevProps.tags !== this.props.tags) {
141+
if (prevProps.dataset !== this.props.dataset || prevProps.tags !== this.props.tags) {
141142
const filterKeys = this.getFilterKeys();
142143
this.setState({filterKeys});
143144
}
@@ -150,6 +151,16 @@ class RuleConditionsForm extends PureComponent<Props, State> {
150151
getFilterKeys = () => {
151152
const {organization, dataset, tags} = this.props;
152153
const {measurements} = this.state;
154+
155+
if (dataset === Dataset.METRICS) {
156+
return Object.values(SESSIONS_FILTER_TAGS)
157+
.filter(key => key !== 'project') // Already have the project selector
158+
.reduce<TagCollection>((acc, key) => {
159+
acc[key] = {key, name: key};
160+
return acc;
161+
}, {});
162+
}
163+
153164
const measurementsWithKind = Object.keys(measurements).reduce(
154165
(measurement_tags, key) => {
155166
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message

0 commit comments

Comments
 (0)