: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(signals): strip markdown from the first report email summary (#122051)
Georgiy Tarasov6c6b57daf23a
diff --git a/products/signals/backend/first_report_notification.py b/products/signals/backend/first_report_notification.pyindex 267909ad281b..b06a8be9f156 100644--- a/products/signals/backend/first_report_notification.py+++ b/products/signals/backend/first_report_notification.py@@ -22,12 +22,14 @@ from posthog.transactional_email import (from products.access_control.backend.facade.user_access_control import UserAccessControlfrom products.signals.backend.artefact_schemas import ActionabilityChoice+from products.signals.backend.briefing_reports import SUMMARY_LEAD_LIMIT, summary_leadfrom products.signals.backend.constants import SIGNALS_FIRST_REPORT_EMAIL_TEMPLATE_IDfrom products.signals.backend.models import SignalFirstReportNotification, SignalReportfrom products.signals.backend.report_access import may_read_reportsfrom products.signals.backend.report_content_gates import team_first_report_email_enabledfrom products.signals.backend.report_priority import latest_report_prioritiesfrom products.signals.backend.report_urls import ReportLinkSource, build_report_url+from products.signals.backend.slack_formatting import strip_chart_referencesif TYPE_CHECKING:from django.db.models import QuerySet@@ -111,7 +113,10 @@ def _claim(team_id: int) -> SignalFirstReportNotification | None:"project_id": team_id,"report_id": str(report.id),"report_title": report.title,- "report_summary": Truncator((report.summary or "").strip().split("\n", 1)[0]).chars(320),+ # The email shows plain text, so a chart link keeps only its label.+ "report_summary": Truncator(+ summary_lead(strip_chart_references(report.summary or ""), SUMMARY_LEAD_LIMIT)+ ).chars(320),"report_priority": latest_report_priorities(team_id, [str(report.id)]).get(str(report.id), ""),"report_url": build_report_url(team_id, report.id, ReportLinkSource.FIRST_REPORT_EMAIL),"activation_id": str(notification.id),diff --git a/products/signals/backend/test/test_first_report_notification.py b/products/signals/backend/test/test_first_report_notification.pyindex ca479379e1cd..fa249e0d65cb 100644--- a/products/signals/backend/test/test_first_report_notification.py+++ b/products/signals/backend/test/test_first_report_notification.py@@ -90,6 +90,13 @@ class TestFirstReportNotification(BaseTest):"P1",),("long_summary_without_priority", "x" * 400, "x" * 319 + "…", ""),+ (+ "markdown_summary",+ "Signups **dropped** after the [pricing change](https://example.com/pricing).\n"+ "[The daily signups chart](chart:daily-signups) shows the drop.\n\n## Evidence\nMore details.",+ "Signups dropped after the pricing change. The daily signups chart shows the drop.",+ "P2",+ ),])@time_machine.travel("2026-01-15T12:01:00Z", tick=False)