: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
chore(alerts): rename PlatformAlertCheck to PlatformAlertCheckInput (#104842)
Jimmy Zhud03c014d7aef
diff --git a/products/alerts/backend/facade/contracts.py b/products/alerts/backend/facade/contracts.pyindex c009054f470b..4853dfd91a28 100644--- a/products/alerts/backend/facade/contracts.py+++ b/products/alerts/backend/facade/contracts.py@@ -84,7 +84,7 @@ class SourceEvaluationInputs:@frozen-class PlatformAlertCheck:+class PlatformAlertCheckInput:"""One configuration and its runtime state, as a source adapter reads it.Flat rather than nested, because a source never holds the rows and has nothing to do withdiff --git a/products/alerts/backend/logic/platform_lifecycle.py b/products/alerts/backend/logic/platform_lifecycle.pyindex 400b4c04ce2c..d0f1c27d10d0 100644--- a/products/alerts/backend/logic/platform_lifecycle.py+++ b/products/alerts/backend/logic/platform_lifecycle.py@@ -10,7 +10,7 @@ from datetime import datetimefrom django.db import transactionfrom django.db.models import Exists, OuterRef, Q-from products.alerts.backend.facade.contracts import PlatformAlertCheck, PlatformAlertOutcome, PlatformAlertUpsert+from products.alerts.backend.facade.contracts import PlatformAlertCheckInput, PlatformAlertOutcome, PlatformAlertUpsertfrom products.alerts.backend.facade.scheduling import advance_next_check_at, compute_shard_offset_secondsfrom products.alerts.backend.models import PlatformAlert, PlatformAlertConfiguration@@ -75,7 +75,7 @@ def suppressed() -> Exists:)-def due_checks(team_id: int, source_kind: str, slot: str, cutoff: datetime) -> tuple[PlatformAlertCheck, ...]:+def due_checks(team_id: int, source_kind: str, slot: str, cutoff: datetime) -> tuple[PlatformAlertCheckInput, ...]:"""Every configuration in one batch key, with its runtime state, ready to evaluate."""configurations = list(PlatformAlertConfiguration.objects.for_team(team_id)@@ -93,8 +93,8 @@ def due_checks(team_id: int, source_kind: str, slot: str, cutoff: datetime) -> treturn tuple(_check(c, alerts.get(str(c.id))) for c in configurations)-def _check(c: PlatformAlertConfiguration, alert: PlatformAlert | None) -> PlatformAlertCheck:- return PlatformAlertCheck(+def _check(c: PlatformAlertConfiguration, alert: PlatformAlert | None) -> PlatformAlertCheckInput:+ return PlatformAlertCheckInput(id=c.id,team_id=c.team_id,name=c.name,diff --git a/products/logs/backend/alert_source_cycle.py b/products/logs/backend/alert_source_cycle.pyindex 80c7de8d1480..38d7035b71c0 100644--- a/products/logs/backend/alert_source_cycle.py+++ b/products/logs/backend/alert_source_cycle.py@@ -29,7 +29,7 @@ from products.alerts.backend.facade.contracts import (AlertDeliveryPreview,GroupTransition,MuteReason,- PlatformAlertCheck,+ PlatformAlertCheckInput,PlatformAlertOutcome,SkipReason,SourceBatchEvaluation,@@ -104,7 +104,7 @@ _NOTIFICATION_EVENT_KINDS: dict[NotificationAction, EventKind] = {}-def _cohort_key(check: PlatformAlertCheck, checkpoint: datetime | None, now: datetime) -> tuple:+def _cohort_key(check: PlatformAlertCheckInput, checkpoint: datetime | None, now: datetime) -> tuple:return (check.window_minutes,check.evaluation_periods,@@ -114,7 +114,7 @@ def _cohort_key(check: PlatformAlertCheck, checkpoint: datetime | None, now: dat)-def _is_in_quiet_hours(check: PlatformAlertCheck, now: datetime, tz_name: str) -> bool:+def _is_in_quiet_hours(check: PlatformAlertCheckInput, now: datetime, tz_name: str) -> bool:"""True when the alert's schedule restriction mutes an announcement at the batch instant.The check still runs, so an incident wholly inside the window is still recorded.@@ -132,7 +132,7 @@ def _is_in_quiet_hours(check: PlatformAlertCheck, now: datetime, tz_name: str) -return False-def _snapshot(check: PlatformAlertCheck, prior_breached: tuple[bool, ...]) -> AlertSnapshot:+def _snapshot(check: PlatformAlertCheckInput, prior_breached: tuple[bool, ...]) -> AlertSnapshot:return AlertSnapshot(state=AlertState(check.state),cooldown=timedelta(minutes=check.cooldown_minutes),@@ -153,12 +153,12 @@ class _Triage:"""What a batch splits into before any query runs."""decided: list[Decision]- evaluable: list[PlatformAlertCheck]+ evaluable: list[PlatformAlertCheckInput]muted_ids: frozenset[UUID]def _record_check_metrics(- check: PlatformAlertCheck,+ check: PlatformAlertCheckInput,*,new_state: str,notification: NotificationAction,@@ -183,7 +183,7 @@ def _record_check_metrics(def _verdict(- check: PlatformAlertCheck,+ check: PlatformAlertCheckInput,check_input: CheckInput,prior_breached: tuple[bool, ...],*,@@ -216,7 +216,7 @@ def _verdict(def _recorded(- check: PlatformAlertCheck, *, new_state: str, notified: bool, consecutive_failures: int, disable: bool = False+ check: PlatformAlertCheckInput, *, new_state: str, notified: bool, consecutive_failures: int, disable: bool = False) -> PlatformAlertOutcome:return PlatformAlertOutcome(configuration_id=check.id,@@ -227,7 +227,7 @@ def _recorded()-def _delivery(check: PlatformAlertCheck, outcome: AlertCheckOutcome, *, window_end: datetime) -> Decision:+def _delivery(check: PlatformAlertCheckInput, outcome: AlertCheckOutcome, *, window_end: datetime) -> Decision:"""What the platform records for a verdict, and what delivery would announce for it."""recorded = _recorded(check,@@ -258,7 +258,7 @@ def _delivery(check: PlatformAlertCheck, outcome: AlertCheckOutcome, *, window_edef _evaluate_one(- check: PlatformAlertCheck, buckets: list[BucketedCount], *, now: datetime, muted: bool+ check: PlatformAlertCheckInput, buckets: list[BucketedCount], *, now: datetime, muted: bool) -> AlertCheckOutcome:current_breached, *prior_windows_breached = _derive_breaches(buckets, check.threshold_count, check.threshold_operator, check.evaluation_periods@@ -272,7 +272,7 @@ def _evaluate_one()-def _failed(check: PlatformAlertCheck, error: Exception, *, now: datetime, muted: bool) -> AlertCheckOutcome:+def _failed(check: PlatformAlertCheckInput, error: Exception, *, now: datetime, muted: bool) -> AlertCheckOutcome:"""A check that could not reach a verdict, as the shared machine's error path sees it.The machine raises `consecutive_failures` and escalates to BROKEN, so an alert that fails@@ -294,7 +294,7 @@ def _failed(check: PlatformAlertCheck, error: Exception, *, now: datetime, muted)-def _held(check: PlatformAlertCheck, outcome: ControlPlaneOutcome, *, skip: SkipReason, now: datetime) -> Decision:+def _held(check: PlatformAlertCheckInput, outcome: ControlPlaneOutcome, *, skip: SkipReason, now: datetime) -> Decision:"""A control-plane transition the check machine cannot express. The outcome advances the schedule."""recorded = _recorded(check,@@ -310,7 +310,7 @@ def _held(check: PlatformAlertCheck, outcome: ControlPlaneOutcome, *, skip: Skipdef _evaluate_cohort(team: Team,- checks: Sequence[PlatformAlertCheck],+ checks: Sequence[PlatformAlertCheckInput],key: tuple,*,now: datetime,@@ -360,7 +360,7 @@ def _evaluate_cohort(return decided-def _triage(checks: Sequence[PlatformAlertCheck], *, now: datetime, tz_name: str) -> _Triage:+def _triage(checks: Sequence[PlatformAlertCheckInput], *, now: datetime, tz_name: str) -> _Triage:"""Splits a batch into the checks a query can answer, the ones already decided, and the muted.A skip is a decision, not an omission. Dropping one records nothing, so its due time stays@@ -370,7 +370,7 @@ def _triage(checks: Sequence[PlatformAlertCheck], *, now: datetime, tz_name: strquery like any other and its id lands in the muted set."""decided: list[Decision] = []- evaluable: list[PlatformAlertCheck] = []+ evaluable: list[PlatformAlertCheckInput] = []muted_ids: set[UUID] = set()for check in checks:broken_reason = _detect_broken_filter_config(check.source_config)@@ -454,7 +454,7 @@ def evaluate_logs_batch(team_id: int, slot: str, cutoff: datetime) -> SourceBatclogger.exception("Failed to fetch logs ingestion checkpoint; falling back to wall-clock", error=str(error))checkpoint = None- cohorts: dict[tuple, list[PlatformAlertCheck]] = {}+ cohorts: dict[tuple, list[PlatformAlertCheckInput]] = {}for check in triage.evaluable:cohorts.setdefault(_cohort_key(check, checkpoint, cutoff), []).append(check)