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(slack-app): use slack integration kind for coding-agent mentions (#59354)

Vojta Bartošc61131d103dd
diff --git a/posthog/temporal/ai/posthog_code_slack_interactivity.py b/posthog/temporal/ai/posthog_code_slack_interactivity.py
index 0ee783c2db50..86b5594b02bc 100644
--- a/posthog/temporal/ai/posthog_code_slack_interactivity.py
+++ b/posthog/temporal/ai/posthog_code_slack_interactivity.py
@@ -95,9 +95,7 @@ def process_posthog_code_task_termination_payload(payload: dict[str, Any]) -> No
return
try:
- integration = Integration.objects.get(
- id=integration_id, kind="slack-posthog-code", integration_id=slack_team_id
- )
+ integration = Integration.objects.get(id=integration_id, kind="slack", integration_id=slack_team_id)
except Integration.DoesNotExist:
logger.warning("posthog_code_terminate_integration_not_found", integration_id=integration_id)
return
diff --git a/posthog/temporal/ai/posthog_code_slack_mention.py b/posthog/temporal/ai/posthog_code_slack_mention.py
index 1fb04a4d9a04..b09a0956ea11 100644
--- a/posthog/temporal/ai/posthog_code_slack_mention.py
+++ b/posthog/temporal/ai/posthog_code_slack_mention.py
@@ -360,7 +360,7 @@ def resolve_posthog_code_slack_user_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
@@ -386,7 +386,7 @@ def handle_posthog_code_rules_command_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
@@ -652,7 +652,7 @@ def collect_posthog_code_thread_messages_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
@@ -675,7 +675,7 @@ def select_posthog_code_repository_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
all_repos = _get_full_repo_names(integration)
@@ -713,7 +713,7 @@ def post_posthog_code_no_repos_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
@@ -744,7 +744,7 @@ def post_posthog_code_repo_picker_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
@@ -788,7 +788,7 @@ def create_posthog_code_task_for_repo_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
@@ -914,7 +914,7 @@ def create_posthog_code_routing_rule_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
@@ -994,7 +994,7 @@ def forward_posthog_code_followup_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
@@ -1437,7 +1437,7 @@ def post_posthog_code_picker_timeout_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
@@ -1467,7 +1467,7 @@ def post_posthog_code_internal_error_activity(
integration = Integration.objects.select_related("team", "team__organization").get(
id=inputs.integration_id,
- kind="slack-posthog-code",
+ kind="slack",
integration_id=inputs.slack_team_id,
)
slack = SlackIntegration(integration)
diff --git a/products/slack_app/backend/api.py b/products/slack_app/backend/api.py
index fcae6d07b02b..6e8a04d8213a 100644
--- a/products/slack_app/backend/api.py
+++ b/products/slack_app/backend/api.py
@@ -781,9 +781,7 @@ def _replace_repo_picker_message_with_selection(
) -> None:
try:
# nosemgrep: idor-lookup-without-team — Slack webhook: no team context; scoped by PK + kind + Slack team ID
- integration = Integration.objects.get(
- id=integration_id, kind="slack-posthog-code", integration_id=slack_team_id
- )
+ integration = Integration.objects.get(id=integration_id, kind="slack", integration_id=slack_team_id)
slack = SlackIntegration(integration)
text = f"Repository selected: `{selected_repo}`"
slack.client.chat_update(
@@ -815,9 +813,7 @@ def _replace_repo_picker_message_with_no_repo(
) -> None:
try:
# nosemgrep: idor-lookup-without-team — Slack webhook: no team context; scoped by PK + kind + Slack team ID
- integration = Integration.objects.get(
- id=integration_id, kind="slack-posthog-code", integration_id=slack_team_id
- )
+ integration = Integration.objects.get(id=integration_id, kind="slack", integration_id=slack_team_id)
slack = SlackIntegration(integration)
text = "Continuing without a repository."
slack.client.chat_update(
@@ -1149,34 +1145,25 @@ def route_posthog_code_event_to_relevant_region(
slack_team_id: str,
event_id: str | None = None,
) -> str:
- # One webhook endpoint serves both the notifications integration (kind="slack") and the
- # coding-agent integration (kind="slack-posthog-code"). What counts as a "local match" has
- # to depend on event type: app_mention needs the coding-agent integration specifically,
- # while link_shared (unfurl) works with either kind. Without this, a region that has only a
- # notifications install for a workspace would silently swallow mentions instead of
- # proxying to the region that holds the coding-agent install.
- integrations = list(
+ # The webhook serves the regular slack integration; app_mention activation is gated
+ # by the posthog-code-slack-availability feature flag rather than a separate kind.
+ local_match = (
Integration.objects.filter(
- kind__in=["slack", "slack-posthog-code"],
+ kind="slack",
integration_id=slack_team_id,
)
.select_related("team", "team__organization", "created_by")
.order_by("id")
+ .first()
)
- coding_agent_integration = next((i for i in integrations if i.kind == "slack-posthog-code"), None)
- any_integration = integrations[0] if integrations else None
event_type = event.get("type")
- if event_type == "app_mention":
- local_match = coding_agent_integration
- else:
- local_match = any_integration
if local_match and not (settings.DEBUG and request.get_host() == SLACK_PRIMARY_REGION_DOMAIN):
if event_type == "app_mention":
if not _posthog_code_enabled_for_integration(local_match):
logger.info(
- "posthog_code_event_flag_off",
+ "slack_app_mention_flag_disabled",
slack_team_id=slack_team_id,
organization_id=str(local_match.team.organization_id),
)
@@ -1208,7 +1195,7 @@ def route_posthog_code_event_to_relevant_region(
success = proxy_slack_event_to_secondary_region(request)
return ROUTE_PROXIED if success else ROUTE_PROXY_FAILED
else:
- logger.warning("posthog_code_no_integration_found", slack_team_id=slack_team_id)
+ logger.warning("slack_app_integration_not_found", slack_team_id=slack_team_id)
return ROUTE_NO_INTEGRATION
@@ -1249,15 +1236,15 @@ def posthog_code_event_handler(request: HttpRequest) -> HttpResponse:
return HttpResponse(status=405)
try:
- posthog_code_config = SlackIntegration.posthog_code_slack_config()
- validate_slack_request(request, posthog_code_config["SLACK_POSTHOG_CODE_SIGNING_SECRET"])
+ slack_config = SlackIntegration.slack_config()
+ validate_slack_request(request, slack_config["SLACK_APP_SIGNING_SECRET"])
except SlackIntegrationError as e:
- logger.warning("posthog_code_event_invalid_request", error=str(e))
+ logger.warning("slack_event_invalid_request", error=str(e))
return HttpResponse("Invalid request", status=403)
retry_num = request.headers.get("X-Slack-Retry-Num")
if retry_num:
- logger.info("posthog_code_event_retry", retry_num=retry_num)
+ logger.info("slack_event_retry", retry_num=retry_num)
return HttpResponse(status=200)
try:
@@ -1386,7 +1373,7 @@ def _handle_repo_picker_options(payload: dict) -> JsonResponse:
team_id = payload.get("team", {}).get("id")
if team_id:
fallback_integration = (
- Integration.objects.filter(kind="slack-posthog-code", integration_id=team_id).order_by("id").first()
+ Integration.objects.filter(kind="slack", integration_id=team_id).order_by("id").first()
)
if fallback_integration:
hinted_integration_id = fallback_integration.id
@@ -1420,9 +1407,7 @@ def _handle_repo_picker_options(payload: dict) -> JsonResponse:
if not integration_id:
raise Integration.DoesNotExist
# nosemgrep: idor-lookup-without-team — Slack webhook: no team context; scoped by PK + kind + Slack team ID
- integration = Integration.objects.get(
- id=integration_id, kind="slack-posthog-code", integration_id=slack_team_id
- )
+ integration = Integration.objects.get(id=integration_id, kind="slack", integration_id=slack_team_id)
except Integration.DoesNotExist:
logger.info("posthog_code_repo_picker_options_no_integration", context_token=context_token)
return JsonResponse({"options": []})
@@ -1499,9 +1484,7 @@ def _handle_repo_picker_submit(payload: dict) -> HttpResponse:
try:
# nosemgrep: idor-lookup-without-team — Slack webhook: no team context; scoped by PK + kind + Slack team ID
- integration = Integration.objects.get(
- id=integration_id, kind="slack-posthog-code", integration_id=slack_team_id
- )
+ integration = Integration.objects.get(id=integration_id, kind="slack", integration_id=slack_team_id)
SlackIntegration(integration).client.chat_postMessage(
channel=channel,
thread_ts=thread_ts,
@@ -1639,10 +1622,10 @@ def posthog_code_interactivity_handler(request: HttpRequest) -> HttpResponse:
return HttpResponse(status=405)
try:
- posthog_code_config = SlackIntegration.posthog_code_slack_config()
- validate_slack_request(request, posthog_code_config["SLACK_POSTHOG_CODE_SIGNING_SECRET"])
+ slack_config = SlackIntegration.slack_config()
+ validate_slack_request(request, slack_config["SLACK_APP_SIGNING_SECRET"])
except SlackIntegrationError as e:
- logger.warning("posthog_code_interactivity_invalid_request", error=str(e))
+ logger.warning("slack_interactivity_invalid_request", error=str(e))
return HttpResponse("Invalid request", status=403)
try:
@@ -1672,19 +1655,19 @@ def posthog_code_interactivity_handler(request: HttpRequest) -> HttpResponse:
if slack_team_id and ctx_integration_id:
local = Integration.objects.filter( # nosemgrep: idor-lookup-without-team
id=ctx_integration_id, # nosemgrep: idor-taint-user-input-to-model-get
- kind="slack-posthog-code",
+ kind="slack",
integration_id=slack_team_id,
).exists()
elif slack_team_id and hinted_integration_id and hinted_user_id and requesting_user == hinted_user_id:
local = Integration.objects.filter( # nosemgrep: idor-lookup-without-team
id=hinted_integration_id, # nosemgrep: idor-taint-user-input-to-model-get
- kind="slack-posthog-code",
+ kind="slack",
integration_id=slack_team_id,
).exists()
elif slack_team_id and terminate_integration_id and (not terminate_user_id or requesting_user == terminate_user_id):
local = Integration.objects.filter( # nosemgrep: idor-lookup-without-team
id=terminate_integration_id, # nosemgrep: idor-taint-user-input-to-model-get
- kind="slack-posthog-code",
+ kind="slack",
integration_id=slack_team_id,
).exists()
diff --git a/products/slack_app/backend/tests/test_collect_thread_messages.py b/products/slack_app/backend/tests/test_collect_thread_messages.py
index 704592b86017..c884eac270da 100644
--- a/products/slack_app/backend/tests/test_collect_thread_messages.py
+++ b/products/slack_app/backend/tests/test_collect_thread_messages.py
@@ -169,7 +169,7 @@ class TestCollectThreadMessages:
self.team = Team.objects.create(organization=self.organization, name="Test Team")
self.integration = Integration.objects.create(
team=self.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T12345",
sensitive_config={"access_token": "xoxb-test"},
)
diff --git a/products/slack_app/backend/tests/test_followup_forwarding.py b/products/slack_app/backend/tests/test_followup_forwarding.py
index 37731c22069e..dda4d32a7455 100644
--- a/products/slack_app/backend/tests/test_followup_forwarding.py
+++ b/products/slack_app/backend/tests/test_followup_forwarding.py
@@ -40,9 +40,7 @@ class TestSlackThreadTaskMapping(TestCase):
self.org = Organization.objects.create(name="TestOrg")
self.team = Team.objects.create(organization=self.org, name="TestTeam")
self.user = User.objects.create(email="[email protected]")
- self.integration = Integration.objects.create(
- team=self.team, kind="slack-posthog-code", integration_id="T_SLACK", config={}
- )
+ self.integration = Integration.objects.create(team=self.team, kind="slack", integration_id="T_SLACK", config={})
self.task = self.Task.objects.create(
team=self.team,
title="Test task",
@@ -138,9 +136,7 @@ class TestCreatePostHogCodeTaskForRepoActivity(TestCase):
self.org = Organization.objects.create(name="TestOrg")
self.team = Team.objects.create(organization=self.org, name="TestTeam")
self.user = User.objects.create(email="[email protected]", distinct_id="user-1")
- self.integration = Integration.objects.create(
- team=self.team, kind="slack-posthog-code", integration_id="T_SLACK", config={}
- )
+ self.integration = Integration.objects.create(team=self.team, kind="slack", integration_id="T_SLACK", config={})
@patch("products.tasks.backend.temporal.client.execute_task_processing_workflow")
@patch("posthog.models.integration.SlackIntegration")
@@ -409,9 +405,7 @@ class TestForwardPostHogCodeFollowupActivity(TestCase):
self.org = Organization.objects.create(name="TestOrg")
self.team = Team.objects.create(organization=self.org, name="TestTeam")
self.user = User.objects.create(email="[email protected]")
- self.integration = Integration.objects.create(
- team=self.team, kind="slack-posthog-code", integration_id="T_SLACK", config={}
- )
+ self.integration = Integration.objects.create(team=self.team, kind="slack", integration_id="T_SLACK", config={})
self.task = self.Task.objects.create(
team=self.team,
title="Test task",
diff --git a/products/slack_app/backend/tests/test_guess_repository.py b/products/slack_app/backend/tests/test_guess_repository.py
index 45f3125090f4..c17f6ed4cfa4 100644
--- a/products/slack_app/backend/tests/test_guess_repository.py
+++ b/products/slack_app/backend/tests/test_guess_repository.py
@@ -40,7 +40,7 @@ class TestGetFullRepoNames:
self.slack_integration = Integration.objects.create(
team=self.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T12345",
sensitive_config={"access_token": "xoxb-test"},
)
@@ -163,7 +163,7 @@ class TestGetFullRepoNamesCache:
self.team = Team.objects.create(organization=self.organization, name="Cache Team")
self.slack_integration = Integration.objects.create(
team=self.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T_CACHE",
sensitive_config={"access_token": "xoxb-cache"},
)
@@ -206,7 +206,7 @@ class TestGetFullRepoNamesCache:
team_b = Team.objects.create(organization=org_b, name="Other Team")
slack_b = Integration.objects.create(
team=team_b,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T_OTHER",
sensitive_config={"access_token": "xoxb-other"},
)
@@ -323,7 +323,7 @@ class TestPostRepoPickerPrewarm:
self.team = Team.objects.create(organization=self.organization, name="Prewarm Team")
self.slack_integration = Integration.objects.create(
team=self.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T_PREWARM",
sensitive_config={"access_token": "xoxb-prewarm"},
)
@@ -390,7 +390,7 @@ class TestSelectRepository:
self.slack_integration = Integration.objects.create(
team=self.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T12345",
sensitive_config={"access_token": "xoxb-test"},
)
@@ -748,7 +748,7 @@ class TestHandleRulesCommandActivity:
self.integration = Integration.objects.create(
team=self.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T12345",
sensitive_config={"access_token": "xoxb-test"},
)
diff --git a/products/slack_app/backend/tests/test_posthog_code_event_handler.py b/products/slack_app/backend/tests/test_posthog_code_event_handler.py
index fa03bc212afd..e3e1250c2c32 100644
--- a/products/slack_app/backend/tests/test_posthog_code_event_handler.py
+++ b/products/slack_app/backend/tests/test_posthog_code_event_handler.py
@@ -34,22 +34,22 @@ class TestPostHogCodeEventHandler(TestCase):
**extra_headers,
)
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_url_verification(self, mock_config):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
response = self._post_event({"type": "url_verification", "challenge": "test-challenge-123"})
assert response.status_code == 200
assert response.json() == {"challenge": "test-challenge-123"}
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_invalid_signature(self, mock_config):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": "different-secret"}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": "different-secret"}
response = self._post_event({"type": "url_verification", "challenge": "test"})
assert response.status_code == 403
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_retry_returns_200(self, mock_config):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
body = json.dumps({"type": "event_callback", "event": {"type": "app_mention"}}).encode()
signature, ts = sign_slack_request(body, self.signing_secret)
response = self.client.post(
@@ -73,7 +73,7 @@ class TestPostHogCodeEventHandler(TestCase):
]
)
@patch("products.slack_app.backend.api.route_posthog_code_event_to_relevant_region")
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_event_callback_dispatch(
self,
_name,
@@ -84,7 +84,7 @@ class TestPostHogCodeEventHandler(TestCase):
mock_config,
mock_route,
):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
mock_route.return_value = route_result
payload = {
"type": "event_callback",
@@ -107,7 +107,7 @@ class TestRoutePostHogCodeEventToRelevantRegion(TestCase):
self.team = Team.objects.create(organization=self.organization, name="Test Team")
self.posthog_code_integration = Integration.objects.create(
team=self.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T12345",
sensitive_config={"access_token": "xoxb-posthog-code-test"},
)
@@ -238,21 +238,6 @@ class TestRoutePostHogCodeEventToRelevantRegion(TestCase):
else:
assert pending_picker is None
- @patch("products.slack_app.backend.api._posthog_code_enabled_for_integration", return_value=False)
- @patch("products.slack_app.backend.api.asyncio.run")
- @patch("products.slack_app.backend.api.sync_connect")
- @override_settings(DEBUG=False)
- def test_local_match_flag_off_skips_workflow(self, mock_sync_connect, mock_asyncio_run, _mock_flag):
- request = self.factory.post("/slack/event-callback/", HTTP_HOST="eu.posthog.com")
-
- from products.slack_app.backend.api import ROUTE_HANDLED_LOCALLY, route_posthog_code_event_to_relevant_region
-
- result = route_posthog_code_event_to_relevant_region(request, self.event, "T12345")
-
- assert result == ROUTE_HANDLED_LOCALLY
- mock_sync_connect.assert_not_called()
- mock_asyncio_run.assert_not_called()
-
@patch("products.slack_app.backend.api.handle_posthog_link_unfurl")
@override_settings(DEBUG=False)
def test_link_shared_routes_to_unfurl(self, mock_unfurl):
@@ -268,83 +253,6 @@ class TestRoutePostHogCodeEventToRelevantRegion(TestCase):
passed_integration = mock_unfurl.call_args[0][1]
assert passed_integration.id == self.posthog_code_integration.id
- @patch("products.slack_app.backend.api.handle_posthog_link_unfurl")
- @override_settings(DEBUG=False)
- def test_link_shared_works_with_only_notifications_integration(self, mock_unfurl):
- # Delete the coding-agent integration and create a notifications-only integration for same workspace
- self.posthog_code_integration.delete()
- Integration.objects.create(
- team=self.team,
- kind="slack",
- integration_id="T12345",
- sensitive_config={"access_token": "xoxb-notifications"},
- )
- request = self.factory.post("/slack/event-callback/", HTTP_HOST="eu.posthog.com")
- link_shared_event = {"type": "link_shared", "channel": "C001", "links": []}
-
- from products.slack_app.backend.api import ROUTE_HANDLED_LOCALLY, route_posthog_code_event_to_relevant_region
-
- result = route_posthog_code_event_to_relevant_region(request, link_shared_event, "T12345")
-
- assert result == ROUTE_HANDLED_LOCALLY
- mock_unfurl.assert_called_once()
- # Don't assert on which integration row was passed: "first row by id" picking is a known
- # limitation for multi-team workspaces and shouldn't be baked into the test contract.
- passed_integration = mock_unfurl.call_args[0][1]
- assert passed_integration.integration_id == "T12345"
-
- @patch("products.slack_app.backend.api.asyncio.run")
- @patch("products.slack_app.backend.api.sync_connect")
- @patch("products.slack_app.backend.api.proxy_slack_event_to_secondary_region")
- @patch("products.slack_app.backend.api.SLACK_PRIMARY_REGION_DOMAIN", "eu.posthog.com")
- @override_settings(DEBUG=False)
- def test_app_mention_in_primary_with_only_notifications_proxies_to_secondary(
- self, mock_proxy, mock_sync_connect, mock_asyncio_run
- ):
- # Regression test: the coding-agent install may live in the other region. A notifications-only
- # row in the primary region must NOT short-circuit the proxy path for app_mention.
- self.posthog_code_integration.delete()
- Integration.objects.create(
- team=self.team,
- kind="slack",
- integration_id="T12345",
- sensitive_config={"access_token": "xoxb-notifications"},
- )
- mock_proxy.return_value = True
- request = self.factory.post("/slack/event-callback/", HTTP_HOST="eu.posthog.com")
-
- from products.slack_app.backend.api import ROUTE_PROXIED, route_posthog_code_event_to_relevant_region
-
- result = route_posthog_code_event_to_relevant_region(request, self.event, "T12345")
-
- assert result == ROUTE_PROXIED
- mock_proxy.assert_called_once_with(request)
- mock_sync_connect.assert_not_called()
- mock_asyncio_run.assert_not_called()
-
- @patch("products.slack_app.backend.api.asyncio.run")
- @patch("products.slack_app.backend.api.sync_connect")
- @override_settings(DEBUG=False)
- def test_app_mention_in_secondary_with_only_notifications_noop(self, mock_sync_connect, mock_asyncio_run):
- # In the secondary region with only a notifications install, app_mention should
- # report no_integration (no coding-agent install anywhere reachable from here).
- self.posthog_code_integration.delete()
- Integration.objects.create(
- team=self.team,
- kind="slack",
- integration_id="T12345",
- sensitive_config={"access_token": "xoxb-notifications"},
- )
- request = self.factory.post("/slack/event-callback/", HTTP_HOST="us.posthog.com")
-
- from products.slack_app.backend.api import ROUTE_NO_INTEGRATION, route_posthog_code_event_to_relevant_region
-
- result = route_posthog_code_event_to_relevant_region(request, self.event, "T12345")
-
- assert result == ROUTE_NO_INTEGRATION
- mock_sync_connect.assert_not_called()
- mock_asyncio_run.assert_not_called()
-
@patch("products.slack_app.backend.api.proxy_slack_event_to_secondary_region")
@patch("products.slack_app.backend.api.SLACK_PRIMARY_REGION_DOMAIN", "eu.posthog.com")
@override_settings(DEBUG=False)
diff --git a/products/slack_app/backend/tests/test_posthog_code_interactivity.py b/products/slack_app/backend/tests/test_posthog_code_interactivity.py
index da119f043061..438821a835c7 100644
--- a/products/slack_app/backend/tests/test_posthog_code_interactivity.py
+++ b/products/slack_app/backend/tests/test_posthog_code_interactivity.py
@@ -41,9 +41,9 @@ class TestPostHogCodeInteractivityHandler(TestCase):
response = self.client.get("/slack/interactivity-callback/")
assert response.status_code == 405
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_invalid_signature_returns_403(self, mock_config):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": "different-secret"}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": "different-secret"}
response = self._post_interactivity({"type": "block_suggestion"})
assert response.status_code == 403
@@ -60,7 +60,7 @@ class TestRepoPickerOptions(TestCase):
OrganizationMembership.objects.create(user=self.user, organization=self.organization)
self.posthog_code_integration = Integration.objects.create(
team=self.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T12345",
sensitive_config={"access_token": "xoxb-posthog-code-test"},
)
@@ -96,9 +96,9 @@ class TestRepoPickerOptions(TestCase):
)
@patch("products.slack_app.backend.api._get_full_repo_names")
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_options_returns_filtered_repos(self, mock_config, mock_get_repos):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
mock_get_repos.return_value = ["posthog/posthog", "posthog/posthog-js", "posthog/hogvm"]
payload = {
@@ -115,9 +115,9 @@ class TestRepoPickerOptions(TestCase):
assert options[0]["value"] == "posthog/posthog-js"
@patch("products.slack_app.backend.api._get_full_repo_names")
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_options_empty_query_returns_all(self, mock_config, mock_get_repos):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
mock_get_repos.return_value = ["posthog/posthog", "posthog/posthog-js"]
payload = {
@@ -131,9 +131,9 @@ class TestRepoPickerOptions(TestCase):
assert response.status_code == 200
assert len(response.json()["options"]) == 2
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_options_wrong_user_returns_empty(self, mock_config):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
payload = {
"type": "block_suggestion",
@@ -146,9 +146,9 @@ class TestRepoPickerOptions(TestCase):
assert response.status_code == 200
assert response.json()["options"] == []
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_options_expired_token_returns_empty(self, mock_config):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
cache.delete(f"posthog_code_repo_picker_ctx:{self.context_token}")
payload = {
@@ -165,11 +165,11 @@ class TestRepoPickerOptions(TestCase):
@patch("posthog.models.integration.WebClient")
@patch("products.slack_app.backend.api.asyncio.run")
@patch("products.slack_app.backend.api.sync_connect")
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_submit_signals_temporal_workflow(
self, mock_config, mock_sync_connect, mock_asyncio_run, mock_webclient_class
):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
mock_webclient_class.return_value = MagicMock()
self.context_payload["workflow_id"] = "posthog-code-mention-T12345:C001:1234.5678"
cache.set(f"posthog_code_repo_picker_ctx:{self.context_token}", self.context_payload, timeout=900)
@@ -199,11 +199,11 @@ class TestRepoPickerOptions(TestCase):
@patch("posthog.models.integration.WebClient")
@patch("products.slack_app.backend.api.asyncio.run")
@patch("products.slack_app.backend.api.sync_connect")
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_no_repo_button_signals_temporal_workflow(
self, mock_config, mock_sync_connect, mock_asyncio_run, mock_webclient_class
):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
mock_webclient_class.return_value = MagicMock()
self.context_payload["workflow_id"] = "posthog-code-mention-T12345:C001:1234.5678"
cache.set(f"posthog_code_repo_picker_ctx:{self.context_token}", self.context_payload, timeout=900)
@@ -233,9 +233,9 @@ class TestRepoPickerOptions(TestCase):
assert "without a repository" in update_call["text"].lower()
@patch("posthog.models.integration.WebClient")
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_submit_without_workflow_id_posts_expired(self, mock_config, mock_webclient_class):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
mock_client = MagicMock()
mock_webclient_class.return_value = mock_client
self.context_payload.pop("workflow_id", None)
@@ -263,7 +263,7 @@ class TestRepoPickerOptions(TestCase):
@patch("posthog.models.integration.WebClient")
@patch("products.slack_app.backend.api.asyncio.run")
@patch("products.slack_app.backend.api.sync_connect")
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_submit_signal_failure_posts_expired(
self,
mock_config,
@@ -271,7 +271,7 @@ class TestRepoPickerOptions(TestCase):
mock_asyncio_run,
mock_webclient_class,
):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
mock_client = MagicMock()
mock_webclient_class.return_value = mock_client
self.context_payload["workflow_id"] = "posthog-code-mention-T12345:C001:1234.5678"
@@ -300,9 +300,9 @@ class TestRepoPickerOptions(TestCase):
@patch("products.slack_app.backend.api.asyncio.run")
@patch("products.slack_app.backend.api.sync_connect")
- @patch("products.slack_app.backend.api.SlackIntegration.posthog_code_slack_config")
+ @patch("products.slack_app.backend.api.SlackIntegration.slack_config")
def test_terminate_action_starts_temporal_workflow(self, mock_config, mock_sync_connect, mock_asyncio_run):
- mock_config.return_value = {"SLACK_POSTHOG_CODE_SIGNING_SECRET": self.signing_secret}
+ mock_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}
payload = {
"type": "block_actions",
diff --git a/products/slack_app/backend/tests/test_resolve_slack_user.py b/products/slack_app/backend/tests/test_resolve_slack_user.py
index d9ba47b06c0f..e726c3611926 100644
--- a/products/slack_app/backend/tests/test_resolve_slack_user.py
+++ b/products/slack_app/backend/tests/test_resolve_slack_user.py
@@ -23,7 +23,7 @@ class TestResolveSlackUser:
self.integration = Integration.objects.create(
team=self.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T12345",
sensitive_config={"access_token": "xoxb-test"},
)
diff --git a/products/slack_app/backend/tests/test_terminate.py b/products/slack_app/backend/tests/test_terminate.py
index a69ddcb0df9a..80075894c5fa 100644
--- a/products/slack_app/backend/tests/test_terminate.py
+++ b/products/slack_app/backend/tests/test_terminate.py
@@ -27,9 +27,7 @@ class TestProcessPostHogCodeTaskTermination(TestCase):
self.org = Organization.objects.create(name="TestOrg")
self.team = Team.objects.create(organization=self.org, name="TestTeam")
self.user = User.objects.create(email="[email protected]")
- self.integration = Integration.objects.create(
- team=self.team, kind="slack-posthog-code", integration_id="T_SLACK", config={}
- )
+ self.integration = Integration.objects.create(team=self.team, kind="slack", integration_id="T_SLACK", config={})
self.task = self.Task.objects.create(
team=self.team,
title="Test task",
diff --git a/products/tasks/backend/temporal/process_task/tests/test_forward_pending_message.py b/products/tasks/backend/temporal/process_task/tests/test_forward_pending_message.py
index 4c170e93ad9c..4db77a8a004a 100644
--- a/products/tasks/backend/temporal/process_task/tests/test_forward_pending_message.py
+++ b/products/tasks/backend/temporal/process_task/tests/test_forward_pending_message.py
@@ -47,7 +47,7 @@ class TestForwardPendingUserMessage(TestCase):
)
cls.slack_integration = Integration.objects.create(
team=cls.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T123",
config={},
)
diff --git a/products/tasks/backend/temporal/slack_relay/tests/test_activities.py b/products/tasks/backend/temporal/slack_relay/tests/test_activities.py
index c2b68952e380..0ade4e2a7552 100644
--- a/products/tasks/backend/temporal/slack_relay/tests/test_activities.py
+++ b/products/tasks/backend/temporal/slack_relay/tests/test_activities.py
@@ -50,7 +50,7 @@ class TestRelaySlackMessage(TestCase):
)
cls.integration = Integration.objects.create(
team=cls.team,
- kind="slack-posthog-code",
+ kind="slack",
integration_id="T123",
config={},
)
diff --git a/products/tasks/backend/tests/test_api.py b/products/tasks/backend/tests/test_api.py
index 67007da65743..b74343f19f99 100644
--- a/products/tasks/backend/tests/test_api.py
+++ b/products/tasks/backend/tests/test_api.py
@@ -3113,9 +3113,7 @@ class TestTaskRunAPI(BaseTaskAPITest):
task = self.create_task()
run = TaskRun.objects.create(task=task, team=self.team, status=TaskRun.Status.IN_PROGRESS)
- integration = Integration.objects.create(
- team=self.team, kind="slack-posthog-code", integration_id="T_SLACK", config={}
- )
+ integration = Integration.objects.create(team=self.team, kind="slack", integration_id="T_SLACK", config={})
SlackThreadTaskMapping.objects.create(
team=self.team,
@@ -3164,9 +3162,7 @@ class TestTaskRunAPI(BaseTaskAPITest):
task = self.create_task()
run = TaskRun.objects.create(task=task, team=self.team, status=TaskRun.Status.IN_PROGRESS)
- integration = Integration.objects.create(
- team=self.team, kind="slack-posthog-code", integration_id="T_SLACK", config={}
- )
+ integration = Integration.objects.create(team=self.team, kind="slack", integration_id="T_SLACK", config={})
SlackThreadTaskMapping.objects.create(
team=self.team,
@@ -3294,9 +3290,7 @@ class TestTaskRunAPI(BaseTaskAPITest):
run = TaskRun.objects.create(task=task, team=self.team, status=TaskRun.Status.IN_PROGRESS)
mock_execute_relay.return_value = "relay-1"
- integration = Integration.objects.create(
- team=self.team, kind="slack-posthog-code", integration_id="T_SLACK", config={}
- )
+ integration = Integration.objects.create(team=self.team, kind="slack", integration_id="T_SLACK", config={})
SlackThreadTaskMapping.objects.create(
team=self.team,
integration=integration,
@@ -3378,9 +3372,7 @@ class TestTaskRunAPI(BaseTaskAPITest):
task = self.create_task()
run = TaskRun.objects.create(task=task, team=self.team, status=TaskRun.Status.IN_PROGRESS)
- integration = Integration.objects.create(
- team=self.team, kind="slack-posthog-code", integration_id="T_SLACK", config={}
- )
+ integration = Integration.objects.create(team=self.team, kind="slack", integration_id="T_SLACK", config={})
SlackThreadTaskMapping.objects.create(
team=self.team,
integration=integration,