: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: hook up provisioning_welcome Customer.io template (#58820)
Matt Brooker2fe611026b17
diff --git a/posthog/email.py b/posthog/email.pyindex f58624d8c43b..127c274d94f9 100644--- a/posthog/email.py+++ b/posthog/email.py@@ -119,6 +119,7 @@ CUSTOMER_IO_TEMPLATE_ID_MAP = {"conversation_restore": "63","proxy_provisioned": "64","delegation_invite": "66",+ "provisioning_welcome": "67",}diff --git a/posthog/test/test_email.py b/posthog/test/test_email.pyindex 51eef25d57b6..e3495e791381 100644--- a/posthog/test/test_email.py+++ b/posthog/test/test_email.py@@ -322,3 +322,52 @@ class TestEmail(BaseTest):# Raw email should remain unchangedself.assertEqual(message.to[0]["raw_email"], "[email protected]")++ def test_all_http_templates_are_registered_in_customer_io_map(self) -> None:+ # Every EmailMessage(use_http=True, template_name="X", ...) call in+ # production code under posthog/ needs "X" in CUSTOMER_IO_TEMPLATE_ID_MAP.+ # The Customer.io HTTP sender raises "Unknown template name" if it+ # isn't, and the Celery task wrapper swallows the exception via+ # capture_exception. Without this test, a new transactional email+ # added with a forgotten map entry sends zero emails and surfaces+ # nothing user-visible.+ import ast+ from pathlib import Path++ import posthog as posthog_pkg++ posthog_root = Path(posthog_pkg.__file__).parent+ sources = sorted(+ p+ for p in posthog_root.rglob("*.py")+ if "/test/" not in str(p) and "/tests/" not in str(p) and not p.name.startswith("test_")+ )++ missing: dict[str, str] = {} # template_name -> first source path that uses it+ for source_path in sources:+ try:+ tree = ast.parse(source_path.read_text())+ except SyntaxError:+ continue+ for node in ast.walk(tree):+ if not isinstance(node, ast.Call):+ continue+ if not (isinstance(node.func, ast.Name) and node.func.id == "EmailMessage"):+ continue+ kwargs = {kw.arg: kw.value for kw in node.keywords if kw.arg is not None}+ use_http = kwargs.get("use_http")+ if not (isinstance(use_http, ast.Constant) and use_http.value is True):+ continue+ template_name = kwargs.get("template_name")+ if isinstance(template_name, ast.Constant) and isinstance(template_name.value, str):+ if template_name.value not in CUSTOMER_IO_TEMPLATE_ID_MAP:+ missing.setdefault(template_name.value, str(source_path.relative_to(posthog_root.parent)))++ self.assertEqual(+ missing,+ {},+ "These template_name values use use_http=True in production code but are missing "+ "from CUSTOMER_IO_TEMPLATE_ID_MAP in posthog/email.py. Add a map entry pointing to "+ "the Customer.io transactional message ID, otherwise the sender will raise "+ "'Unknown template name' at runtime and capture_exception will swallow it.",+ )