Skip to content

feat(aci): add eventUniqueUserFrequency and percentSessions data condition nodes #91826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions static/app/types/workflowEngine/dataConditions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export enum DataConditionType {

// frequency types for UI only
EVENT_FREQUENCY = 'event_frequency',
EVENT_UNIQUE_USER_FREQUENCY = 'event_unique_user_frequency',
PERCENT_SESSIONS = 'percent_sessions',
}

export enum DataConditionGroupLogicType {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import AutomationBuilderNumberField from 'sentry/components/workflowEngine/form/automationBuilderNumberField';
import AutomationBuilderSelectField from 'sentry/components/workflowEngine/form/automationBuilderSelectField';
import {tct} from 'sentry/locale';
import {
COMPARISON_INTERVAL_CHOICES,
INTERVAL_CHOICES,
} from 'sentry/views/automations/components/actionFilters/constants';
import {useDataConditionNodeContext} from 'sentry/views/automations/components/dataConditionNodes';

export function CountBranch() {
return tct('more than [value] [interval]', {
value: <ValueField />,
interval: <IntervalField />,
});
}

export function PercentBranch() {
return tct('[value] higher [interval] compared to [comparison_interval]', {
value: <ValueField />,
interval: <IntervalField />,
comparison_interval: <ComparisonIntervalField />,
});
}

function ValueField() {
const {condition, condition_id, onUpdate} = useDataConditionNodeContext();
return (
<AutomationBuilderNumberField
name={`${condition_id}.comparison.value`}
value={condition.comparison.value}
min={1}
step={1}
onChange={(value: string) => {
onUpdate({
value,
});
}}
/>
);
}

function IntervalField() {
const {condition, condition_id, onUpdate} = useDataConditionNodeContext();
return (
<AutomationBuilderSelectField
name={`${condition_id}.comparison.interval`}
value={condition.comparison.interval}
options={INTERVAL_CHOICES}
onChange={(value: string) => {
onUpdate({
interval: value,
});
}}
/>
);
}

function ComparisonIntervalField() {
const {condition, condition_id, onUpdate} = useDataConditionNodeContext();
return (
<AutomationBuilderSelectField
name={`${condition_id}.comparison.comparison_interval`}
value={condition.comparison.comparison_interval}
options={COMPARISON_INTERVAL_CHOICES}
onChange={(value: string) => {
onUpdate({
comparison_interval: value,
});
}}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const FILTER_DATA_CONDITION_TYPES = [
DataConditionType.TAGGED_EVENT,
DataConditionType.LEVEL,
DataConditionType.EVENT_FREQUENCY,
DataConditionType.EVENT_UNIQUE_USER_FREQUENCY,
DataConditionType.PERCENT_SESSIONS,
];

export enum MatchType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import AutomationBuilderNumberField from 'sentry/components/workflowEngine/form/automationBuilderNumberField';
import AutomationBuilderSelectField from 'sentry/components/workflowEngine/form/automationBuilderSelectField';
import {tct} from 'sentry/locale';
import {DataConditionType} from 'sentry/types/workflowEngine/dataConditions';
import {
COMPARISON_INTERVAL_CHOICES,
INTERVAL_CHOICES,
} from 'sentry/views/automations/components/actionFilters/constants';
CountBranch,
PercentBranch,
} from 'sentry/views/automations/components/actionFilters/comparisonBranches';
import {useDataConditionNodeContext} from 'sentry/views/automations/components/dataConditionNodes';

export default function EventFrequencyNode() {
Expand Down Expand Up @@ -44,67 +43,3 @@ function ComparisonTypeField() {
/>
);
}

function CountBranch() {
return tct('more than [value] [interval]', {
value: <ValueField />,
interval: <IntervalField />,
});
}

function PercentBranch() {
return tct('[value] higher [interval] compared to [comparison_interval]', {
value: <ValueField />,
interval: <IntervalField />,
comparison_interval: <ComparisonIntervalField />,
});
}

function ValueField() {
const {condition, condition_id, onUpdate} = useDataConditionNodeContext();
return (
<AutomationBuilderNumberField
name={`${condition_id}.comparison.value`}
value={condition.comparison.value}
min={1}
step={1}
onChange={(value: string) => {
onUpdate({
value,
});
}}
/>
);
}

function IntervalField() {
const {condition, condition_id, onUpdate} = useDataConditionNodeContext();
return (
<AutomationBuilderSelectField
name={`${condition_id}.comparison.interval`}
value={condition.comparison.interval}
options={INTERVAL_CHOICES}
onChange={(value: string) => {
onUpdate({
interval: value,
});
}}
/>
);
}

function ComparisonIntervalField() {
const {condition, condition_id, onUpdate} = useDataConditionNodeContext();
return (
<AutomationBuilderSelectField
name={`${condition_id}.comparison.comparison_interval`}
value={condition.comparison.comparison_interval}
options={COMPARISON_INTERVAL_CHOICES}
onChange={(value: string) => {
onUpdate({
comparison_interval: value,
});
}}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import AutomationBuilderSelectField from 'sentry/components/workflowEngine/form/automationBuilderSelectField';
import {tct} from 'sentry/locale';
import {DataConditionType} from 'sentry/types/workflowEngine/dataConditions';
import {
CountBranch,
PercentBranch,
} from 'sentry/views/automations/components/actionFilters/comparisonBranches';
import {useDataConditionNodeContext} from 'sentry/views/automations/components/dataConditionNodes';

export default function EventUniqueUserFrequencyNode() {
return tct('Number of users affected by an issue is [select]', {
select: <ComparisonTypeField />,
});
}

function ComparisonTypeField() {
const {condition, condition_id, onUpdateType} = useDataConditionNodeContext();

if (condition.comparison_type === DataConditionType.EVENT_UNIQUE_USER_FREQUENCY_COUNT) {
return <CountBranch />;
}
if (
condition.comparison_type === DataConditionType.EVENT_UNIQUE_USER_FREQUENCY_PERCENT
) {
return <PercentBranch />;
}

return (
<AutomationBuilderSelectField
name={`${condition_id}.comparison_type`}
value={condition.comparison_type}
options={[
{
label: 'more than...',
value: DataConditionType.EVENT_UNIQUE_USER_FREQUENCY_COUNT,
},
{
label: 'relatively higher than...',
value: DataConditionType.EVENT_UNIQUE_USER_FREQUENCY_PERCENT,
},
]}
onChange={(value: DataConditionType) => {
onUpdateType(value);
}}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import AutomationBuilderSelectField from 'sentry/components/workflowEngine/form/automationBuilderSelectField';
import {tct} from 'sentry/locale';
import {DataConditionType} from 'sentry/types/workflowEngine/dataConditions';
import {
CountBranch,
PercentBranch,
} from 'sentry/views/automations/components/actionFilters/comparisonBranches';
import {useDataConditionNodeContext} from 'sentry/views/automations/components/dataConditionNodes';

export default function PercentSessionsNode() {
return tct('Percentage of sessions affected by an issue is [select]', {
select: <ComparisonTypeField />,
});
}

function ComparisonTypeField() {
const {condition, condition_id, onUpdateType} = useDataConditionNodeContext();

if (condition.comparison_type === DataConditionType.PERCENT_SESSIONS_COUNT) {
return <CountBranch />;
}
if (condition.comparison_type === DataConditionType.PERCENT_SESSIONS_PERCENT) {
return <PercentBranch />;
}

return (
<AutomationBuilderSelectField
name={`${condition_id}.comparison_type`}
value={condition.comparison_type}
options={[
{
label: 'more than...',
value: DataConditionType.PERCENT_SESSIONS_COUNT,
},
{
label: 'relatively higher than...',
value: DataConditionType.PERCENT_SESSIONS_PERCENT,
},
]}
onChange={(value: DataConditionType) => {
onUpdateType(value);
}}
/>
);
}
44 changes: 44 additions & 0 deletions static/app/views/automations/components/dataConditionNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import {
import AgeComparisonNode from 'sentry/views/automations/components/actionFilters/ageComparison';
import EventAttributeNode from 'sentry/views/automations/components/actionFilters/eventAttribute';
import EventFrequencyNode from 'sentry/views/automations/components/actionFilters/eventFrequency';
import EventUniqueUserFrequencyNode from 'sentry/views/automations/components/actionFilters/eventUniqueUserFrequency';
import IssueOccurrencesNode from 'sentry/views/automations/components/actionFilters/issueOccurrences';
import IssuePriorityNode from 'sentry/views/automations/components/actionFilters/issuePriority';
import LatestAdoptedReleaseNode from 'sentry/views/automations/components/actionFilters/latestAdoptedRelease';
import LevelNode from 'sentry/views/automations/components/actionFilters/level';
import PercentSessionsNode from 'sentry/views/automations/components/actionFilters/percentSessions';
import TaggedEventNode from 'sentry/views/automations/components/actionFilters/taggedEvent';

interface DataConditionNodeProps {
Expand Down Expand Up @@ -136,4 +138,46 @@ export const dataConditionNodesMap = new Map<DataConditionType, DataConditionNod
dataCondition: <EventFrequencyNode />,
},
],
[
DataConditionType.EVENT_UNIQUE_USER_FREQUENCY,
{
label: t('Number of users affected'),
dataCondition: <EventUniqueUserFrequencyNode />,
},
],
[
DataConditionType.EVENT_UNIQUE_USER_FREQUENCY_COUNT,
{
label: t('Number of users affected'),
dataCondition: <EventUniqueUserFrequencyNode />,
},
],
[
DataConditionType.EVENT_UNIQUE_USER_FREQUENCY_PERCENT,
{
label: t('Number of users affected'),
dataCondition: <EventUniqueUserFrequencyNode />,
},
],
[
DataConditionType.PERCENT_SESSIONS,
{
label: t('Percentage of sessions affected'),
dataCondition: <PercentSessionsNode />,
},
],
[
DataConditionType.PERCENT_SESSIONS_COUNT,
{
label: t('Percentage of sessions affected'),
dataCondition: <PercentSessionsNode />,
},
],
[
DataConditionType.PERCENT_SESSIONS_PERCENT,
{
label: t('Percentage of sessions affected'),
dataCondition: <PercentSessionsNode />,
},
],
]);
Loading