:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(error-tracking): add severity rules settings (#86271)
Hugues Pouillote2435bb55919
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex f7ef3d50b45e..05d08d409204 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7721,9 +7721,9 @@ snapshots:scenes-app-settings-environment--settings-environment-error-tracking--light:hash: v1.k794b7964.5ac167271f00184ce6159d0072ce163542658b08419f6e70b5cf6a6ca201a718.X6dKpM6uGw_g_FAwdQ5PukTVcKWGAa77bMOzgw-kiXYscenes-app-settings-environment--settings-environment-error-tracking-configuration--dark:- hash: v1.k794b7964.610a8d8b91871b32a6b83b087df8523999636f905ebacd4d4bad4f6c2c10cdd2.N1EL1qb6-quDv9B8-LwQ5S-zyRZlCwgJJiR-ahq4p-8+ hash: v1.k794b7964.033e5499811363c36dee07950ff09f33413e64b81c8522859c85748bc0443e3f.Hz66ItOfiG51KAAT2yidV4lINJmLINi-9_k81Ygdk80scenes-app-settings-environment--settings-environment-error-tracking-configuration--light:- hash: v1.k794b7964.adb8f8b9586c3cda5749b248291df41cfc5da3f9e1764fbaef8c0c2c3b5315dc.BLb5wQ4ykREEPkol8psVfNFlk1KlbWmTZDwW8MncIPo+ hash: v1.k794b7964.56f8265ff5de3733a4d00b0dbde7c0fff36ccdc886f713881134159802a13d39.9ArXuAkoxa6dyVQ_uspbjHWKM8YIgCPgCbDUnLHsxsoscenes-app-settings-environment--settings-environment-feature-flags--dark:hash: v1.k794b7964.56670f556ffac0360ec521741db9822f4e545e25b45bd8ed4ad012da8885c30a.qj9dLuAFy8v0TwEH-UTymXnlWPe2eu-YjAOpe2zc3Q8scenes-app-settings-environment--settings-environment-feature-flags--light:diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 4c8771fcea41..8f477f1a4531 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -317,6 +317,7 @@ export const FEATURE_FLAGS = {ERROR_TRACKING_RATE_LIMITING_PER_ISSUE: 'error-tracking-rate-limiting-per-issue', // owner: @ablaszkiewicz #team-error-trackingERROR_TRACKING_RECOMMENDATIONS: 'error-tracking-recommendations', // owner: @ablaszkiewicz #team-error-trackingERROR_TRACKING_RELATED_ISSUES: 'error-tracking-related-issues', // owner: #team-error-tracking+ ERROR_TRACKING_SEVERITY_RULES: 'error-tracking-severity-rules', // owner: #team-error-trackingERROR_TRACKING_WEEKLY_DIGEST: 'error-tracking-weekly-digest', // owner: #team-error-trackingEVENT_MEDIA_PREVIEWS: 'event-media-previews', // owner: @alexliderEXPERIMENT_BEHAVIOR_COMPARISON: 'experiment-behavior-comparison', // owner: @mp-hog #team-experimentsdiff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsxindex ba412aa9bb65..2653252b11af 100644--- a/frontend/src/scenes/settings/SettingsMap.tsx+++ b/frontend/src/scenes/settings/SettingsMap.tsx@@ -6,6 +6,7 @@ import { AssignmentRules } from '@posthog/products-error-tracking/frontend/sceneimport { GroupingRules } from '@posthog/products-error-tracking/frontend/scenes/ErrorTrackingConfigurationScene/grouping_rules/GroupingRules'import { RateLimitSettings } from '@posthog/products-error-tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/RateLimitSettings'import { Releases } from '@posthog/products-error-tracking/frontend/scenes/ErrorTrackingConfigurationScene/releases/Releases'+import { SeverityRules } from '@posthog/products-error-tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/SeverityRules'import { SpikeDetectionSettings } from '@posthog/products-error-tracking/frontend/scenes/ErrorTrackingConfigurationScene/spike_detection/SpikeDetectionSettings'import { SymbolSets } from '@posthog/products-error-tracking/frontend/scenes/ErrorTrackingConfigurationScene/symbol_sets/SymbolSets'import { McpStoreSettings } from '@posthog/products-mcp-store/frontend/McpStoreSettings'@@ -588,6 +589,14 @@ export const SETTINGS_MAP: SettingSection[] = [component: <AssignmentRules />,keywords: ['assign', 'owner', 'team', 'rule', 'routing'],},+ {+ id: 'error-tracking-severity-rules',+ title: 'Severity rules',+ description: 'Set the initial severity of new issues based on rules you define.',+ component: <SeverityRules />,+ flag: 'ERROR_TRACKING_SEVERITY_RULES',+ keywords: ['severity', 'priority', 'triage', 'critical', 'rule'],+ },{id: 'error-tracking-custom-grouping',title: 'Custom grouping rules',diff --git a/frontend/src/scenes/settings/types.ts b/frontend/src/scenes/settings/types.tsindex 90378ab7b222..95497c063e41 100644--- a/frontend/src/scenes/settings/types.ts+++ b/frontend/src/scenes/settings/types.ts@@ -157,6 +157,7 @@ export type SettingId =| 'error-tracking-integrations'| 'error-tracking-rate-limits'| 'error-tracking-releases'+ | 'error-tracking-severity-rules'| 'error-tracking-spike-detection'| 'error-tracking-suppression-rules'| 'error-tracking-symbol-sets'diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/rulesLogic.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/rulesLogic.tsxindex 09461306d0bf..674043de31d4 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/rulesLogic.tsx+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/rulesLogic.tsx@@ -41,6 +41,14 @@ function createNewRule(ruleType: ErrorTrackingRuleType, order_key: number): Errofilters: { type: FilterLogicalOperator.Or, values: [] },order_key,}+ case 'severity_rules':+ return {+ id: 'new',+ disabled_data: null,+ filters: { type: FilterLogicalOperator.And, values: [] },+ order_key,+ severity: null,+ }default:throw new Error(`Unsupported rule type: ${ruleType}`)}diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/types.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/types.tsindex d6e31fba5e32..9492196eb479 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/types.ts+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/types.ts@@ -1,6 +1,11 @@import { ErrorTrackingIssueAssignee } from '~/queries/schema/schema-general'import { JsonType, UniversalFiltersGroup } from '~/types'+import type {+ ErrorTrackingIssueSeverityRuleEnumApi,+ ErrorTrackingSeverityRuleApi,+} from '../../../generated/api.schemas'+export type ErrorTrackingBaseRule = {id: stringfilters: UniversalFiltersGroup@@ -26,17 +31,27 @@ export type ErrorTrackingGroupingRule = ErrorTrackingBaseRule & {export type ErrorTrackingBypassRule = ErrorTrackingBaseRule+export type ErrorTrackingSeverityRule = ErrorTrackingBaseRule & Pick<ErrorTrackingSeverityRuleApi, 'severity'>++export type ErrorTrackingSeverityRuleNew = Omit<ErrorTrackingSeverityRule, 'id' | 'severity'> & {+ id: 'new'+ severity: ErrorTrackingIssueSeverityRuleEnumApi | null+}+export type ErrorTrackingRule =| ErrorTrackingSuppressionRule| ErrorTrackingGroupingRule| ErrorTrackingAssignmentRule| ErrorTrackingBypassRule+ | ErrorTrackingSeverityRule+ | ErrorTrackingSeverityRuleNewexport type ErrorTrackingRuleNew = ErrorTrackingRule & { id: 'new' }export enum ErrorTrackingRuleType {Assignment = 'assignment_rules',Bypass = 'bypass_rules',Grouping = 'grouping_rules',+ Severity = 'severity_rules',Suppression = 'suppression_rules',}diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/SeverityRuleModal.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/SeverityRuleModal.tsxnew file mode 100644index 000000000000..66be81156821--- /dev/null+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/SeverityRuleModal.tsx@@ -0,0 +1,70 @@+import { useActions, useValues } from 'kea'++import { LemonSelect, LemonTag } from '@posthog/lemon-ui'++import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'+import { LemonLabel } from 'lib/lemon-ui/LemonLabel'++import {+ ErrorTrackingIssueSeverityRuleEnumApi,+ type ErrorTrackingIssueSeverityRuleEnumApi as Severity,+} from '../../../generated/api.schemas'+import { RuleModal } from '../rules/RuleModal'+import { severityRuleModalLogic } from './severityRuleModalLogic'++const SEVERITY_OPTIONS: { label: string; value: Severity }[] = [+ { label: 'Low', value: ErrorTrackingIssueSeverityRuleEnumApi.Low },+ { label: 'Medium', value: ErrorTrackingIssueSeverityRuleEnumApi.Medium },+ { label: 'High', value: ErrorTrackingIssueSeverityRuleEnumApi.High },+ { label: 'Critical', value: ErrorTrackingIssueSeverityRuleEnumApi.Critical },+]++export const severityTagType = (severity: Severity): 'default' | 'warning' | 'danger' => {+ if (severity === ErrorTrackingIssueSeverityRuleEnumApi.Critical) {+ return 'danger'+ }+ if (severity === ErrorTrackingIssueSeverityRuleEnumApi.High) {+ return 'warning'+ }+ return 'default'+}++export const severityLabel = (severity: Severity): string =>+ SEVERITY_OPTIONS.find((option) => option.value === severity)?.label ?? severity++export function SeverityRuleModal(): JSX.Element {+ const { rule, hasFilters, hasSeverity } = useValues(severityRuleModalLogic)+ const { updateSeverity } = useActions(severityRuleModalLogic)+ const saveDisabledReason = !hasFilters ? 'Add at least one filter' : !hasSeverity ? 'Choose a severity' : undefined++ return (+ <RuleModal+ logic={severityRuleModalLogic}+ ruleLabel="severity"+ description="Matching exceptions set the initial severity when they create a new issue. Existing issues are never changed."+ pageKey="severity-rule-modal"+ taxonomicGroupTypes={[TaxonomicFilterGroupType.EventProperties]}+ saveDisabledReason={saveDisabledReason}+ suffix={(issuesLink, dateRangeLabel) => (+ <>+ across {issuesLink} would have matched this severity rule in the last {dateRangeLabel}+ </>+ )}+ extraFields={+ <div>+ <LemonLabel className="mb-2">Severity</LemonLabel>+ <LemonSelect+ fullWidth+ value={rule.severity ?? undefined}+ placeholder="Choose severity"+ onChange={updateSeverity}+ options={SEVERITY_OPTIONS.map((option) => ({+ value: option.value,+ label: <LemonTag type={severityTagType(option.value)}>{option.label}</LemonTag>,+ }))}+ />+ </div>+ }+ />+ )+}diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/SeverityRules.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/SeverityRules.tsxnew file mode 100644index 000000000000..9f0bc3eb4203--- /dev/null+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/SeverityRules.tsx@@ -0,0 +1,33 @@+import { LemonTag } from '@posthog/lemon-ui'++import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'++import { RuleList } from '../rules/RuleList'+import { ErrorTrackingRuleType, ErrorTrackingSeverityRule } from '../rules/types'+import { SeverityRuleModal, severityLabel, severityTagType } from './SeverityRuleModal'+import { severityRuleModalLogic } from './severityRuleModalLogic'++export function SeverityRules(): JSX.Element {+ return (+ <RuleList+ ruleType={ErrorTrackingRuleType.Severity}+ modalLogic={severityRuleModalLogic}+ modal={<SeverityRuleModal />}+ taxonomicGroupTypes={[TaxonomicFilterGroupType.EventProperties]}+ pageKeyPrefix="severity-rule"+ description={+ <p>+ Set the initial severity of newly created issues from exception properties. The first matching rule+ wins. When no rule matches, built-in severity inference is preserved. Existing issues are never+ changed.+ </p>+ }+ renderCardHeaderExtra={(rule: ErrorTrackingSeverityRule) => (+ <>+ <span className="text-muted">·</span>+ <LemonTag type={severityTagType(rule.severity)}>{severityLabel(rule.severity)}</LemonTag>+ </>+ )}+ />+ )+}diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/severityRuleModalLogic.test.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/severityRuleModalLogic.test.tsnew file mode 100644index 000000000000..59bee15278c2--- /dev/null+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/severityRuleModalLogic.test.ts@@ -0,0 +1,98 @@+import { expectLogic } from 'kea-test-utils'++import api from 'lib/api'++import { ProductKey } from '~/queries/schema/schema-general'+import { initKeaTests } from '~/test/init'+import { EventPropertyFilter, FilterLogicalOperator, PropertyFilterType, PropertyOperator } from '~/types'++import { ErrorTrackingIssueSeverityRuleEnumApi } from '../../../generated/api.schemas'+import { ErrorTrackingSeverityRule, ErrorTrackingRuleType } from '../rules/types'+import { severityRuleModalLogic } from './severityRuleModalLogic'++const browserFilter: EventPropertyFilter = {+ key: '$browser',+ value: ['Firefox'],+ operator: PropertyOperator.Exact,+ type: PropertyFilterType.Event,+}++const persistedRule: ErrorTrackingSeverityRule = {+ id: 'rule-id',+ filters: { type: FilterLogicalOperator.And, values: [browserFilter] },+ severity: ErrorTrackingIssueSeverityRuleEnumApi.High,+ order_key: 0,+ disabled_data: null,+ created_at: '2026-08-13T00:00:00Z',+ updated_at: '2026-08-13T00:00:00Z',+}++describe('severityRuleModalLogic', () => {+ beforeEach(() => {+ initKeaTests()+ jest.spyOn(api, 'query').mockResolvedValue({ results: [[3, 2]] } as any)+ jest.spyOn(api.errorTracking, 'rules').mockResolvedValue({ results: [] })+ jest.spyOn(api.errorTracking, 'createRule').mockResolvedValue(persistedRule)+ jest.spyOn(api.errorTracking, 'updateRule').mockResolvedValue()+ jest.spyOn(api.errorTracking, 'deleteRule').mockResolvedValue()+ })++ afterEach(() => {+ jest.restoreAllMocks()+ })++ it('requires a supported severity and creates a rule', async () => {+ const logic = severityRuleModalLogic()+ logic.mount()++ logic.actions.openModal()+ expect(logic.values.hasSeverity).toBe(false)+ logic.actions.updateSeverity(ErrorTrackingIssueSeverityRuleEnumApi.Critical)+ expect(logic.values.hasSeverity).toBe(true)++ await expectLogic(logic, () => logic.actions.saveRule()).toFinishAllListeners()++ expect(api.errorTracking.createRule).toHaveBeenCalledWith(+ ErrorTrackingRuleType.Severity,+ expect.objectContaining({ severity: ErrorTrackingIssueSeverityRuleEnumApi.Critical })+ )+ logic.unmount()+ })++ it('edits and deletes a persisted rule', async () => {+ const logic = severityRuleModalLogic()+ logic.mount()++ logic.actions.openModal(persistedRule)+ logic.actions.updateSeverity(ErrorTrackingIssueSeverityRuleEnumApi.Low)+ await expectLogic(logic, () => logic.actions.saveRule()).toFinishAllListeners()+ expect(api.errorTracking.updateRule).toHaveBeenCalledWith(+ ErrorTrackingRuleType.Severity,+ expect.objectContaining({ id: persistedRule.id, severity: ErrorTrackingIssueSeverityRuleEnumApi.Low })+ )++ logic.actions.openModal(persistedRule)+ await expectLogic(logic, () => logic.actions.deleteRule()).toFinishAllListeners()+ expect(api.errorTracking.deleteRule).toHaveBeenCalledWith(ErrorTrackingRuleType.Severity, persistedRule.id)+ logic.unmount()+ })++ it('previews matching exceptions with error tracking query tags', async () => {+ const logic = severityRuleModalLogic()+ logic.mount()++ await expectLogic(logic, () => {+ logic.actions.openModal(persistedRule)+ logic.actions.loadMatchCount()+ }).toFinishAllListeners()++ expect(api.query).toHaveBeenCalledWith(+ expect.objectContaining({+ tags: { productKey: ProductKey.ERROR_TRACKING },+ fixedProperties: [{ type: FilterLogicalOperator.And, values: [browserFilter] }],+ })+ )+ expect(logic.values.matchResult).toEqual({ exceptionCount: 3, issueCount: 2 })+ logic.unmount()+ })+})diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/severityRuleModalLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/severityRuleModalLogic.tsnew file mode 100644index 000000000000..22c9fa4498bc--- /dev/null+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/severity_rules/severityRuleModalLogic.ts@@ -0,0 +1,254 @@+import { MakeLogicType, actions, kea, listeners, path, reducers, selectors } from 'kea'+import { loaders } from 'kea-loaders'++import api from 'lib/api'++import { NodeKind, ProductKey } from '~/queries/schema/schema-general'+import { AnyPropertyFilter, FilterLogicalOperator, UniversalFiltersGroup } from '~/types'++import { ErrorTrackingIssueSeverityRuleEnumApi } from '../../../generated/api.schemas'+import { rulesLogic } from '../rules/rulesLogic'+import { ErrorTrackingRuleType, ErrorTrackingSeverityRule, ErrorTrackingSeverityRuleNew } from '../rules/types'++type EditableSeverityRule = ErrorTrackingSeverityRule | ErrorTrackingSeverityRuleNew++function emptyRule(): ErrorTrackingSeverityRuleNew {+ return {+ id: 'new',+ filters: { type: FilterLogicalOperator.And, values: [] },+ severity: null,+ disabled_data: null,+ order_key: 0,+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface severityRuleModalLogicValues {+ dateRange: string+ deleting: boolean+ deletingLoading: boolean+ hasFilters: boolean+ hasSeverity: boolean+ isOpen: boolean+ matchResult: {+ exceptionCount: number+ issueCount: number+ } | null+ matchResultLoading: boolean+ rule: EditableSeverityRule+ saving: boolean+ savingLoading: boolean+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface severityRuleModalLogicActions {+ closeModal: () => {+ value: true+ }+ deleteRule: () => any+ deleteRuleFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ deleteRuleSuccess: (+ deleting: boolean,+ payload?: any+ ) => {+ deleting: boolean+ payload?: any+ }+ increaseDateRange: () => {+ value: true+ }+ loadMatchCount: () => any+ loadMatchCountFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadMatchCountSuccess: (+ matchResult: {+ exceptionCount: any+ issueCount: any+ } | null,+ payload?: any+ ) => {+ matchResult: {+ exceptionCount: any+ issueCount: any+ } | null+ payload?: any+ }+ openModal: (rule?: ErrorTrackingSeverityRule) => {+ rule: ErrorTrackingSeverityRule | null+ }+ resetMatchCount: () => any+ resetMatchCountFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ resetMatchCountSuccess: (+ matchResult: null,+ payload?: any+ ) => {+ matchResult: null+ payload?: any+ }+ saveRule: () => any+ saveRuleFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ saveRuleSuccess: (+ saving: boolean,+ payload?: any+ ) => {+ saving: boolean+ payload?: any+ }+ updateRule: (rule: EditableSeverityRule) => {+ rule: EditableSeverityRule+ }+ updateSeverity: (severity: ErrorTrackingIssueSeverityRuleEnumApi) => {+ severity: ErrorTrackingIssueSeverityRuleEnumApi+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface severityRuleModalLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ hasFilters: (rule: EditableSeverityRule) => boolean+ hasSeverity: (rule: EditableSeverityRule) => boolean+ }+}++export type severityRuleModalLogicType = MakeLogicType<+ severityRuleModalLogicValues,+ severityRuleModalLogicActions,+ Record<string, any>,+ severityRuleModalLogicMeta+>++export const severityRuleModalLogic = kea<severityRuleModalLogicType>([+ path([+ 'products',+ 'error_tracking',+ 'scenes',+ 'ErrorTrackingConfigurationScene',+ 'severity_rules',+ 'severityRuleModalLogic',+ ]),++ actions({+ openModal: (rule?: ErrorTrackingSeverityRule) => ({ rule: rule ?? null }),+ closeModal: true,+ updateRule: (rule: EditableSeverityRule) => ({ rule }),+ updateSeverity: (severity: ErrorTrackingIssueSeverityRuleEnumApi) => ({ severity }),+ increaseDateRange: true,+ }),++ reducers({+ isOpen: [false, { openModal: () => true, closeModal: () => false }],+ rule: [+ emptyRule() as EditableSeverityRule,+ {+ openModal: (_: EditableSeverityRule, { rule }: { rule: ErrorTrackingSeverityRule | null }) =>+ rule ?? emptyRule(),+ updateRule: (_: EditableSeverityRule, { rule }: { rule: EditableSeverityRule }) => rule,+ updateSeverity: (+ state: EditableSeverityRule,+ { severity }: { severity: ErrorTrackingIssueSeverityRuleEnumApi }+ ) => ({ ...state, severity }),+ },+ ],+ dateRange: [+ '-7d' as string,+ {+ openModal: () => '-7d',+ updateRule: () => '-7d',+ increaseDateRange: (state: string) => ({ '-7d': '-30d', '-30d': '-90d' })[state] ?? state,+ },+ ],+ }),++ loaders(({ values }) => ({+ matchResult: [+ null as { exceptionCount: number; issueCount: number } | null,+ {+ loadMatchCount: async () => {+ const filters = values.rule.filters as UniversalFiltersGroup+ const properties = (filters.values as AnyPropertyFilter[]) ?? []+ if (properties.length === 0) {+ return null+ }+ const response = (await api.query({+ kind: NodeKind.EventsQuery,+ event: '$exception',+ select: ['count()', 'count(distinct issue_id)'],+ after: values.dateRange,+ tags: { productKey: ProductKey.ERROR_TRACKING },+ fixedProperties: [{ type: filters.type ?? FilterLogicalOperator.And, values: properties }],+ })) as Record<string, any>+ return {+ exceptionCount: response.results?.[0]?.[0] ?? 0,+ issueCount: response.results?.[0]?.[1] ?? 0,+ }+ },+ resetMatchCount: () => null,+ },+ ],+ saving: [+ false,+ {+ saveRule: async () => {+ const rule = values.rule+ if (rule.id === 'new') {+ await api.errorTracking.createRule(ErrorTrackingRuleType.Severity, rule)+ } else {+ await api.errorTracking.updateRule(ErrorTrackingRuleType.Severity, rule)+ }+ return true+ },+ },+ ],+ deleting: [+ false,+ {+ deleteRule: async () => {+ await api.errorTracking.deleteRule(ErrorTrackingRuleType.Severity, values.rule.id)+ return true+ },+ },+ ],+ })),++ listeners(({ actions }) => ({+ saveRuleSuccess: () => {+ actions.closeModal()+ rulesLogic({ ruleType: ErrorTrackingRuleType.Severity }).actions.loadRules()+ },+ deleteRuleSuccess: () => {+ actions.closeModal()+ rulesLogic({ ruleType: ErrorTrackingRuleType.Severity }).actions.loadRules()+ },+ openModal: () => actions.resetMatchCount(),+ updateRule: () => actions.resetMatchCount(),+ increaseDateRange: () => actions.loadMatchCount(),+ })),++ selectors({+ hasFilters: [(s) => [s.rule], (rule: EditableSeverityRule): boolean => (rule.filters.values?.length ?? 0) > 0],+ hasSeverity: [(s) => [s.rule], (rule: EditableSeverityRule): boolean => rule.severity !== null],+ }),+])