: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
fix(alerts): compare logs alert destinations with every logs default (#126544)
Jimmy Zhu1622a4d58412
diff --git a/products/alerts/backend/facade/destinations.py b/products/alerts/backend/facade/destinations.pyindex 52e905fd2129..32491a1e8ae3 100644--- a/products/alerts/backend/facade/destinations.py+++ b/products/alerts/backend/facade/destinations.py@@ -321,6 +321,18 @@ def customized_alert_destination_ids()+def unrevised_hold_backs(+ config: AlertDestinationConfig, *, allowed_event_ids: Collection[str]+) -> tuple[DestinationHoldBack, ...]:+ """What a destination built from this config holds back when it has no revision to compare with.++ Empty means the source lists every message the builder wrote as one of its defaults.+ """+ return destination_eligibility.unrevised_hold_backs(+ config.payload["template_id"], config.payload["inputs"], allowed_event_ids+ )++def unbound_alert_destinations(*, team_id: int, allowed_event_ids: Collection[str], include_disabled: bool = False) -> tuple[UUID, ...]:diff --git a/products/alerts/backend/logic/destination_eligibility.py b/products/alerts/backend/logic/destination_eligibility.pyindex 20e639d966d5..a45378fcb0f7 100644--- a/products/alerts/backend/logic/destination_eligibility.py+++ b/products/alerts/backend/logic/destination_eligibility.py@@ -8,9 +8,9 @@ HogFunction API writes on the first change it records. A template's stock text cso comparing with what the code builds today would read an old, unedited function as edited.The first snapshot is the stock content only when the function was created with stock inputs. The-logs alert API creates every logs destination that way. The HogFunction editor that insight alerts-use lets a person change the message before the first save. So for insight the first inputs are also-compared with every default an insight alert path has shipped.+HogFunction editor and API let a person write their own message before the first save, for insight+and logs destinations alike. So the first inputs are also compared with every default that the alert+paths of the source have shipped."""from __future__ import annotations@@ -63,9 +63,20 @@ _INPUT_HOLD_BACKS: Final[dict[str, dict[str, DestinationHoldBack]]] = {# Every value an insight alert path has shipped as a default, by template and input key. Built from# git history: the insight alert sub-template, the template defaults, the alert wizard, the backend# Slack blocks, the agent recipes and the chart-block backfill. Add the default of any new path here.-STOCK_INPUT_VALUES: Final[dict[str, dict[str, list[Any]]]] = json.loads(- (Path(__file__).parent / "destination_stock_inputs.json").read_text()-)+StockInputValues = dict[str, dict[str, list[Any]]]+++def _load_stock_input_values(file_name: str) -> StockInputValues:+ return json.loads((Path(__file__).parent / file_name).read_text())+++STOCK_INPUT_VALUES: Final = _load_stock_input_values("destination_stock_inputs.json")+# Every value a logs alert path has written as a default, by template and input key: what the logs+# alert API builds, and the retired Slack messages that functions built in April 2026 still hold. When+# a logs message changes, add the new value and keep the old one, because functions built with it still exist.+LOGS_STOCK_INPUT_VALUES: Final = _load_stock_input_values("logs_destination_stock_inputs.json")+# Matches the logs events that `GENERIC_API_EDITABLE_ALERT_EVENT_SCOPES` in cdp names.+_LOGS_ALERT_EVENT_PREFIX: Final = "$logs_alert_"_NOT_SENT_INPUTS: Final = frozenset({"debug"})_DERIVED_FILTER_KEYS: Final = ("bytecode", "bytecode_error", "bytecode_contract", "transpiled")@@ -146,8 +157,7 @@ def _classify() -> tuple[DestinationEligibility, ...]:if not functions:return ()- # Insight destinations are built in an editor, so the first revision can already hold an edit.- stock = STOCK_INPUT_VALUES if not set(allowed_event_ids).isdisjoint(INSIGHT_ALERT_EVENT_IDS) else {}+ source_stock = _source_stock_input_values(allowed_event_ids)first_revisions: dict[UUID, HogFunctionRevision] = {revision.hog_function_id: revisionfor revision in HogFunctionRevision.objects.for_team(team_id)@@ -160,13 +170,40 @@ def _classify(DestinationEligibility(hog_function_id=function.id,template_id=function.template_id,- hold_backs=_hold_backs(function, first_revisions.get(function.id), stock.get(function.template_id or "")),+ hold_backs=_hold_backs(+ function, first_revisions.get(function.id), _template_stock(source_stock, function.template_id)+ ),code_hash=hashlib.md5((function.hog or "").encode(), usedforsecurity=False).hexdigest(),)for function in functions)+def _source_stock_input_values(allowed_event_ids: Collection[str]) -> StockInputValues | None:+ # The first revision of an insight or logs destination can already hold an edit.+ if not set(allowed_event_ids).isdisjoint(INSIGHT_ALERT_EVENT_IDS):+ return STOCK_INPUT_VALUES+ if any(event_id.startswith(_LOGS_ALERT_EVENT_PREFIX) for event_id in allowed_event_ids):+ return LOGS_STOCK_INPUT_VALUES+ return None+++def _template_stock(source_stock: StockInputValues | None, template_id: str | None) -> dict[str, list[Any]] | None:+ if source_stock is None:+ return None+ # A template missing from the list was never a default of the source, so every message it holds is an edit.+ return source_stock.get(template_id or "", {})+++def unrevised_hold_backs(+ template_id: str, inputs: dict[str, Any], allowed_event_ids: Collection[str]+) -> tuple[DestinationHoldBack, ...]:+ stock = _template_stock(_source_stock_input_values(allowed_event_ids), template_id)+ if stock is None:+ return ()+ return tuple(dict.fromkeys(_stock_hold_backs(template_id, inputs, stock)))++def bucket_for(eligibility: DestinationEligibility) -> DestinationBucket:"""The most restrictive bucket among a destination's hold-backs. No hold-back means stock."""buckets = {_BUCKET_BY_HOLD_BACK.get(hold_back, DestinationBucket.PORTABLE) for hold_back in eligibility.hold_backs}@@ -297,6 +334,9 @@ def _stock_hold_backs(if value in (None, "") or _is_stock_value(inputs, key, stock):continuefound.extend(_key_hold_backs(template_id, key, value))+ # Without a body the webhook template sends none, but native delivery always sends one.+ if template_id == WebhookDestination.template_id and input_value(inputs, "body") in (None, ""):+ found.append(DestinationHoldBack.WEBHOOK_BODY)return founddiff --git a/products/alerts/backend/logic/logs_destination_stock_inputs.json b/products/alerts/backend/logic/logs_destination_stock_inputs.jsonnew file mode 100644index 000000000000..282a9debc098--- /dev/null+++ b/products/alerts/backend/logic/logs_destination_stock_inputs.json@@ -0,0 +1,533 @@+{+ "template-microsoft-teams": {+ "text": [+ "**🔴 Log alert '{event.properties.alert_name}' is firing**\n\n**Threshold breached:** {event.properties.result_count} logs in {event.properties.window_minutes}m (threshold: {event.properties.threshold_operator} {event.properties.threshold_count})\n\n[View logs]({project.url}/logs?{event.properties.logs_url_params})",+ "**🟢 Log alert '{event.properties.alert_name}' has resolved**\n\n**Current count:** {event.properties.result_count} logs in {event.properties.window_minutes}m (threshold: {event.properties.threshold_operator} {event.properties.threshold_count})\n\n[View logs]({project.url}/logs?{event.properties.logs_url_params})",+ "**⚠️ Log alert '{event.properties.alert_name}' was auto-disabled**\n\n**Reason:** {event.properties.consecutive_failures} consecutive check failures.\n\n**Last error:** {event.properties.last_error_message}\n\n[View alert]({project.url}/logs/alerts/{event.properties.alert_id})",+ "**🟡 Log alert '{event.properties.alert_name}' couldn't evaluate**\n\n**Reason:** {event.properties.error_message}\n\n**Failure count:** {event.properties.consecutive_failures}\n\n[View alert]({project.url}/logs/alerts/{event.properties.alert_id})"+ ]+ },+ "template-pagerduty": {+ "custom_details": [+ {+ "Threshold breached": "{event.properties.result_count} logs in {event.properties.window_minutes}m (threshold: {event.properties.threshold_operator} {event.properties.threshold_count})"+ },+ {+ "Reason": "{event.properties.reason}"+ }+ ],+ "dedup_key": ["posthog-alert-{event.properties.alert_id}"],+ "event_action": ["trigger", "resolve"],+ "links": [+ [+ {+ "href": "{project.url}/logs?{event.properties.logs_url_params}",+ "text": "View logs"+ },+ {+ "href": "{project.url}/logs/alerts/{event.properties.alert_id}",+ "text": "View alert"+ }+ ],+ [+ {+ "href": "{project.url}/logs/alerts/{event.properties.alert_id}",+ "text": "View alert"+ }+ ]+ ],+ "source": ["{project.name}"],+ "summary": [+ "🔴 Log alert '{event.properties.alert_name}' is firing: {event.properties.result_count} logs in {event.properties.window_minutes}m (threshold: {event.properties.threshold_operator} {event.properties.threshold_count})",+ "Log alert '{event.properties.alert_name}' stopped firing: {event.properties.reason}"+ ]+ },+ "template-slack": {+ "blocks": [+ [+ {+ "text": {+ "text": "🔴 Log alert '{event.properties.alert_name}' is firing",+ "type": "plain_text"+ },+ "type": "header"+ },+ {+ "text": {+ "text": "*Threshold breached:* {event.properties.result_count} logs in {event.properties.window_minutes}m (threshold: {event.properties.threshold_operator} {event.properties.threshold_count})",+ "type": "mrkdwn"+ },+ "type": "section"+ },+ {+ "elements": [+ {+ "text": "{if(length(event.properties.severity_levels) > 0 or length(event.properties.service_names) > 0, concat( if(length(event.properties.severity_levels) > 0, concat('Severity: ', arrayStringConcat(event.properties.severity_levels, ', ')), ''), if(length(event.properties.severity_levels) > 0 and length(event.properties.service_names) > 0, ' | ', ''), if(length(event.properties.service_names) > 0, concat('Services: ', arrayStringConcat(event.properties.service_names, ', ')), '') ), 'All log levels and services')}",+ "type": "mrkdwn"+ },+ {+ "text": "Project: <{project.url}|{project.name}>",+ "type": "mrkdwn"+ }+ ],+ "type": "context"+ },+ {+ "type": "divider"+ },+ {+ "elements": [+ {+ "text": {+ "text": "View logs",+ "type": "plain_text"+ },+ "type": "button",+ "url": "{project.url}/logs?{event.properties.logs_url_params}"+ }+ ],+ "type": "actions"+ }+ ],+ [+ {+ "text": {+ "text": "🟢 Log alert '{event.properties.alert_name}' has resolved",+ "type": "plain_text"+ },+ "type": "header"+ },+ {+ "text": {+ "text": "*Current count:* {event.properties.result_count} logs in {event.properties.window_minutes}m (threshold: {event.properties.threshold_operator} {event.properties.threshold_count})",+ "type": "mrkdwn"+ },+ "type": "section"+ },+ {+ "elements": [+ {+ "text": "{if(length(event.properties.severity_levels) > 0 or length(event.properties.service_names) > 0, concat( if(length(event.properties.severity_levels) > 0, concat('Severity: ', arrayStringConcat(event.properties.severity_levels, ', ')), ''), if(length(event.properties.severity_levels) > 0 and length(event.properties.service_names) > 0, ' | ', ''), if(length(event.properties.service_names) > 0, concat('Services: ', arrayStringConcat(event.properties.service_names, ', ')), '') ), 'All log levels and services')}",+ "type": "mrkdwn"+ },+ {+ "text": "Project: <{project.url}|{project.name}>",+ "type": "mrkdwn"+ }+ ],+ "type": "context"+ },+ {+ "type": "divider"+ },+ {+ "elements": [+ {+ "text": {+ "text": "View logs",+ "type": "plain_text"+ },+ "type": "button",+ "url": "{project.url}/logs?{event.properties.logs_url_params}"+ }+ ],+ "type": "actions"+ }+ ],+ [+ {+ "text": {+ "text": "⚠️ Log alert '{event.properties.alert_name}' was auto-disabled",+ "type": "plain_text"+ },+ "type": "header"+ },+ {+ "text": {+ "text": "*Reason:* {event.properties.consecutive_failures} consecutive check failures.\n*Last error:* {event.properties.last_error_message}",+ "type": "mrkdwn"+ },+ "type": "section"+ },+ {+ "elements": [+ {+ "text": "{if(length(event.properties.severity_levels) > 0 or length(event.properties.service_names) > 0, concat( if(length(event.properties.severity_levels) > 0, concat('Severity: ', arrayStringConcat(event.properties.severity_levels, ', ')), ''), if(length(event.properties.severity_levels) > 0 and length(event.properties.service_names) > 0, ' | ', ''), if(length(event.properties.service_names) > 0, concat('Services: ', arrayStringConcat(event.properties.service_names, ', ')), '') ), 'All log levels and services')}",+ "type": "mrkdwn"+ },+ {+ "text": "Project: <{project.url}|{project.name}>",+ "type": "mrkdwn"+ }+ ],+ "type": "context"+ },+ {+ "type": "divider"+ },+ {+ "elements": [+ {+ "text": {+ "text": "View alert",+ "type": "plain_text"+ },+ "type": "button",+ "url": "{project.url}/logs/alerts/{event.properties.alert_id}"+ }+ ],+ "type": "actions"+ }+ ],+ [+ {+ "text": {+ "text": "🟡 Log alert '{event.properties.alert_name}' couldn't evaluate",+ "type": "plain_text"+ },+ "type": "header"+ },+ {+ "text": {+ "text": "*Reason:* {event.properties.error_message}\n*Failure count:* {event.properties.consecutive_failures}",+ "type": "mrkdwn"+ },+ "type": "section"+ },+ {+ "elements": [+ {+ "text": "{if(length(event.properties.severity_levels) > 0 or length(event.properties.service_names) > 0, concat( if(length(event.properties.severity_levels) > 0, concat('Severity: ', arrayStringConcat(event.properties.severity_levels, ', ')), ''), if(length(event.properties.severity_levels) > 0 and length(event.properties.service_names) > 0, ' | ', ''), if(length(event.properties.service_names) > 0, concat('Services: ', arrayStringConcat(event.properties.service_names, ', ')), '') ), 'All log levels and services')}",+ "type": "mrkdwn"+ },+ {+ "text": "Project: <{project.url}|{project.name}>",+ "type": "mrkdwn"+ }+ ],+ "type": "context"+ },+ {+ "type": "divider"+ },+ {+ "elements": [+ {+ "text": {+ "text": "View alert",+ "type": "plain_text"+ },+ "type": "button",+ "url": "{project.url}/logs/alerts/{event.properties.alert_id}"+ }+ ],+ "type": "actions"+ }+ ],+ [+ {+ "text": {+ "text": "Log alert '{event.properties.alert_name}' has resolved",+ "type": "plain_text"+ },+ "type": "header"+ },+ {+ "text": {+ "text": "*Current count:* {event.properties.result_count} logs in {event.properties.window_minutes}m (threshold: {event.properties.threshold_operator} {event.properties.threshold_count})",+ "type": "mrkdwn"+ },+ "type": "section"+ },+ {+ "type": "context",+ "elements": [+ {+ "text": "{if(length(event.properties.severity_levels) > 0 or length(event.properties.service_names) > 0, concat( if(length(event.properties.severity_levels) > 0, concat('Severity: ', arrayStringConcat(event.properties.severity_levels, ', ')), ''), if(length(event.properties.severity_levels) > 0 and length(event.properties.service_names) > 0, ' | ', ''), if(length(event.properties.service_names) > 0, concat('Services: ', arrayStringConcat(event.properties.service_names, ', ')), '') ), 'All log levels and services')}",+ "type": "mrkdwn"+ },+ {+ "text": "Project: <{project.url}|{project.name}>",+ "type": "mrkdwn"+ }+ ]+ },+ {+ "type": "divider"+ },+ {+ "type": "actions",+ "elements": [+ {+ "url": "{project.url}/logs?{event.properties.logs_url_params}",+ "text": {+ "text": "View logs",+ "type": "plain_text"+ },+ "type": "button"+ }+ ]+ }+ ],+ [+ {+ "text": {+ "text": "Log alert '{event.properties.alert_name}' {if(event.event == '$logs_alert_resolved', 'has resolved', 'is firing')}",+ "type": "plain_text"+ },+ "type": "header"+ },+ {+ "text": {+ "text": "*{if(event.event == '$logs_alert_resolved', 'Current count', 'Threshold breached')}:* {event.properties.result_count} logs in {event.properties.window_minutes}m (threshold: {event.properties.threshold_operator} {event.properties.threshold_count})",+ "type": "mrkdwn"+ },+ "type": "section"+ },+ {+ "type": "context",+ "elements": [+ {+ "text": "{if(length(event.properties.severity_levels) > 0 or length(event.properties.service_names) > 0, concat(if(length(event.properties.severity_levels) > 0, concat('Severity: ', arrayStringConcat(event.properties.severity_levels, ', ')), ''),if(length(event.properties.severity_levels) > 0 and length(event.properties.service_names) > 0, ' | ', ''),if(length(event.properties.service_names) > 0, concat('Services: ', arrayStringConcat(event.properties.service_names, ', ')), '')), 'All log levels and services')}",+ "type": "mrkdwn"+ },+ {+ "text": "Project: <{project.url}|{project.name}>",+ "type": "mrkdwn"+ }+ ]+ },+ {+ "type": "divider"+ },+ {+ "type": "actions",+ "elements": [+ {+ "url": "{project.url}/logs?{event.properties.logs_url_params}",+ "text": {+ "text": "View logs",+ "type": "plain_text"+ },+ "type": "button"+ }+ ]+ }+ ],+ [+ {+ "text": {+ "text": "Log alert '{event.properties.alert_name}' is firing",+ "type": "plain_text"+ },+ "type": "header"+ },+ {+ "text": {+ "text": "*Threshold breached:* {event.properties.result_count} logs in {event.properties.window_minutes}m (threshold: {event.properties.threshold_operator} {event.properties.threshold_count})",+ "type": "mrkdwn"+ },+ "type": "section"+ },+ {+ "type": "context",+ "elements": [+ {+ "text": "{if(length(event.properties.severity_levels) > 0 or length(event.properties.service_names) > 0, concat( if(length(event.properties.severity_levels) > 0, concat('Severity: ', arrayStringConcat(event.properties.severity_levels, ', ')), ''), if(length(event.properties.severity_levels) > 0 and length(event.properties.service_names) > 0, ' | ', ''), if(length(event.properties.service_names) > 0, concat('Services: ', arrayStringConcat(event.properties.service_names, ', ')), '') ), 'All log levels and services')}",+ "type": "mrkdwn"+ },+ {+ "text": "Project: <{project.url}|{project.name}>",+ "type": "mrkdwn"+ }+ ]+ },+ {+ "type": "divider"+ },+ {+ "type": "actions",+ "elements": [+ {+ "url": "{project.url}/logs?{event.properties.logs_url_params}",+ "text": {+ "text": "View logs",+ "type": "plain_text"+ },+ "type": "button"+ }+ ]+ }+ ],+ [+ {+ "text": {+ "text": "Log alert '{event.properties.alert_name}' is firing",+ "type": "plain_text"+ },+ "type": "header"+ },+ {+ "text": {+ "text": "*Threshold breached:* {event.properties.threshold_count} logs in {event.properties.window_minutes}m (limit: {event.properties.threshold_operator} {event.properties.threshold_value})",+ "type": "mrkdwn"+ },+ "type": "section"+ },+ {+ "type": "context",+ "elements": [+ {+ "text": "Project: <{project.url}|{project.name}>",+ "type": "mrkdwn"+ }+ ]+ },+ {+ "type": "divider"+ },+ {+ "type": "actions",+ "elements": [+ {+ "url": "{project.url}/logs?{event.properties.logs_url_params}",+ "text": {+ "text": "View logs",+ "type": "plain_text"+ },+ "type": "button"+ }+ ]+ }+ ],+ [+ {+ "text": {+ "text": "Log alert '{event.properties.alert_name}' was auto-disabled",+ "type": "plain_text"+ },+ "type": "header"+ },+ {+ "text": {+ "text": "*Reason:* {event.properties.consecutive_failures} consecutive check failures.\n*Last error:* {event.properties.last_error_message}",+ "type": "mrkdwn"+ },+ "type": "section"+ },+ {+ "type": "context",+ "elements": [+ {+ "text": "{if(length(event.properties.severity_levels) > 0 or length(event.properties.service_names) > 0, concat( if(length(event.properties.severity_levels) > 0, concat('Severity: ', arrayStringConcat(event.properties.severity_levels, ', ')), ''), if(length(event.properties.severity_levels) > 0 and length(event.properties.service_names) > 0, ' | ', ''), if(length(event.properties.service_names) > 0, concat('Services: ', arrayStringConcat(event.properties.service_names, ', ')), '') ), 'All log levels and services')}",+ "type": "mrkdwn"+ },+ {+ "text": "Project: <{project.url}|{project.name}>",+ "type": "mrkdwn"+ }+ ]+ },+ {+ "type": "divider"+ },+ {+ "type": "actions",+ "elements": [+ {+ "url": "{project.url}/logs?alertId={event.properties.alert_id}",+ "text": {+ "text": "View alert",+ "type": "plain_text"+ },+ "type": "button"+ }+ ]+ }+ ]+ ],+ "text": [+ "🔴 Log alert '{event.properties.alert_name}' is firing",+ "🟢 Log alert '{event.properties.alert_name}' has resolved",+ "⚠️ Log alert '{event.properties.alert_name}' was auto-disabled",+ "🟡 Log alert '{event.properties.alert_name}' couldn't evaluate",+ "Log alert '{event.properties.alert_name}' has resolved",+ "Log alert '{event.properties.alert_name}' {if(event.event == '$logs_alert_resolved', 'has resolved', 'is firing')}",+ "Log alert '{event.properties.alert_name}' is firing",+ "Log alert '{event.properties.alert_name}' was auto-disabled"+ ]+ },+ "template-webhook": {+ "body": [+ {+ "data": {+ "alert_id": "{event.properties.alert_id}",+ "alert_name": "{event.properties.alert_name}",+ "alert_url": "{project.url}/logs/alerts/{event.properties.alert_id}",+ "logs_url": "{project.url}/logs?{event.properties.logs_url_params}",+ "result_count": "{event.properties.result_count}",+ "service_names": "{event.properties.service_names}",+ "severity_levels": "{event.properties.severity_levels}",+ "threshold_count": "{event.properties.threshold_count}",+ "threshold_operator": "{event.properties.threshold_operator}",+ "window_minutes": "{event.properties.window_minutes}"+ },+ "id": "{event.uuid}",+ "timestamp": "{event.properties.triggered_at}",+ "type": "logs_alert.firing"+ },+ {+ "data": {+ "alert_id": "{event.properties.alert_id}",+ "alert_name": "{event.properties.alert_name}",+ "alert_url": "{project.url}/logs/alerts/{event.properties.alert_id}",+ "logs_url": "{project.url}/logs?{event.properties.logs_url_params}",+ "result_count": "{event.properties.result_count}",+ "service_names": "{event.properties.service_names}",+ "severity_levels": "{event.properties.severity_levels}",+ "threshold_count": "{event.properties.threshold_count}",+ "threshold_operator": "{event.properties.threshold_operator}",+ "window_minutes": "{event.properties.window_minutes}"+ },+ "id": "{event.uuid}",+ "timestamp": "{event.properties.triggered_at}",+ "type": "logs_alert.resolved"+ },+ {+ "data": {+ "alert_id": "{event.properties.alert_id}",+ "alert_name": "{event.properties.alert_name}",+ "alert_url": "{project.url}/logs/alerts/{event.properties.alert_id}",+ "consecutive_failures": "{event.properties.consecutive_failures}",+ "last_error_message": "{event.properties.last_error_message}",+ "service_names": "{event.properties.service_names}",+ "severity_levels": "{event.properties.severity_levels}"+ },+ "id": "{event.uuid}",+ "timestamp": "{event.properties.triggered_at}",+ "type": "logs_alert.auto_disabled"+ },+ {+ "data": {+ "alert_id": "{event.properties.alert_id}",+ "alert_name": "{event.properties.alert_name}",+ "alert_url": "{project.url}/logs/alerts/{event.properties.alert_id}",+ "consecutive_failures": "{event.properties.consecutive_failures}",+ "error_message": "{event.properties.error_message}",+ "service_names": "{event.properties.service_names}",+ "severity_levels": "{event.properties.severity_levels}"+ },+ "id": "{event.uuid}",+ "timestamp": "{event.properties.triggered_at}",+ "type": "logs_alert.errored"+ }+ ],+ "headers": [+ {+ "Content-Type": "application/json",+ "X-PostHog-Webhook-Version": "1"+ }+ ],+ "method": ["POST"]+ }+}diff --git a/products/alerts/backend/test/test_destination_eligibility.py b/products/alerts/backend/test/test_destination_eligibility.pyindex 7dcdbe9ced70..bae986af8f6f 100644--- a/products/alerts/backend/test/test_destination_eligibility.py+++ b/products/alerts/backend/test/test_destination_eligibility.py@@ -21,7 +21,7 @@ from products.alerts.backend.facade.destinations import (unbound_alert_destinations,)from products.alerts.backend.logic.destination_bucket_report import bucketed_destinations-from products.alerts.backend.logic.destination_eligibility import STOCK_INPUT_VALUES+from products.alerts.backend.logic.destination_eligibility import LOGS_STOCK_INPUT_VALUES, STOCK_INPUT_VALUESfrom products.alerts.backend.logic.insight_alert_destinations import build_insight_alert_slack_configfrom products.alerts_platform.backend.facade.contracts import AlertDestinationData, DestinationTypefrom products.cdp.backend.models.hog_functions.hog_function import HogFunction@@ -32,7 +32,7 @@ EVENT = "$logs_alert_firing"WEBHOOK_INPUTS: dict[str, Any] = {"url": {"value": "https://hooks.example.com/hook"},"method": {"value": "POST"},- "body": {"value": {"type": "logs_alert.firing"}},+ "body": {"value": LOGS_STOCK_INPUT_VALUES["template-webhook"]["body"][0]},"headers": {"value": {"Content-Type": "application/json"}},}PAGERDUTY_INPUTS: dict[str, Any] = {@@ -48,7 +48,7 @@ INSIGHT_SLACK_DATA: AlertDestinationData = {SLACK_INPUTS: dict[str, Any] = {"slack_workspace": {"value": 1},"channel": {"value": "C-1"},- "text": {"value": "Log alert is firing"},+ "text": {"value": LOGS_STOCK_INPUT_VALUES["template-slack"]["text"][0]},}@@ -424,10 +424,19 @@ class TestDestinationEligibility(APIBaseTest):(eligibility,) = classify_alert_destinations(team_id=self.team.id, alert_id=ALERT_ID, allowed_event_ids=[event])assert eligibility.hold_backs == expected- def test_a_logs_destination_is_not_compared_with_insight_defaults(self) -> None:- self._function("template-slack", _with(SLACK_INPUTS, "text", "Look at this"))+ @parameterized.expand(+ [+ ("logs_default", LOGS_STOCK_INPUT_VALUES["template-slack"]["text"][1], ()),+ ("own_text", "Look at this", (DestinationHoldBack.MESSAGE,)),+ ("insight_default", STOCK_INPUT_VALUES["template-slack"]["text"][0], (DestinationHoldBack.MESSAGE,)),+ ]+ )+ def test_a_logs_destination_built_without_a_revision_is_compared_with_logs_defaults(+ self, _name: str, text: str, expected: tuple[DestinationHoldBack, ...]+ ) -> None:+ self._function("template-slack", _with(SLACK_INPUTS, "text", text))- assert self._classify() == ()+ assert self._classify() == expectedclass TestBucketFor(SimpleTestCase):diff --git a/products/logs/backend/test/test_alert_destinations.py b/products/logs/backend/test/test_alert_destinations.pyindex fe4fbffd3bfa..05c4c24e09cd 100644--- a/products/logs/backend/test/test_alert_destinations.py+++ b/products/logs/backend/test/test_alert_destinations.py@@ -4,7 +4,12 @@ from django.test import SimpleTestCasefrom parameterized import parameterized-from products.alerts.backend.facade.destinations import build_alert_destination_config, validate_destination_data+from products.alerts.backend.facade.destinations import (+ build_alert_destination_config,+ destination_handles_event_kind,+ unrevised_hold_backs,+ validate_destination_data,+)from products.alerts_platform.backend.facade.contracts import (AlertDestinationData,AlertDestinationValidationError,@@ -66,6 +71,8 @@ SLACK_DATA = cast(AlertDestinationData, {"type": DestinationType.SLACK, "slack_workspace_id": 1, "slack_channel_id": "C-ENG"})TEAMS_DATA = cast(AlertDestinationData, {"type": DestinationType.TEAMS, "webhook_url": "https://example.com/hook"})+WEBHOOK_DATA = cast(AlertDestinationData, {"type": DestinationType.WEBHOOK, "webhook_url": "https://example.com/hook"})+PAGERDUTY_DATA = cast(AlertDestinationData, {"type": DestinationType.PAGERDUTY, "pagerduty_routing_key": "a" * 32})def destination_inputs(kind: EventKind, data: AlertDestinationData) -> dict[str, Any]:@@ -83,6 +90,27 @@ MESSAGE_KINDS = [kind for kind in EVENT_KINDS if EVENT_KIND_CONFIG[kind].incidenclass TestRenderedDestinationContent(SimpleTestCase):+ @parameterized.expand(+ [+ (f"{kind}_{data['type']}", kind, data)+ for kind in EVENT_KINDS+ for data in (SLACK_DATA, TEAMS_DATA, WEBHOOK_DATA, PAGERDUTY_DATA)+ if destination_handles_event_kind(data["type"], EVENT_KIND_CONFIG[kind])+ ]+ )+ def test_every_default_message_is_in_the_stock_list_native_delivery_reads(+ self, _name: str, kind: EventKind, data: AlertDestinationData+ ) -> None:+ spec = EVENT_KIND_CONFIG[kind]+ config = build_alert_destination_config(+ spec=spec,+ alert_id="alert-1",+ alert_name="Checkout errors",+ data=data,+ slack_context_elements=LOGS_ALERT_SLACK_CONTEXT_ELEMENTS,+ )+ assert unrevised_hold_backs(config, allowed_event_ids=[spec.event_id]) == ()+@parameterized.expand([(kind,) for kind in MESSAGE_KINDS])def test_slack_body_puts_every_detail_on_its_own_line(self, kind: EventKind) -> None:spec = EVENT_KIND_CONFIG[kind]diff --git a/products/logs/backend/test/test_platform_cutover.py b/products/logs/backend/test/test_platform_cutover.pyindex 99e561a88e12..1d4e5d2b274d 100644--- a/products/logs/backend/test/test_platform_cutover.py+++ b/products/logs/backend/test/test_platform_cutover.py@@ -1,5 +1,5 @@from datetime import UTC, datetime, timedelta-from typing import Any+from typing import Any, castfrom uuid import UUIDfrom posthog.test.base import APIBaseTest@@ -11,12 +11,23 @@ from posthog.models.scoping import team_scopefrom posthog.models.team import Teamfrom products.alerts.backend.facade.contracts import HogFunctionPathReason+from products.alerts.backend.facade.destinations import build_alert_destination_configfrom products.alerts_platform.backend.facade import testing as platform_testingfrom products.alerts_platform.backend.facade.api import get_configuration, list_configurations, upsert_configuration-from products.alerts_platform.backend.facade.contracts import DeliveryPath, SourceKind+from products.alerts_platform.backend.facade.contracts import (+ AlertDestinationData,+ DeliveryPath,+ DestinationType,+ SourceKind,+)from products.cdp.backend.models.hog_functions.hog_function import HogFunctionfrom products.cdp.backend.models.hog_functions.hog_function_revision import HogFunctionRevision-from products.logs.backend.alert_destinations import LOGS_ALERT_EVENT_IDS+from products.logs.backend.alert_destinations import (+ EVENT_KIND_CONFIG,+ LOGS_ALERT_EVENT_IDS,+ LOGS_ALERT_SLACK_CONTEXT_ELEMENTS,+ EventKind,+)from products.logs.backend.delivery_path_report import team_delivery_pathsfrom products.logs.backend.models import LogsAlertConfiguration, LogsAlertEventfrom products.logs.backend.platform_alert_backfill import platform_upsert_of@@ -26,18 +37,29 @@ NOW = datetime(2026, 10, 13, 12, 0, tzinfo=UTC)State = LogsAlertConfiguration.StateLEGACY_BODY_FLAG = "products.alerts_platform.backend.delivery.team_flags.posthoganalytics.feature_enabled"STOCK_HOG = "return event"-WEBHOOK_INPUTS: dict[str, Any] = {- "url": {"value": "https://hooks.example.com/hook"},- "method": {"value": "POST"},- "body": {"value": {"type": "logs_alert.firing"}},-}-SLACK_INPUTS: dict[str, Any] = {- "slack_workspace": {"value": 1},- "channel": {"value": "C-1"},- "text": {"value": "Log alert is firing"},+DESTINATION_DATA: dict[DestinationType, dict[str, Any]] = {+ DestinationType.SLACK: {"slack_workspace_id": 1, "slack_channel_id": "C-1"},+ DestinationType.WEBHOOK: {"webhook_url": "https://hooks.example.com/hook"},+ DestinationType.TEAMS: {"webhook_url": "https://example.webhook.office.com/webhookb2/a/IncomingWebhook/b/c"},+ DestinationType.PAGERDUTY: {"pagerduty_routing_key": "a" * 32},}+def stock_destination(kind: EventKind, destination_type: DestinationType) -> tuple[str, dict[str, Any]]:+ payload = build_alert_destination_config(+ spec=EVENT_KIND_CONFIG[kind],+ alert_id="alert-1",+ alert_name="Checkout errors",+ data=cast(AlertDestinationData, {"type": destination_type, **DESTINATION_DATA[destination_type]}),+ slack_context_elements=LOGS_ALERT_SLACK_CONTEXT_ELEMENTS,+ ).payload+ return payload["template_id"], payload["inputs"]+++_, WEBHOOK_INPUTS = stock_destination("firing", DestinationType.WEBHOOK)+_, SLACK_INPUTS = stock_destination("firing", DestinationType.SLACK)++class TestPlatformCutover(APIBaseTest):def _alert(self, **overrides: Any) -> LogsAlertConfiguration:fields: dict[str, Any] = {@@ -307,6 +329,22 @@ class TestPlatformCutover(APIBaseTest):True,HogFunctionPathReason.CUSTOMIZED,),+ (+ "body_written_before_the_first_save",+ "template-webhook",+ {**WEBHOOK_INPUTS, "body": {"value": {"embeds": [{"title": "{event.properties.alert_name}"}]}}},+ {},+ True,+ HogFunctionPathReason.CUSTOMIZED,+ ),+ (+ "no_body",+ "template-webhook",+ {key: value for key, value in WEBHOOK_INPUTS.items() if key != "body"},+ {},+ True,+ HogFunctionPathReason.CUSTOMIZED,+ ),("secret_header","template-webhook",@@ -359,15 +397,15 @@ class TestPlatformCutover(APIBaseTest):@parameterized.expand([- ("stock_slack", "template-slack", SLACK_INPUTS, {}),- ("stock_webhook_with_legacy_body", "template-webhook", WEBHOOK_INPUTS, {}),+ ("stock_slack", "template-slack", SLACK_INPUTS),+ ("stock_webhook_with_legacy_body", "template-webhook", WEBHOOK_INPUTS),])def test_a_team_moves_when_every_destination_is_ready(- self, _name: str, template_id: str, inputs: dict[str, Any], edit: dict[str, Any]+ self, _name: str, template_id: str, inputs: dict[str, Any]) -> None:alert = self._alert()- self._destination(alert.id, template_id, inputs, edit)+ self._destination(alert.id, template_id, inputs)with patch(LEGACY_BODY_FLAG, return_value=True):paths = team_delivery_paths(self.team.id)