Skip to content

Commit

Permalink
feat(alerts): add special tag frequency condition
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshFerge committed Oct 17, 2024
1 parent f4d7b1d commit 158c3c4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions static/app/types/alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const enum IssueAlertConditionType {
REAPPEARED_EVENT = 'sentry.rules.conditions.reappeared_event.ReappearedEventCondition',
EVENT_FREQUENCY = 'sentry.rules.conditions.event_frequency.EventFrequencyCondition',
EVENT_UNIQUE_USER_FREQUENCY = 'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition',
EVENT_UNIQUE_USER_FREQUENCY_WITH_CONDITIONS = 'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyConditionWithConditions',
EVENT_FREQUENCY_PERCENT = 'sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition',
NEW_HIGH_PRIORITY_ISSUE = 'sentry.rules.conditions.high_priority_issue.NewHighPriorityIssueCondition',
EXISTING_HIGH_PRIORITY_ISSUE = 'sentry.rules.conditions.high_priority_issue.ExistingHighPriorityIssueCondition',
Expand Down
23 changes: 19 additions & 4 deletions static/app/views/alerts/rules/issue/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -794,17 +794,32 @@ class IssueRuleEditor extends DeprecatedAsyncView<Props, State> {
if (!organization.features.includes('change-alerts')) {
return this.state.configs?.conditions ?? null;
}
let conditions = this.state.configs?.conditions ?? null;

return (
this.state.configs?.conditions?.map(condition =>
if (
!organization.features.includes(
'event-unique-user-frequency-condition-with-conditions'
)
) {
conditions =
conditions?.filter(
condition =>
condition.id !==
'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyConditionWithConditions'
) ?? null;
}

conditions =
conditions?.map(condition =>
CHANGE_ALERT_CONDITION_IDS.includes(condition.id)
? {
...condition,
label: `${CHANGE_ALERT_PLACEHOLDERS_LABELS[condition.id]}...`,
}
: condition
) ?? null
);
) ?? null;

return conditions;
}

getTeamId = () => {
Expand Down
3 changes: 3 additions & 0 deletions static/app/views/alerts/utils/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const CHANGE_ALERT_CONDITION_IDS = [
'sentry.rules.conditions.event_frequency.EventFrequencyCondition',
'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition',
'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyConditionWithConditions',
'sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition',
];

Expand All @@ -9,6 +10,8 @@ export const CHANGE_ALERT_PLACEHOLDERS_LABELS = {
'Number of events in an issue is',
'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition':
'Number of users affected by an issue is',
'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyConditionWithConditions':
'Number of users affected by an issue (with tag values equal) is',
'sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition':
'Percent of sessions affected by an issue is',
};
Expand Down

0 comments on commit 158c3c4

Please sign in to comment.