: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(workflows): release Slack workflow triggers to all projects (#113470)
Harley Alexanderf87c8708d634
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 58d74d7d4a22..ca4d5ed795e9 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -550,7 +550,6 @@ export const FEATURE_FLAGS = {SIGNUP_AA_TEST_4_WAY: 'signup-aa-test-4-way', // owner: @andehen #team-experiments multivariate=control,test-1,test-2,test-3SIMPLE_SIDEPANEL: 'simple-sidepanel',SLACK_DWH: 'slack-dwh', // owner: @MarconLP #team-warehouse-sources- SLACK_WORKFLOW_TRIGGERS: 'slack-workflow-triggers', // owner: #team-workflows-cdpSQL_EDITOR_BI_MODE: 'sql-editor-bi-mode', // owner: @mariusandra #team-data-toolsSQL_EDITOR_LAZY_SCHEMA: 'sql-editor-lazy-schema', // owner: @mariusandra #team-data-toolsSQL_EDITOR_VIM_MODE: 'sql-editor-vim-mode', // owner: @arthurdedeusdiff --git a/posthog/settings/__init__.py b/posthog/settings/__init__.pyindex 6253c3d42231..b7a2beae0c86 100644--- a/posthog/settings/__init__.py+++ b/posthog/settings/__init__.py@@ -85,13 +85,9 @@ INSTANCE_TAG: str = os.getenv("INSTANCE_TAG", "none")# empty to use the real Slack email while keeping DEBUG on. Ignored outside DEBUG.SLACK_APP_LOCAL_DEV_EMAIL: str = os.getenv("SLACK_APP_LOCAL_DEV_EMAIL", "[email protected]")-# Forward every Slack channel message onto the internal events topic, where a workflow with a Slack-# trigger can pick it up. Off by default: this is the only thing admitting the full channel-# firehose, so it doubles as the kill switch.-SLACK_WORKFLOW_TRIGGERS_ENABLED: bool = get_from_env("SLACK_WORKFLOW_TRIGGERS_ENABLED", False, type_cast=str_to_bool)--# Same for GitHub App deliveries. Off by default for the same reason: a busy repository is a-# firehose, and this is the only thing admitting it.+# Forward GitHub App deliveries onto the internal events topic, where a workflow with a GitHub+# trigger can pick them up. Off by default: a busy repository is a firehose, and this is the only+# thing admitting it.GITHUB_WORKFLOW_TRIGGERS_ENABLED: bool = get_from_env("GITHUB_WORKFLOW_TRIGGERS_ENABLED", False, type_cast=str_to_bool)if DEBUG:diff --git a/products/slack_app/backend/slack_workflow_events.py b/products/slack_app/backend/slack_workflow_events.pyindex da9c76862bcf..fefff6290f9d 100644--- a/products/slack_app/backend/slack_workflow_events.py+++ b/products/slack_app/backend/slack_workflow_events.py@@ -8,8 +8,6 @@ wants, and the CDP consumer evaluates that, so nothing here needs to know a trigimport uuidfrom typing import Any-from django.conf import settings-import structlogfrom posthog.cdp.internal_events import InternalEventEvent, produce_internal_event@@ -64,7 +62,7 @@ def is_triggering_message(event: dict[str, Any]) -> bool:Exposed so the webhook can decide about a cross-region mirror without spending a probe or ahop on the subtypes (edits, joins, deletions) no trigger fires on."""- return bool(settings.SLACK_WORKFLOW_TRIGGERS_ENABLED) and event.get("subtype") in _TRIGGERING_SUBTYPES+ return event.get("subtype") in _TRIGGERING_SUBTYPESdef emit_slack_message_event(diff --git a/products/slack_app/backend/tests/test_slack_workflow_events.py b/products/slack_app/backend/tests/test_slack_workflow_events.pyindex b5d0929327d6..c8df98b8dad1 100644--- a/products/slack_app/backend/tests/test_slack_workflow_events.py+++ b/products/slack_app/backend/tests/test_slack_workflow_events.py@@ -25,14 +25,6 @@ def produce():yield mock[email protected]("enabled", [True, False])-def test_setting_gates_the_emit(produce, workspace_integration, enabled) -> None:- with patch("django.conf.settings.SLACK_WORKFLOW_TRIGGERS_ENABLED", enabled):- emit_slack_message_event(MESSAGE_EVENT, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=False)-- assert produce.call_count == (1 if enabled else 0)--def test_emits_once_per_connected_project(produce, org_team_user, workspace_integration) -> None:org, first_team, _ = org_team_usersecond_team = Team.objects.create(organization=org, name="Second")@@ -43,8 +35,7 @@ def test_emits_once_per_connected_project(produce, org_team_user, workspace_intesensitive_config={"access_token": "xoxb-test"},)- with patch("django.conf.settings.SLACK_WORKFLOW_TRIGGERS_ENABLED", True):- emit_slack_message_event(MESSAGE_EVENT, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=False)+ emit_slack_message_event(MESSAGE_EVENT, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=False)assert {call.args[0] for call in produce.call_args_list} == {first_team.pk, second_team.pk}# Same Slack event, different projects: the uuids have to differ or the second project's run@@ -72,15 +63,13 @@ def test_emits_once_per_connected_project(produce, org_team_user, workspace_intedef test_only_a_new_post_is_emitted(produce, workspace_integration, subtype, emitted) -> None:event = MESSAGE_EVENT if subtype is None else {**MESSAGE_EVENT, "subtype": subtype}- with patch("django.conf.settings.SLACK_WORKFLOW_TRIGGERS_ENABLED", True):- emit_slack_message_event(event, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=False)+ emit_slack_message_event(event, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=False)assert produce.call_count == (1 if emitted else 0)def test_emits_nothing_for_an_unconnected_workspace(produce, workspace_integration) -> None:- with patch("django.conf.settings.SLACK_WORKFLOW_TRIGGERS_ENABLED", True):- emit_slack_message_event(MESSAGE_EVENT, "T-OTHER-REGION", event_id="Ev1", is_ext_shared_channel=False)+ emit_slack_message_event(MESSAGE_EVENT, "T-OTHER-REGION", event_id="Ev1", is_ext_shared_channel=False)produce.assert_not_called()@@ -88,8 +77,7 @@ def test_emits_nothing_for_an_unconnected_workspace(produce, workspace_integratidef test_properties_carry_what_a_filter_needs(produce, workspace_integration) -> None:event = {**MESSAGE_EVENT, "thread_ts": "1699999999.000000", "bot_id": "B42"}- with patch("django.conf.settings.SLACK_WORKFLOW_TRIGGERS_ENABLED", True):- emit_slack_message_event(event, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=True)+ emit_slack_message_event(event, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=True)properties = produce.call_args.args[1].propertiesassert properties["channel"] == "C0ALERTS"@@ -102,8 +90,7 @@ def test_properties_carry_what_a_filter_needs(produce, workspace_integration) ->def test_a_top_level_post_is_not_a_thread_reply(produce, workspace_integration) -> None:event = {**MESSAGE_EVENT, "thread_ts": MESSAGE_EVENT["ts"]}- with patch("django.conf.settings.SLACK_WORKFLOW_TRIGGERS_ENABLED", True):- emit_slack_message_event(event, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=False)+ emit_slack_message_event(event, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=False)assert produce.call_args.args[1].properties["is_thread_reply"] is False@@ -111,5 +98,4 @@ def test_a_top_level_post_is_not_a_thread_reply(produce, workspace_integration)def test_a_kafka_failure_does_not_reach_the_webhook(produce, workspace_integration) -> None:produce.side_effect = RuntimeError("kafka is down")- with patch("django.conf.settings.SLACK_WORKFLOW_TRIGGERS_ENABLED", True):- emit_slack_message_event(MESSAGE_EVENT, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=False)+ emit_slack_message_event(MESSAGE_EVENT, SLACK_TEAM_ID, event_id="Ev1", is_ext_shared_channel=False)diff --git a/products/slack_app/backend/tests/test_thread_message_routing.py b/products/slack_app/backend/tests/test_thread_message_routing.pyindex 332425cb61f7..e62bd29ec3f3 100644--- a/products/slack_app/backend/tests/test_thread_message_routing.py+++ b/products/slack_app/backend/tests/test_thread_message_routing.py@@ -185,7 +185,6 @@ class TestRouteThreadMessage(TestCase):("an edit, owned here", "T_SLACK", "message_changed", False, False),])- @override_settings(SLACK_WORKFLOW_TRIGGERS_ENABLED=True)def test_top_level_post_reaches_every_region_holding_the_workspace(self, _name, slack_team_id, subtype, expect_full_proxy, expect_mirror_dispatch):@@ -219,7 +218,6 @@ class TestRouteThreadMessage(TestCase):assert kwargs["headers"][REGION_PROXY_HEADER] == "1"assert "eu.posthog.com" in kwargs["target_url"]- @override_settings(SLACK_WORKFLOW_TRIGGERS_ENABLED=True)def test_emit_only_mirror_emits_for_local_projects_and_nothing_else(self):from products.slack_app.backend.api import (EMIT_ONLY_MIRROR_HEADER,@@ -248,7 +246,6 @@ class TestRouteThreadMessage(TestCase):mock_proxy.assert_not_called()mock_start.assert_not_called()- @override_settings(SLACK_WORKFLOW_TRIGGERS_ENABLED=True)def test_owned_thread_stays_local_without_an_emit_only_mirror(self):from products.slack_app.backend.api import ROUTE_HANDLED_LOCALLY, route_posthog_code_event_to_relevant_regiondiff --git a/products/workflows/frontend/Workflows/hogflows/registry/triggers/slack.test.ts b/products/workflows/frontend/Workflows/hogflows/registry/triggers/slack.test.tsindex da224dba0274..459e844e5840 100644--- a/products/workflows/frontend/Workflows/hogflows/registry/triggers/slack.test.ts+++ b/products/workflows/frontend/Workflows/hogflows/registry/triggers/slack.test.ts@@ -118,10 +118,6 @@ describe('slack message trigger', () => {expect(getTriggerType().validate!({ type: 'event', filters: {} } as any)).toBeNull()})- it('is gated behind the slack-workflow-triggers feature flag', () => {- expect(getTriggerType().featureFlag).toBe('slack-workflow-triggers')- })-it('does not claim an internal-event config for a different event', () => {// The tile is one of several that can own an `internal-event` config, so it identifies// itself by its own value. Naming it after the config type made it match every internaldiff --git a/products/workflows/frontend/Workflows/hogflows/registry/triggers/slack.tsx b/products/workflows/frontend/Workflows/hogflows/registry/triggers/slack.tsxindex 9ddf2a42ea61..202f54f96938 100644--- a/products/workflows/frontend/Workflows/hogflows/registry/triggers/slack.tsx+++ b/products/workflows/frontend/Workflows/hogflows/registry/triggers/slack.tsx@@ -185,7 +185,6 @@ registerTriggerType({icon: <IconSlack />,description: 'Trigger when someone posts in a Slack channel',group: 'Slack',- featureFlag: 'slack-workflow-triggers',matchConfig: (config) => isSlackMessageTriggerConfig(config),buildConfig: () => ({type: 'internal-event',