Skip to content

: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.

feat(alerts): deliver natively only for alerts the platform owns (#130584)

Jimmy Zhud3e516479eb8
diff --git a/products/alerts/backend/platform_source_cycle.py b/products/alerts/backend/platform_source_cycle.py
index e3bbd9f5f6d3..fefc49abf6c7 100644
--- a/products/alerts/backend/platform_source_cycle.py
+++ b/products/alerts/backend/platform_source_cycle.py
@@ -2,9 +2,7 @@
A parallel run. The production insight fleet evaluates the same alerts against
`AlertConfiguration` and notifies their destinations. This decides what the platform would have
-said, and asks for a delivery for the alerts the platform owns and for the alerts in
-`LIVE_DELIVERY_INSIGHT_ALERT_IDS`. An owned alert sends without the platform's live delivery flag.
-Every other alert on the list still sends only to projects on that flag.
+said, and asks for a delivery only for the alerts the platform owns.
Each platform row resolves to its production alert through `legacy_configuration_id`, because
`check_alert_for_insight` reads the insight, the threshold and the condition off that model. The
@@ -179,11 +177,6 @@ EVALUATED_INTERVALS = frozenset(
)
-# The production insight alerts whose platform evaluations ask for a native delivery while production
-# still owns them, as a test. The platform's live delivery flag still has to be on for the project.
-# The list stays short because production also sends for these alerts, so each one sends twice.
-LIVE_DELIVERY_INSIGHT_ALERT_IDS: Final = frozenset({"01a11d6f-598e-0000-8529-4bcb65526f6d"})
-
# Which event each announced kind's destinations listen on. A resolve is left out, because
# production never announces one and the analytics platform team has not agreed to start. A kind
# with no event id reaches no destination.
@@ -580,16 +573,15 @@ def _delivery(check: PlatformAlertCheckInput, outcome: PlatformAlertOutcome) ->
paging destination needs one resolve for every trigger. An alert with no such destination gets
no incident action, so its edges start no delivery.
"""
+ # Destinations are matched on the legacy alert's id, so a copy without one has nobody to send to.
+ # A source-owned alert is the insight stack's to send.
+ if check.legacy_configuration_id is None or not check.owned_by_platform:
+ return None
+ legacy_id = str(check.legacy_configuration_id)
kinds = [group.kind for group in outcome.groups]
if outcome.failure is not None:
kinds.append(outcome.failure.kind)
sends_messages = any(kind.value in _EVENT_IDS_BY_KIND for kind in kinds)
- # Destinations are matched on the legacy alert's id, so a copy without one has nobody to send to.
- if check.legacy_configuration_id is None:
- return None
- legacy_id = str(check.legacy_configuration_id)
- if not check.owned_by_platform and legacy_id not in LIVE_DELIVERY_INSIGHT_ALERT_IDS:
- return None
actions = _incident_actions(check, outcome)
if actions and not configured_destination_template_ids(
team_id=check.team_id,
@@ -611,7 +603,7 @@ def _delivery(check: PlatformAlertCheckInput, outcome: PlatformAlertOutcome) ->
incident_actions=actions,
sends_messages=sends_messages,
source_alert_url=_alert_url(check, legacy_id),
- owned_by_platform=check.owned_by_platform,
+ owned_by_platform=True,
overflowed=outcome.overflowed,
overflow_is_lower_bound=outcome.overflow_is_lower_bound,
parts=delivery_parts(outcome, actions),
diff --git a/products/alerts/backend/test/test_platform_source_cycle.py b/products/alerts/backend/test/test_platform_source_cycle.py
index d54c1f205929..d2213ad1927c 100644
--- a/products/alerts/backend/test/test_platform_source_cycle.py
+++ b/products/alerts/backend/test/test_platform_source_cycle.py
@@ -528,21 +528,19 @@ class TestPlatformInsightEvaluation(APIBaseTest):
@parameterized.expand(
[
- # name, allowlisted, was_firing, owned, paged, breaks, (incident_actions, sends_messages) or no delivery
- ("allowlisted", True, False, False, False, False, ({}, True)),
- ("not_allowlisted", False, False, False, False, False, None),
- ("allowlisted_resolve", True, True, False, False, False, None),
- ("platform_owned", False, False, True, False, False, ({}, True)),
- ("paged_firing", False, False, True, True, False, ({"": IncidentAction.TRIGGER}, True)),
- ("paged_resolve", False, True, True, True, False, ({"": IncidentAction.RESOLVE}, False)),
- ("paged_firing_that_breaks", False, True, True, True, True, ({}, True)),
- ("paged_but_not_allowlisted", False, False, False, True, False, None),
+ # name, was_firing, owned, paged, breaks, (incident_actions, sends_messages) or no delivery
+ ("source_owned", False, False, False, False, None),
+ ("platform_owned", False, True, False, False, ({}, True)),
+ ("platform_owned_resolve", True, True, False, False, None),
+ ("paged_firing", False, True, True, False, ({"": IncidentAction.TRIGGER}, True)),
+ ("paged_resolve", True, True, True, False, ({"": IncidentAction.RESOLVE}, False)),
+ ("paged_firing_that_breaks", True, True, True, True, ({}, True)),
+ ("paged_but_source_owned", False, False, True, False, None),
]
)
- def test_only_an_allowlisted_or_platform_owned_firing_failure_or_incident_edge_asks_for_a_delivery(
+ def test_only_a_platform_owned_firing_failure_or_incident_edge_asks_for_a_delivery(
self,
_name: str,
- allowlisted: bool,
was_firing: bool,
owned: bool,
paged: bool,
@@ -551,7 +549,6 @@ class TestPlatformInsightEvaluation(APIBaseTest):
) -> None:
alert = self._alert()
configuration = self._copy(alert, **({"owner": PlatformAlertOwner.PLATFORM} if owned else {}))
- allowlist = frozenset({str(alert.id)}) if allowlisted else frozenset()
if paged:
HogFunction.objects.create(
team=self.team,
@@ -573,13 +570,12 @@ class TestPlatformInsightEvaluation(APIBaseTest):
with team_scope(self.team.id):
platform_testing.set_due_at(configuration.id, CUTOFF - timedelta(minutes=1))
- with patch(f"{_MODULE}.LIVE_DELIVERY_INSIGHT_ALERT_IDS", allowlist):
- self._evaluate(
- configuration,
- result=AlertExtractionError("bad query shape")
- if breaks
- else AlertEvaluationResult(value=50.0, breaches=[] if was_firing else ["above 100"]),
- )
+ self._evaluate(
+ configuration,
+ result=AlertExtractionError("bad query shape")
+ if breaks
+ else AlertEvaluationResult(value=50.0, breaches=[] if was_firing else ["above 100"]),
+ )
expected = (
[
diff --git a/products/alerts_platform/backend/delivery/evaluation.py b/products/alerts_platform/backend/delivery/evaluation.py
index 1268fe9abffb..daa1cabeede8 100644
--- a/products/alerts_platform/backend/delivery/evaluation.py
+++ b/products/alerts_platform/backend/delivery/evaluation.py
@@ -27,7 +27,6 @@ from products.alerts_platform.backend.delivery.in_app import InAppTransport
from products.alerts_platform.backend.delivery.message import INCIDENT_KINDS, AlertMessage
from products.alerts_platform.backend.delivery.pagerduty import PagerDutyTransport, source_incident_key
from products.alerts_platform.backend.delivery.slack import SlackTransport
-from products.alerts_platform.backend.delivery.team_flags import team_flag_enabled
from products.alerts_platform.backend.delivery.teams import TeamsTransport
from products.alerts_platform.backend.delivery.telemetry import record_delivery
from products.alerts_platform.backend.delivery.thread_store import DatabaseThreadStore, ThreadBusy, ThreadKey
@@ -63,16 +62,10 @@ logger = structlog.get_logger(__name__)
_EMISSION_PROVIDER: Final = "legacy_events"
_EMISSION_EPISODE: Final = datetime(1970, 1, 1, tzinfo=UTC)
-# Whether the platform may contact a team's destinations for an alert its source still owns. Only
-# the platform reads it: the source keeps delivering regardless, so a team with this on receives
-# the legacy message and the native one. An alert the platform owns never reads it, because the
-# source sends nothing for that alert and a flag-eval failure would silence it.
-LIVE_DELIVERY_FLAG: Final = "alert-platform-live-delivery"
-
-# A destination type with no entry here has no native transport, and delivery skips it. Make a
-# team live only when its alerts use no such type. Nothing checks this in code, and one alert
-# delivering natively to one destination and through a HogFunction to another would send two
-# differently worded messages for one event.
+# A destination type with no entry here has no native transport, and delivery skips it. Hand an
+# alert to the platform only when its destinations use no such type. Nothing checks this in code,
+# and one alert delivering natively to one destination and through a HogFunction to another would
+# send two differently worded messages for one event.
_TRANSPORTS: Final[dict[DestinationType, type[DeliveryTransport]]] = {
DestinationType.SLACK: SlackTransport,
DestinationType.WEBHOOK: WebhookTransport,
@@ -96,29 +89,12 @@ class DeliveryOutcome:
emitted_events: int = 0
-def destinations_are_live(team: Team) -> bool:
- """Whether this team's destinations are the platform's to contact.
-
- Fail closed. A flag-eval blip leaves the production logs path as the only deliverer, which
- is where everything was before this existed. Reading a blip the other way starts sending.
- """
- try:
- return bool(team_flag_enabled(LIVE_DELIVERY_FLAG, team))
- except Exception:
- logger.warning(
- "alerts_platform_live_delivery_flag_check_failed_defaulting_off",
- team_id=team.id,
- exc_info=True,
- )
- return False
-
-
class _WebhookTransports:
"""The webhook transport for one evaluation, with the legacy body when the team keeps it.
- The flag is read once, and only when a webhook destination is about to be sent to. Unlike the
- live-delivery flag, a failed read is a failed delivery: a guess either way sends a body some
- receiver cannot parse, and a retry costs only time.
+ The flag is read once, and only when a webhook destination is about to be sent to. A failed read
+ is a failed delivery: a guess either way sends a body some receiver cannot parse, and a retry
+ costs only time.
"""
def __init__(self, team: Team, request: AlertDeliveryRequest, announced: EvaluationAnnouncement) -> None:
@@ -167,8 +143,11 @@ class _WebhookTransports:
def deliver_evaluation(request: AlertDeliveryRequest) -> DeliveryOutcome:
"""Sends what one evaluation decided, to every destination configured for it."""
+ # A source that still owns its alert sends its own message, so the platform sends nothing for it.
+ if not request.owned_by_platform:
+ return DeliveryOutcome(live=False, sent=0, skipped_without_transport=0)
team = Team.objects.filter(id=request.team_id).first()
- if team is None or not (request.owned_by_platform or destinations_are_live(team)):
+ if team is None:
return DeliveryOutcome(live=False, sent=0, skipped_without_transport=0)
if delivery_holds.blocks_delivery(request.team_id, request.configuration_id, request.evaluation_key):
logger.info(
@@ -303,9 +282,7 @@ def deliver_evaluation(request: AlertDeliveryRequest) -> DeliveryOutcome:
),
incident_action=action_by_event_id.get(event_id),
source_alert_url=request.source_alert_url,
- source_incident_key=source_incident_key(request.destination_alert_id)
- if request.owned_by_platform
- else None,
+ source_incident_key=source_incident_key(request.destination_alert_id),
project=project,
)
except ThreadBusy as error:
@@ -397,9 +374,6 @@ def _split_by_path(
) -> tuple[EvaluationAnnouncement, tuple[LegacyEventEmission, ...]]:
"""The transitions HogFunction destinations receive natively, and the ones the source emits for them.
- Only an alert the platform owns can take the HogFunction path. While the source owns it, its
- own stack emits those events, and emitting them here too would send every message twice.
-
A transition inside a firing takes the path its firing took first, so a firing and its resolve
never split across paths. Any other transition takes the path its destinations allow now.
@@ -411,7 +385,7 @@ def _split_by_path(
paths, so nothing is sent twice. Moving an existing alert's destinations onto the platform must
therefore disable the HogFunctions it copies, or each of them hears every transition as well.
"""
- if not request.owned_by_platform or delivery_paths.emitter_for(request.source) is None:
+ if delivery_paths.emitter_for(request.source) is None:
return announced, ()
if platform_destinations is not None:
return announced, _emissions(request, announced.transitions)
@@ -552,9 +526,7 @@ class _PlatformDestinations:
def _platform_destinations(request: AlertDeliveryRequest) -> _PlatformDestinations | None:
"""The alert's destinations when the platform owns them, or None when its source's HogFunctions
hold them. Read once per delivery, and after the check, so a destination removed in between is
- not sent to. Only an alert the platform owns can have its destinations on the platform."""
- if not request.owned_by_platform:
- return None
+ not sent to."""
owner = (
PlatformAlertConfiguration.objects.for_team(request.team_id)
.filter(id=request.configuration_id)
diff --git a/products/alerts_platform/backend/temporal/workflows.py b/products/alerts_platform/backend/temporal/workflows.py
index 37f52178b885..ad2d2c005b0b 100644
--- a/products/alerts_platform/backend/temporal/workflows.py
+++ b/products/alerts_platform/backend/temporal/workflows.py
@@ -182,10 +182,10 @@ async def alerts_platform_emit_transitions_activity(request: AlertDeliveryReques
@activity.defn
async def alerts_platform_deliver_preview_activity(request: AlertDeliveryRequest) -> None:
- """Sends what one evaluation decided, once destinations are live for the team.
+ """Sends what one evaluation decided, for an alert the platform owns.
- Until then it records what it would have sent and contacts nobody, which is the same shape
- the activity has had since the PoC.
+ For an alert its source still owns it records a preview and contacts nobody, because the
+ source sends its own message.
The delivery package is synchronous: it reads the history, resolves destinations through
the ORM and posts over a blocking client. Django refuses an ORM call from a thread with a
diff --git a/products/alerts_platform/backend/tests/test_delivery_evaluation.py b/products/alerts_platform/backend/tests/test_delivery_evaluation.py
index 98d1c9f21a3e..56dc8d35d138 100644
--- a/products/alerts_platform/backend/tests/test_delivery_evaluation.py
+++ b/products/alerts_platform/backend/tests/test_delivery_evaluation.py
@@ -14,7 +14,7 @@ from posthog.utils import absolute_uri
from products.alerts_platform.backend.delivery import delivery_paths, describers, legacy_webhook, recipients
from products.alerts_platform.backend.delivery.destinations import list_alert_destination_groups
-from products.alerts_platform.backend.delivery.evaluation import LIVE_DELIVERY_FLAG, deliver_evaluation
+from products.alerts_platform.backend.delivery.evaluation import deliver_evaluation
from products.alerts_platform.backend.delivery.legacy_webhook import LEGACY_WEBHOOK_BODY_FLAG
from products.alerts_platform.backend.delivery.message import AlertMessage
from products.alerts_platform.backend.delivery.thread_store import ThreadBusy
@@ -120,7 +120,7 @@ def _request(
configuration_id: str = CONFIGURATION_ID,
sends_messages: bool = True,
incident_actions: dict[str, IncidentAction] | None = None,
- owned_by_platform: bool = False,
+ owned_by_platform: bool = True,
overflowed: int = 0,
overflow_is_lower_bound: bool = False,
parts: int = 1,
@@ -185,25 +185,20 @@ class TestDeliverEvaluation(APIBaseTest):
self,
announced: Any,
by_event: dict[str, list[AlertDestinationGroup]],
- live: bool | Exception = True,
transports: dict[DestinationType, type] | None = None,
sends_messages: bool = True,
incident_actions: dict[str, IncidentAction] | None = None,
- owned_by_platform: bool = False,
overflowed: int = 0,
overflow_is_lower_bound: bool = False,
parts: int = 1,
part: int = 0,
+ source_alert_url: str | None = None,
kinds: dict[str, AlertEventKind] | None = None,
) -> Any:
def groups(*, team_id: int, alert_id: str, allowed_event_ids: list[str]) -> list[AlertDestinationGroup]:
return by_event.get(allowed_event_ids[0], [])
with (
- patch(
- "products.alerts_platform.backend.delivery.team_flags.posthoganalytics.feature_enabled",
- **({"side_effect": live} if isinstance(live, Exception) else {"return_value": live}),
- ),
patch(f"{_MODULE}.announcement", return_value=announced),
patch(f"{_MODULE}.announced_kinds", return_value=kinds or {}),
patch(f"{_MODULE}.list_alert_destination_groups", side_effect=groups),
@@ -219,18 +214,16 @@ class TestDeliverEvaluation(APIBaseTest):
},
),
):
- return deliver_evaluation(
- _request(
- self.team.id,
- sends_messages=sends_messages,
- incident_actions=incident_actions,
- owned_by_platform=owned_by_platform,
- overflowed=overflowed,
- overflow_is_lower_bound=overflow_is_lower_bound,
- parts=parts,
- part=part,
- )
+ request = _request(
+ self.team.id,
+ sends_messages=sends_messages,
+ incident_actions=incident_actions,
+ overflowed=overflowed,
+ overflow_is_lower_bound=overflow_is_lower_bound,
+ parts=parts,
+ part=part,
)
+ return deliver_evaluation(replace(request, source_alert_url=source_alert_url))
def test_a_destination_hears_only_about_the_kinds_it_subscribed_to(self) -> None:
# One group fires while another resolves. A destination that asked for firings must not
@@ -421,7 +414,6 @@ class TestDeliverEvaluation(APIBaseTest):
_announcement(_transition(kind)),
{FIRING_EVENT: hog_function, RESOLVED_EVENT: hog_function, OPENED_EVENT: hog_function},
incident_actions={"": action},
- owned_by_platform=True,
transports={DestinationType.EMAIL: EmailingTransport},
)
@@ -432,18 +424,16 @@ class TestDeliverEvaluation(APIBaseTest):
]
assert [m.incident_action for channel, m in RecordingTransport.sends if channel == "R-1"] == [action]
- @parameterized.expand([("owned_by_the_platform", True, "posthog-alert-legacy-1"), ("live_delivery", False, None)])
- def test_only_an_alert_the_platform_owns_resolves_under_its_source_incident_key(
- self, _name: str, owned_by_platform: bool, expected: str | None
- ) -> None:
+ def test_a_resolve_closes_the_incident_under_its_source_incident_key(self) -> None:
self._run(
_announcement(_transition(AlertEventKind.RESOLVED)),
{CLOSED_EVENT: [_group(PAGERDUTY)]},
incident_actions={"": IncidentAction.RESOLVE},
- owned_by_platform=owned_by_platform,
)
- assert [m.source_incident_key for channel, m in RecordingTransport.sends if channel == "R-1"] == [expected]
+ assert [m.source_incident_key for channel, m in RecordingTransport.sends if channel == "R-1"] == [
+ "posthog-alert-legacy-1"
+ ]
def test_a_destination_with_no_transport_is_skipped_rather_than_failing_the_send(self) -> None:
outcome = self._run(
@@ -484,17 +474,9 @@ class TestDeliverEvaluation(APIBaseTest):
def test_every_message_links_to_the_alert_page_the_request_names_and_to_its_project(self) -> None:
url = "https://app.example.com/project/7/logs/alerts/legacy-1"
- with (
- patch(
- "products.alerts_platform.backend.delivery.team_flags.posthoganalytics.feature_enabled",
- return_value=True,
- ),
- patch(f"{_MODULE}.announcement", return_value=_announcement(_transition(AlertEventKind.FIRING))),
- patch(f"{_MODULE}.list_alert_destination_groups", return_value=[_group(SLACK)]),
- patch(f"{_MODULE}.DatabaseThreadStore"),
- patch.dict(f"{_MODULE}._TRANSPORTS", {DestinationType.SLACK: RecordingTransport}),
- ):
- deliver_evaluation(replace(_request(self.team.id), source_alert_url=url))
+ self._run(
+ _announcement(_transition(AlertEventKind.FIRING)), {FIRING_EVENT: [_group(SLACK)]}, source_alert_url=url
+ )
assert [(m.alert_url, m.project) for _, m in RecordingTransport.sends] == [
(url, MessageLink(label=self.team.name, url=absolute_uri(f"/project/{self.team.id}")))
@@ -531,9 +513,7 @@ class TestDeliverEvaluation(APIBaseTest):
release_action=release,
)
- outcome = self._run(
- _announcement(_transition(AlertEventKind.FIRING)), {FIRING_EVENT: [_group(SLACK)]}, owned_by_platform=True
- )
+ outcome = self._run(_announcement(_transition(AlertEventKind.FIRING)), {FIRING_EVENT: [_group(SLACK)]})
assert outcome.sent == sent
@@ -586,49 +566,17 @@ class TestDeliverEvaluation(APIBaseTest):
_announcement(_transition(AlertEventKind.FIRING, episode_started_at=episode_started_at)),
{FIRING_EVENT: [_group(SLACK)], OPENED_EVENT: [_group(PAGERDUTY)]},
incident_actions={"": IncidentAction.TRIGGER},
- owned_by_platform=True,
)
assert [channel for channel, _ in RecordingTransport.sends if channel == "C-1"] == ["C-1"]
assert [m.incident_action for channel, m in RecordingTransport.sends if channel == "R-1"] == incident
- def test_a_team_without_the_flag_is_not_contacted(self) -> None:
- outcome = self._run(
- _announcement(_transition(AlertEventKind.FIRING)), {FIRING_EVENT: [_group(SLACK)]}, live=False
- )
+ def test_an_alert_its_source_still_owns_is_not_contacted(self) -> None:
+ outcome = deliver_evaluation(_request(self.team.id, owned_by_platform=False))
assert RecordingTransport.sends == []
assert outcome.live is False
- def test_the_flag_is_read_against_the_project(self) -> None:
- # Without the project group the condition never matches, and the platform stays silent
- # with nothing to say why.
- with (
- patch(
- "products.alerts_platform.backend.delivery.team_flags.posthoganalytics.feature_enabled",
- return_value=False,
- ) as flag,
- patch(f"{_MODULE}.announcement", return_value=None),
- ):
- deliver_evaluation(_request(self.team.id))
-
- assert flag.call_args.args[0] == LIVE_DELIVERY_FLAG
- assert flag.call_args.kwargs["groups"]["project"] == str(self.team.id)
- assert flag.call_args.kwargs["group_properties"]["project"]["uuid"] == str(self.team.uuid)
-
- @parameterized.expand([("owned_by_the_source", False), ("owned_by_the_platform", True)])
- def test_a_flag_that_cannot_be_read_silences_only_alerts_the_source_still_delivers(
- self, _name: str, delivers: bool
- ) -> None:
- outcome = self._run(
- _announcement(_transition(AlertEventKind.FIRING)),
- {FIRING_EVENT: [_group(SLACK)]},
- live=RuntimeError("flags unreachable"),
- owned_by_platform=delivers,
- )
-
- assert (outcome.live, len(RecordingTransport.sends)) == (delivers, int(delivers))
-
@parameterized.expand(
[
("keeps_the_legacy_body", True, "1", "legacy"),
@@ -645,8 +593,6 @@ class TestDeliverEvaluation(APIBaseTest):
def flag(key: str, *_args: Any, **_kwargs: Any) -> bool | None:
flag_reads.append(key)
- if key == LIVE_DELIVERY_FLAG:
- return True
if isinstance(keeps_legacy, Exception):
raise keeps_legacy
return keeps_legacy
@@ -662,6 +608,8 @@ class TestDeliverEvaluation(APIBaseTest):
patch(f"{_MODULE}.announcement", return_value=_announcement(_transition(AlertEventKind.FIRING))),
patch(f"{_MODULE}.list_alert_destination_groups", return_value=[_group(WEBHOOK), _group(SECOND_WEBHOOK)]),
patch(f"{_MODULE}.DatabaseThreadStore"),
+ # The path is covered by `TestDeliveryPath`. Without an emitter every alert delivers natively.
+ patch.dict(delivery_paths._emitters, clear=True),
patch.dict(f"{_LEGACY_MODULE}._bodies", {SourceKind.LOGS: legacy_body}),
patch(f"{_WEBHOOK_URL_MODULE}.post_json") as post,
patch(f"{_MODULE}.record_delivery") as recorded,
@@ -747,7 +695,6 @@ class TestDeliveryPath(APIBaseTest):
announced: EvaluationAnnouncement,
chooser: Any,
*,
- owned_by_platform: bool = True,
incident_actions: dict[str, IncidentAction] | None = None,
emitter: Any = None,
groups: list[AlertDestinationGroup] | None = None,
@@ -755,12 +702,6 @@ class TestDeliveryPath(APIBaseTest):
real_thread_store: bool = False,
) -> Any:
with ExitStack() as stack:
- stack.enter_context(
- patch(
- "products.alerts_platform.backend.delivery.team_flags.posthoganalytics.feature_enabled",
- return_value=True,
- )
- )
stack.enter_context(patch(f"{_MODULE}.announcement", return_value=announced))
stack.enter_context(
patch(f"{_MODULE}.list_alert_destination_groups", return_value=groups or [HOG_FUNCTION_SLACK])
@@ -774,7 +715,6 @@ class TestDeliveryPath(APIBaseTest):
_request(
self.team.id,
configuration_id=str(self.configuration.id),
- owned_by_platform=owned_by_platform,
incident_actions=incident_actions,
)
)
@@ -790,21 +730,18 @@ class TestDeliveryPath(APIBaseTest):
# The subscriber group stands in for email and in-app, which are no HogFunction and never see an emitted event.
@parameterized.expand(
[
- ("stock_destinations_send_natively", True, DeliveryPath.NATIVE, 0, ["C-1", "C-2"]),
- ("customized_destinations_emit_for_their_hog_functions", True, DeliveryPath.HOG_FUNCTION, 1, ["C-2"]),
- # The source's own stack still emits these events, so emitting them here would send twice.
- ("an_alert_the_source_owns_never_emits", False, DeliveryPath.HOG_FUNCTION, 0, ["C-1", "C-2"]),
- ("a_chooser_that_fails_emits", True, None, 1, ["C-2"]),
+ ("stock_destinations_send_natively", DeliveryPath.NATIVE, 0, ["C-1", "C-2"]),
+ ("customized_destinations_emit_for_their_hog_functions", DeliveryPath.HOG_FUNCTION, 1, ["C-2"]),
+ ("a_chooser_that_fails_emits", None, 1, ["C-2"]),
]
)
def test_an_alert_delivers_through_the_path_its_destinations_allow(
- self, _name: str, owned_by_platform: bool, path: DeliveryPath | None, emitted: int, native_channels: list[str]
+ self, _name: str, path: DeliveryPath | None, emitted: int, native_channels: list[str]
) -> None:
chooser = self._chooses(path) if path else self._fails
outcome = self._run(
_announcement(_transition(AlertEventKind.FIRING)),
chooser,
- owned_by_platform=owned_by_platform,
groups=[HOG_FUNCTION_SLACK, SUBSCRIBER],
)