: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
refactor(alerts): group kind-specific props on AlertDefinitionSection (#64873)
Vasco de Krijger4253d2a01abf
diff --git a/frontend/src/lib/components/Alerts/views/EditAlertModal.tsx b/frontend/src/lib/components/Alerts/views/EditAlertModal.tsxindex 5b6e6c5c420e..34722800f159 100644--- a/frontend/src/lib/components/Alerts/views/EditAlertModal.tsx+++ b/frontend/src/lib/components/Alerts/views/EditAlertModal.tsx@@ -270,16 +270,15 @@ export function EditAlertModal({alertForm={alertForm}alertMode={alertMode}thresholdBoundsFormError={thresholdBoundsFormError}- isBreakdownValid={isBreakdownValid}isNonTimeSeriesDisplay={isNonTimeSeriesDisplay}- alertSeries={alertSeries}- formulaNodes={formulaNodes}- funnelStepLabels={funnelStepLabels}- funnelPreview={funnelAlertPreview}- hogqlPreview={hogqlAlertPreview}- hogqlColumns={hogqlResultColumns}- hogqlValueColumnOptions={hogqlValueColumnOptions}- hogqlLabelColumnOptions={hogqlLabelColumnOptions}+ trends={{ alertSeries, formulaNodes, isBreakdownValid }}+ funnel={{ stepLabels: funnelStepLabels, preview: funnelAlertPreview }}+ hogql={{+ preview: hogqlAlertPreview,+ columns: hogqlResultColumns,+ valueColumnOptions: hogqlValueColumnOptions,+ labelColumnOptions: hogqlLabelColumnOptions,+ }}anomalyDetectionEnabled={anomalyDetectionEnabled && supportsAnomalyDetection(alertForm.config)}diff --git a/products/alerts/frontend/components/editAlertModal/AlertDefinitionSection.tsx b/products/alerts/frontend/components/editAlertModal/AlertDefinitionSection.tsxindex 52ac14a4f575..af6053aeee1a 100644--- a/products/alerts/frontend/components/editAlertModal/AlertDefinitionSection.tsx+++ b/products/alerts/frontend/components/editAlertModal/AlertDefinitionSection.tsx@@ -32,26 +32,42 @@ import { getDefaultSimulationRange } from 'products/alerts/frontend/logic/alertIimport { FunnelsDefinitionFields, HogQLDefinitionFields, TrendsDefinitionFields } from './AlertDefinitionFields'import { getSimulationRangeOptions } from './editAlertModalUtils'+export interface TrendsDefinitionProps {+ /** Series in the alerted insight, for the series picker. */+ alertSeries: Array<{ custom_name?: string | null; name?: string | null; event?: string | null }> | null+ /** Formula nodes in the alerted insight, if any. */+ formulaNodes: Array<{ formula: string; custom_name?: string | null }> | undefined+ /** Whether the insight has a valid breakdown; drives the per-value monitoring banner. */+ isBreakdownValid: boolean+}++export interface FunnelDefinitionProps {+ /** Funnel step labels (real event/series names) for the conversion picker. */+ stepLabels: string[]+ /** Conversion rate(s) the alert would evaluate now; null until the result loads. */+ preview: FunnelAlertPreview | null+}++export interface HogQLDefinitionProps {+ /** What a SQL alert would evaluate now; null until the result loads. */+ preview: HogQLAlertPreview | null+ /** Result column names, for the column pickers. */+ columns: string[] | null+ /** Evaluated-column picker options (numeric columns, with fallbacks). */+ valueColumnOptions: { label: string; value: string }[]+ /** Label-column picker options (every column except the evaluated one). */+ labelColumnOptions: { label: string; value: string }[]+}+export interface AlertDefinitionSectionProps {alertForm: AlertFormTypealertMode: 'detector' | 'threshold'thresholdBoundsFormError?: string- isBreakdownValid: booleanisNonTimeSeriesDisplay: boolean- alertSeries: Array<{ custom_name?: string | null; name?: string | null; event?: string | null }> | null- formulaNodes: Array<{ formula: string; custom_name?: string | null }> | undefined- /** The funnel's step labels (real event/series names), used to populate the conversion picker. */- funnelStepLabels: string[]- /** The conversion rate(s) a funnel alert would evaluate right now; null until the result loads. */- funnelPreview: FunnelAlertPreview | null- /** What a SQL alert would evaluate right now; null until the insight result loads. */- hogqlPreview: HogQLAlertPreview | null- /** Result column names of the SQL insight, for the column pickers. */- hogqlColumns: string[] | null- /** Options for the evaluated-column picker (numeric columns, with fallbacks). */- hogqlValueColumnOptions: { label: string; value: string }[]- /** Options for the label-column picker (every column except the evaluated one). */- hogqlLabelColumnOptions: { label: string; value: string }[]+ // Kind-specific inputs, grouped so the shared section only carries the bundle for the active kind.+ trends: TrendsDefinitionProps+ funnel: FunnelDefinitionProps+ hogql: HogQLDefinitionPropsanomalyDetectionEnabled: booleaninvestigationAgentEnabled: booleansimulationResult: AlertSimulationResult | null@@ -73,16 +89,10 @@ export function AlertDefinitionSection({alertForm,alertMode,thresholdBoundsFormError,- isBreakdownValid,isNonTimeSeriesDisplay,- alertSeries,- formulaNodes,- funnelStepLabels,- funnelPreview,- hogqlPreview,- hogqlColumns,- hogqlValueColumnOptions,- hogqlLabelColumnOptions,+ trends,+ funnel,+ hogql,anomalyDetectionEnabled,investigationAgentEnabled,simulationResult,@@ -105,7 +115,7 @@ export function AlertDefinitionSection({return (<>{/* Trends-specific copy; funnels have their own breakdown messaging in the preview banner. */}- {isBreakdownValid && isTrendsAlertConfig(alertForm.config) && (+ {trends.isBreakdownValid && isTrendsAlertConfig(alertForm.config) && (<LemonBanner type="warning">{alertMode === 'detector'? 'For trends with breakdown, the detector will independently monitor each breakdown value (up to 25) and fire if any is anomalous.'@@ -114,25 +124,25 @@ export function AlertDefinitionSection({)}{isTrendsAlertConfig(alertForm.config) ? (<TrendsDefinitionFields- alertSeries={alertSeries}- formulaNodes={formulaNodes}- isBreakdownValid={isBreakdownValid}+ alertSeries={trends.alertSeries}+ formulaNodes={trends.formulaNodes}+ isBreakdownValid={trends.isBreakdownValid}alertMode={alertMode}/>) : isFunnelAlert ? (<FunnelsDefinitionFieldsalertForm={alertForm}- stepLabels={funnelStepLabels}- funnelPreview={funnelPreview}+ stepLabels={funnel.stepLabels}+ funnelPreview={funnel.preview}onSetAlertFormValue={onSetAlertFormValue}/>) : isHogQLAlertConfig(alertForm.config) ? (<HogQLDefinitionFieldsalertForm={alertForm}- hogqlPreview={hogqlPreview}- hogqlColumns={hogqlColumns}- hogqlValueColumnOptions={hogqlValueColumnOptions}- hogqlLabelColumnOptions={hogqlLabelColumnOptions}+ hogqlPreview={hogql.preview}+ hogqlColumns={hogql.columns}+ hogqlValueColumnOptions={hogql.valueColumnOptions}+ hogqlLabelColumnOptions={hogql.labelColumnOptions}onSetAlertFormValue={onSetAlertFormValue}/>) : null}