: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
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.pynew file mode 100644index 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.pynew file mode 100644index 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 CDPIconsServicediff --git a/products/cdp/backend/presentation/serializers.py b/products/cdp/backend/presentation/serializers.pynew file mode 100644index 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.pyindex 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_requestfrom posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.api.tagged_item import TaggedItemViewSetMixinfrom posthog.auth import SessionAuthentication, is_mcp_request-from posthog.cdp.services.icons import CDPIconsServicefrom posthog.event_usage import report_user_actionfrom posthog.exceptions import Conflictfrom 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 CDPIconsServicefrom products.customer_analytics.backend.facade import api, contractsfrom 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.pyindex 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 Responsefrom posthog.api.mixins import validated_requestfrom posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.auth import SessionAuthentication-from posthog.cdp.services.icons import CDPIconsServicefrom posthog.cloud_utils import is_dev_modefrom posthog.event_usage import report_user_actionfrom 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_agentsfrom ..facade.api import check_mcp_url_policy, resolve_member_tool_statesfrom ..gateway import link_installation_to_gateway, members_can_manage_agent_access, server_disabled_reasondiff --git a/products/messaging/backend/presentation/views/message_templates.py b/products/messaging/backend/presentation/views/message_templates.pyindex 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 Responsefrom posthog.api.forbid_destroy_model import ForbidDestroyModelfrom posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.api.shared import UserBasicSerializer-from posthog.cdp.validation import build_html_wrap_designfrom posthog.event_usage import report_user_actionfrom posthog.models import User+from products.cdp.backend.presentation.hog_functions import build_html_wrap_designfrom 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.pyindex 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 Requestfrom rest_framework.response import Responsefrom posthog.api.utils import action-from posthog.cdp.validation import InputsSerializerfrom products.cdp.backend.facade.api import HogFunctionSerializerfrom products.cdp.backend.facade.models import HogFunction+from products.cdp.backend.presentation.serializers import InputsSerializerfrom 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.pyindex 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 LogEntryMixinfrom posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.api.shared import UserBasicSerializerfrom 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, InputsSerializerfrom posthog.clickhouse.query_tagging import Feature, tag_queriesfrom posthog.dataclasses import frozenfrom 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 DesignOperationSerializerfrom products.notifications.backend.facade.api import publish_resource_editedfrom products.tasks.backend.facade.api import list_workflow_last_runsdiff --git a/products/workflows/backend/presentation/views/hog_flow_fields.py b/products/workflows/backend/presentation/views/hog_flow_fields.pyindex 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 jsonfrom 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 setdiff --git a/products/workflows/backend/presentation/views/hog_flow_template.py b/products/workflows/backend/presentation/views/hog_flow_template.pyindex 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 Responsefrom posthog.api.log_entries import LogEntryMixinfrom posthog.api.routing import TeamAndOrgViewSetMixin-from posthog.cdp.validation import HogFunctionFiltersSerializerfrom posthog.event_usage import report_user_actionfrom posthog.helpers.impersonation import is_impersonatedfrom posthog.models import Userfrom posthog.models.activity_logging.activity_log import Detail, log_activity+from products.cdp.backend.presentation.serializers import HogFunctionFiltersSerializerfrom products.workflows.backend.facade.contracts import WorkflowTemplate, WorkflowTemplateNotFoundfrom products.workflows.backend.facade.enums import HogFlowTemplateExitCondition, HogFlowTemplateScopefrom products.workflows.backend.facade.templates import (diff --git a/tach.toml b/tach.tomlindex 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"