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.

chore(cdp): route other products' views through cdp presentation (#115434)

Harley Alexanderd553df62298d
diff --git a/products/cdp/backend/presentation/hog_functions.py b/products/cdp/backend/presentation/hog_functions.py
new file mode 100644
index 000000000000..8ce43a55b232
--- /dev/null
+++ b/products/cdp/backend/presentation/hog_functions.py
@@ -0,0 +1,19 @@
+"""Hog function helpers that other products' views call.
+
+A product's presentation layer may import another product's presentation but not its internals, so
+the helpers that workflows and messaging views use cross here. Their signatures take models and
+return untyped bytecode, so they cannot cross through the facade.
+"""
+
+from posthog.cdp.filters import (
+ DATA_WAREHOUSE_SOURCES as DATA_WAREHOUSE_SOURCES,
+ compile_filters_expr as compile_filters_expr,
+)
+from posthog.cdp.flag_gated_templates import (
+ FLAG_GATED_TEMPLATE_IDS as FLAG_GATED_TEMPLATE_IDS,
+ gated_template_enabled as gated_template_enabled,
+)
+from posthog.cdp.validation import (
+ build_html_wrap_design as build_html_wrap_design,
+ generate_template_bytecode as generate_template_bytecode,
+)
diff --git a/products/cdp/backend/presentation/icons.py b/products/cdp/backend/presentation/icons.py
new file mode 100644
index 000000000000..79706e32c21b
--- /dev/null
+++ b/products/cdp/backend/presentation/icons.py
@@ -0,0 +1,3 @@
+"""The destination icon service that other products' icon endpoints serve through."""
+
+from posthog.cdp.services.icons import CDPIconsService as CDPIconsService
diff --git a/products/cdp/backend/presentation/serializers.py b/products/cdp/backend/presentation/serializers.py
new file mode 100644
index 000000000000..98d36d3931b8
--- /dev/null
+++ b/products/cdp/backend/presentation/serializers.py
@@ -0,0 +1,10 @@
+"""Hog function input and filter serializers that other products' views reuse.
+
+A facade must not hand out DRF classes, so these cross through presentation instead.
+"""
+
+from posthog.cdp.validation import (
+ HogFunctionFiltersSerializer as HogFunctionFiltersSerializer,
+ InputsSchemaSerializer as InputsSchemaSerializer,
+ InputsSerializer as InputsSerializer,
+)
diff --git a/products/customer_analytics/backend/presentation/views/views.py b/products/customer_analytics/backend/presentation/views/views.py
index 392997bf67eb..92665bcdc905 100644
--- a/products/customer_analytics/backend/presentation/views/views.py
+++ b/products/customer_analytics/backend/presentation/views/views.py
@@ -39,7 +39,6 @@ from posthog.api.mixins import ValidatedRequest, validated_request
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.api.tagged_item import TaggedItemViewSetMixin
from posthog.auth import SessionAuthentication, is_mcp_request
-from posthog.cdp.services.icons import CDPIconsService
from posthog.event_usage import report_user_action
from posthog.exceptions import Conflict
from posthog.helpers.impersonation import is_impersonated
@@ -66,6 +65,7 @@ from products.access_control.backend.facade.user_access_control import (
model_to_resource,
)
from products.access_control.backend.presentation.access_control import AccessControlViewSetMixin
+from products.cdp.backend.presentation.icons import CDPIconsService
from products.customer_analytics.backend.facade import api, contracts
from products.customer_analytics.backend.facade.constants import (
CUSTOMER_ANALYTICS_ACCOUNT_VIEWS_FLAG,
diff --git a/products/mcp_store/backend/presentation/views.py b/products/mcp_store/backend/presentation/views.py
index b76700213f08..344d69f84c52 100644
--- a/products/mcp_store/backend/presentation/views.py
+++ b/products/mcp_store/backend/presentation/views.py
@@ -32,7 +32,6 @@ from rest_framework.response import Response
from posthog.api.mixins import validated_request
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.auth import SessionAuthentication
-from posthog.cdp.services.icons import CDPIconsService
from posthog.cloud_utils import is_dev_mode
from posthog.event_usage import report_user_action
from posthog.models import User
@@ -47,6 +46,8 @@ from posthog.rate_limit import (
MCPProxySustainedThrottle,
)
+from products.cdp.backend.presentation.icons import CDPIconsService
+
from ..agents import sync_built_in_agents
from ..facade.api import check_mcp_url_policy, resolve_member_tool_states
from ..gateway import link_installation_to_gateway, members_can_manage_agent_access, server_disabled_reason
diff --git a/products/messaging/backend/presentation/views/message_templates.py b/products/messaging/backend/presentation/views/message_templates.py
index 672aa2b74064..3fa268dd66fb 100644
--- a/products/messaging/backend/presentation/views/message_templates.py
+++ b/products/messaging/backend/presentation/views/message_templates.py
@@ -16,10 +16,10 @@ from rest_framework.response import Response
from posthog.api.forbid_destroy_model import ForbidDestroyModel
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.api.shared import UserBasicSerializer
-from posthog.cdp.validation import build_html_wrap_design
from posthog.event_usage import report_user_action
from posthog.models import User
+from products.cdp.backend.presentation.hog_functions import build_html_wrap_design
from products.messaging.backend.facade.api import (
UnlayerNotConfiguredError,
UnlayerRenderError,
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py b/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py
index 537460524631..f8a9e1ca04b3 100644
--- a/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py
+++ b/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py
@@ -13,10 +13,10 @@ from rest_framework.request import Request
from rest_framework.response import Response
from posthog.api.utils import action
-from posthog.cdp.validation import InputsSerializer
from products.cdp.backend.facade.api import HogFunctionSerializer
from products.cdp.backend.facade.models import HogFunction
+from products.cdp.backend.presentation.serializers import InputsSerializer
from products.data_warehouse.backend.facade.api import (
create_and_register_webhook,
delete_webhook_and_hog_function,
diff --git a/products/workflows/backend/presentation/views/hog_flow.py b/products/workflows/backend/presentation/views/hog_flow.py
index 1ff2e80b0538..eec202b2ca7d 100644
--- a/products/workflows/backend/presentation/views/hog_flow.py
+++ b/products/workflows/backend/presentation/views/hog_flow.py
@@ -54,9 +54,6 @@ from posthog.api.log_entries import LogEntryMixin
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.api.shared import UserBasicSerializer
from posthog.auth import InternalAPIAuthentication
-from posthog.cdp.filters import DATA_WAREHOUSE_SOURCES, compile_filters_expr
-from posthog.cdp.flag_gated_templates import FLAG_GATED_TEMPLATE_IDS, gated_template_enabled
-from posthog.cdp.validation import HogFunctionFiltersSerializer, InputsSchemaSerializer, InputsSerializer
from posthog.clickhouse.query_tagging import Feature, tag_queries
from posthog.dataclasses import frozen
from posthog.event_usage import AGENT_EVENT_SOURCES, EventSource, get_event_source, report_user_action
@@ -88,6 +85,12 @@ from products.access_control.backend.presentation.access_control import (
AccessControlViewSetMixin,
UserAccessControlSerializerMixin,
)
+from products.cdp.backend.presentation.hog_functions import (
+ DATA_WAREHOUSE_SOURCES,
+ FLAG_GATED_TEMPLATE_IDS,
+ compile_filters_expr,
+ gated_template_enabled,
+)
from products.cdp.backend.presentation.hog_invocations.cancel import (
HogInvocationCancelRequestSerializer,
HogInvocationCancelResponseSerializer,
@@ -107,6 +110,11 @@ from products.cdp.backend.presentation.hog_invocations.results import (
fetch_hog_invocation_results_count,
tag_invocation_results_query,
)
+from products.cdp.backend.presentation.serializers import (
+ HogFunctionFiltersSerializer,
+ InputsSchemaSerializer,
+ InputsSerializer,
+)
from products.messaging.backend.presentation.views.serializers import DesignOperationSerializer
from products.notifications.backend.facade.api import publish_resource_edited
from products.tasks.backend.facade.api import list_workflow_last_runs
diff --git a/products/workflows/backend/presentation/views/hog_flow_fields.py b/products/workflows/backend/presentation/views/hog_flow_fields.py
index 04baf6ce763c..fe5aea523bab 100644
--- a/products/workflows/backend/presentation/views/hog_flow_fields.py
+++ b/products/workflows/backend/presentation/views/hog_flow_fields.py
@@ -2,7 +2,7 @@ import json
from rest_framework import serializers
-from posthog.cdp.validation import generate_template_bytecode
+from products.cdp.backend.presentation.hog_functions import generate_template_bytecode
# Caps both the variable definitions on a workflow and the variable values a single run passes,
# so the two share one number instead of drifting. The runtime also checks dynamically set
diff --git a/products/workflows/backend/presentation/views/hog_flow_template.py b/products/workflows/backend/presentation/views/hog_flow_template.py
index 7b396ef9c8df..f0b762fe0b2d 100644
--- a/products/workflows/backend/presentation/views/hog_flow_template.py
+++ b/products/workflows/backend/presentation/views/hog_flow_template.py
@@ -11,12 +11,12 @@ from rest_framework.response import Response
from posthog.api.log_entries import LogEntryMixin
from posthog.api.routing import TeamAndOrgViewSetMixin
-from posthog.cdp.validation import HogFunctionFiltersSerializer
from posthog.event_usage import report_user_action
from posthog.helpers.impersonation import is_impersonated
from posthog.models import User
from posthog.models.activity_logging.activity_log import Detail, log_activity
+from products.cdp.backend.presentation.serializers import HogFunctionFiltersSerializer
from products.workflows.backend.facade.contracts import WorkflowTemplate, WorkflowTemplateNotFound
from products.workflows.backend.facade.enums import HogFlowTemplateExitCondition, HogFlowTemplateScope
from products.workflows.backend.facade.templates import (
diff --git a/tach.toml b/tach.toml
index 9cbd7d41f133..9394d5cd60c5 100644
--- a/tach.toml
+++ b/tach.toml
@@ -626,6 +626,9 @@ path = "products.mcp_store"
depends_on = [
"ee",
"posthog", "products.access_control",
+ # Presentation-only: the server icon endpoint serves through
+ # products.cdp.backend.presentation.icons.
+ "products.cdp",
]
layer = "modules"
@@ -639,6 +642,9 @@ depends_on = [
# Facade-only: the recipient preferences page reads EmailTrackingConsentMode through
# products.workflows.backend.facade.enums.
"products.workflows",
+ # Presentation-only: the template design action wraps HTML through
+ # products.cdp.backend.presentation.hog_functions.
+ "products.cdp",
]
layer = "modules"