: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
fix(replay): show slack channel name in vision action delivery column (#67413)
Kim Svatos Dugan1aab02439528
diff --git a/products/replay_vision/backend/api/delivery.py b/products/replay_vision/backend/api/delivery.pyindex 70bae6c5c5a3..1e747faa2320 100644--- a/products/replay_vision/backend/api/delivery.py+++ b/products/replay_vision/backend/api/delivery.py@@ -36,6 +36,12 @@ def _managed_destinations(action: VisionAction, team: Team) -> QuerySet[HogFunct)+def _channel_id(value: str) -> str:+ # The channel is stored as the `${id}|#${name}` picker composite so the UI can show a friendly+ # name; the Slack template wants the bare id. Mirrors `slackChannelId` in the frontend.+ return value.split("|", 1)[0].strip()++def _slack_destination_payload(action: VisionAction, target: dict[str, Any]) -> dict[str, Any]:return {"type": _INTERNAL_DESTINATION,@@ -50,7 +56,7 @@ def _slack_destination_payload(action: VisionAction, target: dict[str, Any]) ->},"inputs": {"slack_workspace": {"value": target["integration_id"]},- "channel": {"value": target["channel"]},+ "channel": {"value": _channel_id(target["channel"])},# Hog-templated pass-through of the pre-formatted Slack text carried on the event."text": {"value": "{event.properties.slack_text}"},},diff --git a/products/replay_vision/backend/tests/test_vision_action_delivery.py b/products/replay_vision/backend/tests/test_vision_action_delivery.pyindex bd5bf094d54e..9be92b90e7fa 100644--- a/products/replay_vision/backend/tests/test_vision_action_delivery.py+++ b/products/replay_vision/backend/tests/test_vision_action_delivery.py@@ -123,6 +123,14 @@ class TestVisionActionDelivery(APIBaseTest):self.assertEqual(self._inputs(fn)["channel"]["value"], "#general")self.assertEqual(self._inputs(fn)["text"]["value"], "{event.properties.slack_text}")+ def test_channel_composite_is_stripped_to_bare_id_for_slack(self) -> None:+ # The UI stores the `${id}|#${name}` picker composite; the Slack destination must receive the+ # bare id, or the channel input is malformed and delivery fails.+ action = self._create_action(+ delivery_config=[{"type": "slack", "integration_id": self.integration.id, "channel": "C123|#general"}],+ )+ self.assertEqual(self._inputs(self._destinations(action)[0])["channel"]["value"], "C123")+def test_create_two_targets_makes_two_destinations(self) -> None:action = self._create_action(delivery_config=[diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionActionsTab.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionActionsTab.tsxindex 3546c8b36e67..c84f4aa441c1 100644--- a/products/replay_vision/frontend/replay_scanners/components/VisionActionsTab.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/VisionActionsTab.tsx@@ -6,6 +6,7 @@ import { LemonButton, LemonSwitch, LemonTable, Link } from '@posthog/lemon-ui'import { AccessControlAction } from 'lib/components/AccessControlAction'import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'+import { slackChannelDisplayName } from 'lib/integrations/slackChannel'import { LemonDialog } from 'lib/lemon-ui/LemonDialog'import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'@@ -47,7 +48,17 @@ function EditorGate({ children }: { children: JSX.Element }): JSX.Element {function deliverySummary(action: VisionActionApi): string {const targets = action.delivery_config ?? []- return targets.length ? targets.map((t) => t.channel).join(', ') : '—'+ if (!targets.length) {+ return '—'+ }+ return targets+ .map((t) => {+ // channel is the `${id}|#${name}` picker composite for actions saved with a friendly name;+ // fall back to "Slack" rather than exposing a bare channel id (older rows, id-only input).+ const name = slackChannelDisplayName(t.channel)+ return name.startsWith('#') ? name : 'Slack'+ })+ .join(', ')}export function VisionActionsTab({ scannerId }: { scannerId: string }): JSX.Element {diff --git a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.test.ts b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.test.tsindex 38be20140667..690d469ba690 100644--- a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.test.ts+++ b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.test.ts@@ -155,7 +155,9 @@ describe('visionActionsLogic', () => {scanner: 's1',trigger_config: { rrule: 'FREQ=WEEKLY;BYDAY=MO,WE;BYHOUR=14;BYMINUTE=30', timezone: 'Europe/Prague' },synthesis_config: { prompt_guide: 'focus on checkout' },- delivery_config: [{ type: DeliveryTargetTypeEnumApi.Slack, integration_id: 5, channel: 'C123' }],+ // The full `${id}|#${name}` composite is stored so the actions table can show the channel+ // name; the backend strips it to the bare id for the Slack destination.+ delivery_config: [{ type: DeliveryTargetTypeEnumApi.Slack, integration_id: 5, channel: 'C123|#general' }],})})diff --git a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.tsindex a091fa9a0d4d..df38b867da5f 100644--- a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts+++ b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts@@ -2,7 +2,6 @@ import { actions, afterMount, kea, key, listeners, path, props, reducers } fromimport { forms } from 'kea-forms'import { dayjs } from 'lib/dayjs'-import { slackChannelId } from 'lib/integrations/slackChannel'import { lemonToast } from 'lib/lemon-ui/LemonToast'import { teamLogic } from 'scenes/teamLogic'@@ -55,7 +54,9 @@ export function buildActionBody(form: VisionActionForm, scannerId: string): Para{type: DeliveryTargetTypeEnumApi.Slack,integration_id: form.integration_id,- channel: slackChannelId(form.channel),+ // Store the `${id}|#${name}` picker composite so the table can show the+ // channel name; delivery.py strips it to the bare id for the Slack destination.+ channel: form.channel,},]: [],