: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(slack_app): add the connect your tools step to the slack onboarding (#129901)
Vojta Bartošef7af5c0dd89
diff --git a/products/slack_app/backend/logic/onboarding/step.py b/products/slack_app/backend/logic/onboarding/step.pyindex 96b57c0a293b..42058d3318c6 100644--- a/products/slack_app/backend/logic/onboarding/step.py+++ b/products/slack_app/backend/logic/onboarding/step.py@@ -29,6 +29,7 @@ class OnboardingStepKey(StrEnum):SOURCES = "sources"CHANNEL_WELCOME = "channel_welcome"MODEL = "model"+ TOOLS = "tools"REPLIES_IN_THREADS = "replies_in_threads"diff --git a/products/slack_app/backend/logic/onboarding/steps.py b/products/slack_app/backend/logic/onboarding/steps.pyindex d3656a418819..9bf079b10afc 100644--- a/products/slack_app/backend/logic/onboarding/steps.py+++ b/products/slack_app/backend/logic/onboarding/steps.py@@ -7,6 +7,7 @@ from products.slack_app.backend.logic.onboarding.model_step import ModelStepfrom products.slack_app.backend.logic.onboarding.replies_step import RepliesInThreadsStepfrom products.slack_app.backend.logic.onboarding.sources_step import SourcesStepfrom products.slack_app.backend.logic.onboarding.step import OnboardingStep+from products.slack_app.backend.logic.onboarding.tools_step import ToolsStep# In display order. The account link comes first, because the steps after it act for the linked user.ONBOARDING_STEPS: tuple[OnboardingStep, ...] = (@@ -17,6 +18,7 @@ ONBOARDING_STEPS: tuple[OnboardingStep, ...] = (SourcesStep(),ChannelWelcomeStep(),ModelStep(),+ ToolsStep(),RepliesInThreadsStep(),)STEPS_BY_KEY: dict[str, OnboardingStep] = {step.key: step for step in ONBOARDING_STEPS}diff --git a/products/slack_app/backend/logic/onboarding/tools_step.py b/products/slack_app/backend/logic/onboarding/tools_step.pynew file mode 100644index 000000000000..b1e1232d9cdf--- /dev/null+++ b/products/slack_app/backend/logic/onboarding/tools_step.py@@ -0,0 +1,41 @@+from products.mcp_store.backend.facade.api import get_active_installations+from products.slack_app.backend.logic.onboarding.actions import CONTINUE_ACTION_ID, button, skip_button+from products.slack_app.backend.logic.onboarding.step import OnboardingContext, OnboardingStep, OnboardingStepKey+from products.slack_app.backend.services.slack_messages import project_web_url, section_block+++class ToolsStep(OnboardingStep):+ key = OnboardingStepKey.TOOLS+ title = "Your tools"+ done_text = "Tools connected"++ def applies(self, ctx: OnboardingContext) -> bool:+ # MCP servers connect for a PostHog user, so the step needs an account that can link.+ return ctx.can_link++ def is_done(self, ctx: OnboardingContext) -> bool:+ user = ctx.posthog_user+ return user is not None and bool(get_active_installations(ctx.integration.team_id, user.id))++ def render(self, ctx: OnboardingContext) -> list[dict]:+ return [+ section_block(+ "*Connect your tools*\n"+ "I can also use MCP servers, such as Linear or Notion. Connect them in PostHog, and I use them "+ "with your own access. Press Continue when you're done."+ ),+ {+ "type": "actions",+ "elements": [+ # A URL button: the servers connect in the browser, and the thread updates on Continue.+ {+ "type": "button",+ "text": {"type": "plain_text", "text": "Connect an MCP server"},+ "url": f"{project_web_url(ctx.integration.team_id)}/mcp-servers",+ "style": "primary",+ },+ button(ctx, "Continue", CONTINUE_ACTION_ID, step=self.key),+ skip_button(ctx, self.key),+ ],+ },+ ]diff --git a/products/slack_app/backend/tests/logic/onboarding/test_steps.py b/products/slack_app/backend/tests/logic/onboarding/test_steps.pyindex 5e6c05d663ad..6af24fa8b6be 100644--- a/products/slack_app/backend/tests/logic/onboarding/test_steps.py+++ b/products/slack_app/backend/tests/logic/onboarding/test_steps.py@@ -17,6 +17,7 @@ from products.slack_app.backend.services.workspace_integrations import (from products.slack_app.backend.tests.conftest import SLACK_TEAM_ID, SLACK_USER_IDGITHUB_STEP = "products.slack_app.backend.logic.onboarding.github_step"+TOOLS_STEP = "products.slack_app.backend.logic.onboarding.tools_step"ADMIN_SCOPES = "chat:write,users:read,users:read.email,channels:manage,channels:read,groups:read"@@ -80,8 +81,8 @@ def test_each_button_on_a_step_reaches_a_handler(step: OnboardingStep, org_team_@pytest.mark.parametrize("role, expected",[- ("member", ["link_account", "model", "replies_in_threads"]),- ("member_with_team_github", ["link_account", "github", "model", "replies_in_threads"]),+ ("member", ["link_account", "model", "tools", "replies_in_threads"]),+ ("member_with_team_github", ["link_account", "github", "model", "tools", "replies_in_threads"]),("installer",[@@ -92,10 +93,12 @@ def test_each_button_on_a_step_reaches_a_handler(step: OnboardingStep, org_team_"sources","channel_welcome","model",+ "tools","replies_in_threads",],),- ("linked_org_admin", ["ai_consent", "model", "replies_in_threads"]),+ ("linked_org_admin", ["ai_consent", "model", "tools", "replies_in_threads"]),+ ("linked_member_with_tools", ["model", "replies_in_threads"]),],)def test_the_planned_steps_depend_on_the_role(role: str, expected: list[str], org_team_user, link_user) -> None:@@ -105,10 +108,14 @@ def test_the_planned_steps_depend_on_the_role(role: str, expected: list[str], orOrganizationMembership.objects.filter(user=user, organization=org).update(level=OrganizationMembership.Level.ADMIN)+ if role.startswith("linked_"):link_user(user)integration = _install(team, installer=SLACK_USER_ID if role == "installer" else None)- with patch(f"{GITHUB_STEP}.has_team_github", return_value=role == "member_with_team_github"):+ with (+ patch(f"{GITHUB_STEP}.has_team_github", return_value=role == "member_with_team_github"),+ patch(f"{TOOLS_STEP}.get_active_installations", return_value=[object()] if role.endswith("_tools") else []),+ ):plan = plan_onboarding(integration, SLACK_USER_ID)assert plan.post is not None and plan.post.planned == expecteddiff --git a/products/slack_app/backend/tests/logic/onboarding/test_thread.py b/products/slack_app/backend/tests/logic/onboarding/test_thread.pyindex 158151f7ba1f..31994af52734 100644--- a/products/slack_app/backend/tests/logic/onboarding/test_thread.py+++ b/products/slack_app/backend/tests/logic/onboarding/test_thread.py@@ -24,6 +24,7 @@ from products.slack_app.backend.logic.onboarding.interactivity import (onboarding_integration_hint,)from products.slack_app.backend.logic.onboarding.sources_step import NO_PROJECT_ACCESS_TEXT+from products.slack_app.backend.logic.onboarding.tools_step import ToolsStepfrom products.slack_app.backend.models import ChannelWelcomeMode, UntaggedFollowupModefrom products.slack_app.backend.services.slack_settings import (resolve_auto_model_choice,@@ -78,6 +79,13 @@ def _click(integration: WorkspaceIntegration, action_id: str, **value: str) -> d}[email protected](autouse=True)+def without_tools_step() -> Iterator[None]:+ # These tests count a member's steps, so they keep the member's step list fixed. test_steps.py covers this step.+ with patch.object(ToolsStep, "applies", return_value=False):+ yield++@pytest.fixturedef slack_client() -> Iterator[MagicMock]:with patch("posthog.models.integration.slack.WebClient") as web_client: