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): import template dataclasses from products/cdp in other callers (#115478)

Harley Alexandere1f55528cfdc
diff --git a/posthog/management/commands/sync_hog_function_templates.py b/posthog/management/commands/sync_hog_function_templates.py
index cc0123112435..ee4a88782ff6 100644
--- a/posthog/management/commands/sync_hog_function_templates.py
+++ b/posthog/management/commands/sync_hog_function_templates.py
@@ -7,11 +7,11 @@ from django.core.management.base import BaseCommand
import structlog
from posthog.cdp.templates import HOG_FUNCTION_TEMPLATES
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.plugins.plugin_server_api import get_hog_function_templates
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate
from products.cdp.backend.models.hog_functions.hog_function import HogFunctionType
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.warehouse_sources.backend.facade.source_management import (
SourceRegistry,
WebhookSource,
diff --git a/posthog/models/test/test_hog_function_template.py b/posthog/models/test/test_hog_function_template.py
index 9c5a39495a24..f646a592fad4 100644
--- a/posthog/models/test/test_hog_function_template.py
+++ b/posthog/models/test/test_hog_function_template.py
@@ -1,9 +1,9 @@
from django.test import TestCase
from posthog.cdp.templates.fixtures import template_slack as slack_template
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
class TestHogFunctionTemplate(TestCase):
@@ -72,7 +72,7 @@ class TestHogFunctionTemplate(TestCase):
def test_update_existing_template(self):
"""Test updating an existing template with new content"""
- from posthog.cdp.templates.hog_function_template import HogFunctionTemplateDC
+ from products.cdp.backend.templates.hog_function_template import HogFunctionTemplateDC
# First create a simple template
original_dto = HogFunctionTemplateDC(
diff --git a/products/alerts/backend/tests/api/test_alert.py b/products/alerts/backend/tests/api/test_alert.py
index 53c1e10c2aa0..1a00771b1bc2 100644
--- a/products/alerts/backend/tests/api/test_alert.py
+++ b/products/alerts/backend/tests/api/test_alert.py
@@ -16,7 +16,6 @@ from posthog.schema import AlertCalculationInterval, AlertConditionType, AlertSt
from posthog.api.tagged_item import set_tags_on_object
from posthog.cdp.templates.fixtures import template_slack
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.constants import AvailableFeature
from posthog.models import User
from posthog.models.integration import Integration
@@ -34,6 +33,7 @@ from products.alerts.backend.presentation.views.alert import AlertSerializer
from products.alerts_platform.backend.facade.contracts import AlertDelivery
from products.alerts_platform.backend.facade.scheduling import CalendarInterval, alert_check_offset
from products.cdp.backend.facade.models import HogFunction
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.product_analytics.backend.facade.models import Insight
TEST_DESTINATION_DELIVERY = AlertDelivery(
diff --git a/products/customer_analytics/backend/test/test_event_stream.py b/products/customer_analytics/backend/test/test_event_stream.py
index 539624a4aef1..eb4365e83856 100644
--- a/products/customer_analytics/backend/test/test_event_stream.py
+++ b/products/customer_analytics/backend/test/test_event_stream.py
@@ -7,12 +7,12 @@ from rest_framework import status
from slack_sdk.errors import SlackApiError
from posthog.cdp.templates.fixtures import template_slack
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.constants import AvailableFeature
from posthog.models import Integration, Organization, OrganizationMembership, Team
from products.access_control.backend.models.access_control import AccessControl
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.customer_analytics.backend.logic.event_stream_destination import _NO_MEMBERS_SENTINEL
from products.customer_analytics.backend.models import EventStream, EventStreamMember, TeamCustomerAnalyticsConfig
from products.customer_analytics.backend.test.factories import create_account
diff --git a/products/logs/backend/test/test_alerts_api.py b/products/logs/backend/test/test_alerts_api.py
index f9e0ceae4240..a2cf6c4386fa 100644
--- a/products/logs/backend/test/test_alerts_api.py
+++ b/products/logs/backend/test/test_alerts_api.py
@@ -12,13 +12,13 @@ from rest_framework import status
from rest_framework.test import APIClient
from posthog.cdp.templates.fixtures import template_pagerduty, template_slack
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.clickhouse.client import sync_execute
from posthog.models.team.team import Team
from posthog.models.user import User
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.cdp.backend.templates.microsoft_teams.template_microsoft_teams import template as template_microsoft_teams
from products.logs.backend.alert_check_query import AlertCheckQuery, BucketedCount
from products.logs.backend.models import LogsAlertConfiguration, LogsAlertEvent
diff --git a/products/replay_vision/backend/tests/test_vision_alerts_api.py b/products/replay_vision/backend/tests/test_vision_alerts_api.py
index 0e5e60035101..927594c7005d 100644
--- a/products/replay_vision/backend/tests/test_vision_alerts_api.py
+++ b/products/replay_vision/backend/tests/test_vision_alerts_api.py
@@ -11,7 +11,6 @@ from django.db import IntegrityError, transaction
from parameterized import parameterized
from posthog.cdp.templates.fixtures import template_slack
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.constants import AvailableFeature
from posthog.models import Organization, PersonalAPIKey, Team, User
from posthog.models.activity_logging.activity_log import ActivityLog
@@ -19,6 +18,7 @@ from posthog.models.utils import generate_random_token_personal, hash_key_value
from products.access_control.backend.models.access_control import AccessControl
from products.cdp.backend.models.hog_functions.hog_function import HogFunction, HogFunctionTemplate
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.replay_vision.backend.models.replay_scanner import ReplayScanner, ScannerModel, ScannerType
from products.replay_vision.backend.models.vision_alert import (
VisionAlertConfiguration,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/source.py
index 45239bbb2e7f..652e29f688bf 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/source.py
@@ -40,7 +40,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.zapsign.za
from products.warehouse_sources.backend.types import ExternalDataSourceType
if TYPE_CHECKING:
- from posthog.cdp.templates.hog_function_template import HogFunctionTemplateDC
+ from products.cdp.backend.templates.hog_function_template import HogFunctionTemplateDC
@SourceRegistry.register
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/webhook_template.py
index 7d09fc3c6064..196ef1935db4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/webhook_template.py
@@ -1,4 +1,4 @@
-from posthog.cdp.templates.hog_function_template import HogFunctionTemplateDC
+from products.cdp.backend.templates.hog_function_template import HogFunctionTemplateDC
template: HogFunctionTemplateDC = HogFunctionTemplateDC(
status="alpha",
diff --git a/products/workflows/backend/tests/api/test_hog_flow_action_email.py b/products/workflows/backend/tests/api/test_hog_flow_action_email.py
index 6e22be068786..8c0722cf4ca9 100644
--- a/products/workflows/backend/tests/api/test_hog_flow_action_email.py
+++ b/products/workflows/backend/tests/api/test_hog_flow_action_email.py
@@ -6,9 +6,8 @@ from unittest.mock import patch
from parameterized import parameterized
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
-
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.messaging.backend.facade.api import UnlayerRenderError
from products.messaging.backend.facade.testing import create_message_template_for_test
from products.workflows.backend.models.hog_flow.hog_flow import HogFlow
diff --git a/products/workflows/backend/tests/api/test_hog_flow_draft_publish.py b/products/workflows/backend/tests/api/test_hog_flow_draft_publish.py
index 81b1a478cc4f..aa06915c57ab 100644
--- a/products/workflows/backend/tests/api/test_hog_flow_draft_publish.py
+++ b/products/workflows/backend/tests/api/test_hog_flow_draft_publish.py
@@ -6,10 +6,10 @@ from unittest.mock import MagicMock, patch
from parameterized import parameterized
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.models.activity_logging.activity_log import ActivityLog
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.workflows.backend.models.hog_flow.hog_flow import HogFlow
from products.workflows.backend.models.hog_flow_revision import HogFlowRevision
from products.workflows.backend.presentation.views.hog_flow import WRITABLE_DRAFT_CONTENT_FIELDS
diff --git a/products/workflows/backend/tests/api/test_hog_flow_revisions.py b/products/workflows/backend/tests/api/test_hog_flow_revisions.py
index 6f76a7ebf134..7a03720d2759 100644
--- a/products/workflows/backend/tests/api/test_hog_flow_revisions.py
+++ b/products/workflows/backend/tests/api/test_hog_flow_revisions.py
@@ -5,10 +5,10 @@ from unittest.mock import MagicMock, patch
from parameterized import parameterized
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.models.activity_logging.activity_log import ActivityLog
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.workflows.backend.models.hog_flow.hog_flow import HogFlow
from products.workflows.backend.services.hog_flow_content import DRAFT_CONTENT_FIELDS, snapshot_flow_content
diff --git a/products/workflows/backend/tests/api/test_hog_flow_template.py b/products/workflows/backend/tests/api/test_hog_flow_template.py
index d483b095a43b..c1638d667984 100644
--- a/products/workflows/backend/tests/api/test_hog_flow_template.py
+++ b/products/workflows/backend/tests/api/test_hog_flow_template.py
@@ -5,11 +5,11 @@ from posthog.test.base import APIBaseTest
from rest_framework import status
from posthog.cdp.templates.fixtures import template_slack
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.models import Organization, Team, User
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.workflows.backend.models.hog_flow.hog_flow_template import HogFlowTemplate
from products.workflows.backend.templates import clear_template_cache, load_global_templates
diff --git a/products/workflows/backend/tests/api/test_hog_flow_timing_reschedule.py b/products/workflows/backend/tests/api/test_hog_flow_timing_reschedule.py
index ec4c860e9dce..849ad54b5f56 100644
--- a/products/workflows/backend/tests/api/test_hog_flow_timing_reschedule.py
+++ b/products/workflows/backend/tests/api/test_hog_flow_timing_reschedule.py
@@ -3,9 +3,8 @@ from unittest.mock import patch
from parameterized import parameterized
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
-
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.workflows.backend.models.hog_flow.hog_flow import HogFlow
webhook_template = MOCK_NODE_TEMPLATES[0]
diff --git a/products/workflows/backend/tests/api/test_workflow_proposals.py b/products/workflows/backend/tests/api/test_workflow_proposals.py
index 4bed19586ca8..b821b6f5c6d4 100644
--- a/products/workflows/backend/tests/api/test_workflow_proposals.py
+++ b/products/workflows/backend/tests/api/test_workflow_proposals.py
@@ -8,7 +8,6 @@ from unittest.mock import MagicMock, patch
from parameterized import parameterized
-from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.models import Team, User
from posthog.models.activity_logging.activity_log import ActivityLog
from posthog.models.organization import OrganizationMembership
@@ -17,6 +16,7 @@ from posthog.models.utils import generate_random_token_personal, hash_key_value
from products.access_control.backend.facade.user_access_control import UserAccessControl
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
+from products.cdp.backend.templates.hog_function_template import sync_template_to_db
from products.signals.backend.models import SignalScoutConfig
from products.skills.backend.models.skills import LLMSkill
from products.workflows.backend.models.hog_flow.hog_flow import HogFlow