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): record the chart delivery mode on reply analytics (#123269)

Vojta Bartoša297ac6c91ca
diff --git a/products/slack_app/backend/services/slack_messages.py b/products/slack_app/backend/services/slack_messages.py
index 56fa486630a5..bdf9851fbbab 100644
--- a/products/slack_app/backend/services/slack_messages.py
+++ b/products/slack_app/backend/services/slack_messages.py
@@ -710,6 +710,9 @@ class RunFooter:
project: str | None = None
# Whose plan pays for the run, for example "Your ChatGPT plan". Absent on PostHog credits.
plan: str | None = None
+ # Whether the run shares charts as insight links instead of images, so reply analytics can
+ # compare the two delivery modes. Not rendered.
+ chart_links: bool = False
def has_content(self) -> bool:
"""Whether this would render as anything.
@@ -833,6 +836,7 @@ def load_run_footer(run_id: str | UUID | None, *, integration_id: int | None) ->
created_by_id=run.created_by_id,
),
plan=_plan_label(run.state, task_id=run.task_id, integration_id=integration_id),
+ chart_links=bool((run.state or {}).get("slack_chart_links")),
)
except Exception:
logger.exception("slack_app_run_footer_load_failed", run_id=str(run_id))
diff --git a/products/slack_app/backend/slack_link_unfurl.py b/products/slack_app/backend/slack_link_unfurl.py
index d6c36d4c83fa..288c82a1a24f 100644
--- a/products/slack_app/backend/slack_link_unfurl.py
+++ b/products/slack_app/backend/slack_link_unfurl.py
@@ -1481,6 +1481,7 @@ def handle_posthog_link_unfurl(event: dict, integration: Integration) -> None:
kinds=kinds,
compact=compact,
error=error,
+ bot_reply=bot_reply_actor is not None,
)
if error not in _REJECTED_PAYLOAD_ERRORS:
return
diff --git a/products/slack_app/backend/slack_thread.py b/products/slack_app/backend/slack_thread.py
index a421ed54dcd7..4234a2b6c860 100644
--- a/products/slack_app/backend/slack_thread.py
+++ b/products/slack_app/backend/slack_thread.py
@@ -1163,6 +1163,7 @@ class SlackThreadHandler:
slack_session_id=self._session_id(),
task_id=self.run_footer.task_id,
run_id=self.run_footer.run_id,
+ chart_links=self.run_footer.chart_links,
)
except Exception:
logger.warning("slack_app_reply_posted_capture_failed", reply_kind=str(reply_kind), exc_info=True)
diff --git a/products/slack_app/backend/tests/services/slack_messages/test_run_footer.py b/products/slack_app/backend/tests/services/slack_messages/test_run_footer.py
index a3fe1b4adc6d..2afe7ed332e3 100644
--- a/products/slack_app/backend/tests/services/slack_messages/test_run_footer.py
+++ b/products/slack_app/backend/tests/services/slack_messages/test_run_footer.py
@@ -98,7 +98,7 @@ class TestLoadRunFooter(SimpleTestCase):
def test_describes_the_run(self, mock_get_run, mock_parse) -> None:
task_id = uuid4()
mock_get_run.return_value = SimpleNamespace(
- id=uuid4(), task_id=task_id, team_id=1, state={}, created_by_id=None
+ id=uuid4(), task_id=task_id, team_id=1, state={"slack_chart_links": True}, created_by_id=None
)
mock_parse.return_value = SimpleNamespace(model="claude-opus-5", reasoning_effort="high")
@@ -106,6 +106,7 @@ class TestLoadRunFooter(SimpleTestCase):
assert f"/tasks/{task_id}" in (footer.task_url or "")
assert footer.model == "claude-opus-5"
+ assert footer.chart_links is True
@parameterized.expand(
[
diff --git a/products/slack_app/backend/tests/test_slack_thread.py b/products/slack_app/backend/tests/test_slack_thread.py
index a8bbfaef4f41..0e5e96cd117e 100644
--- a/products/slack_app/backend/tests/test_slack_thread.py
+++ b/products/slack_app/backend/tests/test_slack_thread.py
@@ -673,7 +673,9 @@ class TestReplyPostedCapture(SimpleTestCase):
reader = MagicMock()
mock_resolve_user.return_value = reader
context = SlackThreadContext(integration_id=1, channel="C001", thread_ts="1234.5678")
- handler = SlackThreadHandler(context, RunFooter(run_id="run-1", task_id="task-1"), actor_slack_user_id="U123")
+ handler = SlackThreadHandler(
+ context, RunFooter(run_id="run-1", task_id="task-1", chart_links=True), actor_slack_user_id="U123"
+ )
reply(handler)
@@ -691,6 +693,7 @@ class TestReplyPostedCapture(SimpleTestCase):
"slack_session_id": "T1:C001:1234.5678",
"task_id": "task-1",
"run_id": "run-1",
+ "chart_links": True,
}