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.

feat(alerts): include project name in insight alert emails (#68971)

Matt Pua9e11440a855c
diff --git a/posthog/tasks/alerts/utils.py b/posthog/tasks/alerts/utils.py
index 3d87e1114884..01c649357ebe 100644
--- a/posthog/tasks/alerts/utils.py
+++ b/posthog/tasks/alerts/utils.py
@@ -179,6 +179,7 @@ def trigger_alert_hog_functions(alert: AlertConfiguration, properties: dict) ->
props = {
"alert_id": str(alert.id),
"alert_name": alert.name,
+ "project_name": alert.team.name,
"insight_name": alert.insight.name,
"insight_id": alert.insight.short_id,
"state": alert.state,
@@ -218,7 +219,7 @@ def send_notifications_for_breaches(alert: AlertConfiguration, breaches: list[st
"""
email_targets = alert.get_subscribed_users_emails()
if email_targets:
- subject = f"PostHog alert {alert.name} is firing"
+ subject = f"PostHog alert {alert.name} is firing for {alert.team.name}"
campaign_key = f"alert-firing-notification-{idempotency_key}"
insight_url = f"/project/{alert.team.pk}/insights/{alert.insight.short_id}"
alert_url = f"{insight_url}?alert_id={alert.id}"
@@ -232,6 +233,7 @@ def send_notifications_for_breaches(alert: AlertConfiguration, breaches: list[st
"insight_name": alert.insight.name,
"alert_url": alert_url,
"alert_name": alert.name,
+ "project_name": alert.team.name,
},
)
@@ -414,7 +416,7 @@ def disable_invalid_alert(alert: AlertConfiguration, reason: str) -> AlertCheck:
def send_notifications_for_disabled(alert: AlertConfiguration, reason: str, targets: list[str]) -> None:
logger.info("Sending alert disabled notification", alert_id=alert.id, reason=reason)
- subject = f"PostHog alert {alert.name} has been disabled"
+ subject = f"PostHog alert {alert.name} for {alert.team.name} has been disabled"
campaign_key = f"alert-disabled-notification-{alert.id}-{timezone.now().timestamp()}"
insight_url = f"/project/{alert.team.pk}/insights/{alert.insight.short_id}"
alert_url = f"{insight_url}?alert_id={alert.id}"
@@ -428,6 +430,7 @@ def send_notifications_for_disabled(alert: AlertConfiguration, reason: str, targ
"insight_url": insight_url,
"insight_name": alert.insight.name,
"alert_error": reason,
+ "project_name": alert.team.name,
},
)
for target in targets:
diff --git a/posthog/templates/email/alert_check_firing.html b/posthog/templates/email/alert_check_firing.html
index 52b10b504e17..9c9a98e5132b 100644
--- a/posthog/templates/email/alert_check_firing.html
+++ b/posthog/templates/email/alert_check_firing.html
@@ -1,7 +1,7 @@
{% extends "email/base.html" %} {% load posthog_assets %} {% block section %}
<p>
The <a href="{% absolute_uri alert_url %}">{{ alert_name }}</a> alert is firing for <a
- href="{% absolute_uri insight_url %}">{{ insight_name }}</a>:
+ href="{% absolute_uri insight_url %}">{{ insight_name }}</a> in project <strong>{{ project_name }}</strong>:
</p>
<ul>
{% for item in match_descriptions %}
diff --git a/posthog/templates/email/alert_disabled.html b/posthog/templates/email/alert_disabled.html
index d524e24888ef..e8fa5f89f244 100644
--- a/posthog/templates/email/alert_disabled.html
+++ b/posthog/templates/email/alert_disabled.html
@@ -1,7 +1,7 @@
{% extends "email/base.html" %} {% load posthog_assets %} {% block section %}
<p>
The <a href="{% absolute_uri alert_url %}">{{ alert_name }}</a> alert for insight <a
- href="{% absolute_uri insight_url %}">{{ insight_name }}</a> has been <strong>automatically disabled</strong> because its configuration is no longer valid:
+ href="{% absolute_uri insight_url %}">{{ insight_name }}</a> in project <strong>{{ project_name }}</strong> has been <strong>automatically disabled</strong> because its configuration is no longer valid:
</p>
<p><i>{{ alert_error }}</i></p>
<p>