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.

fix(signals): attribute automatic pr closure dismissals (#121881)

Georgiy Tarasov8b4ab330711d
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.md
index eff08de2d0bc..a4c2299f3589 100644
--- a/docs/internal/signals-pr-lifecycle.md
+++ b/docs/internal/signals-pr-lifecycle.md
@@ -5,6 +5,8 @@ At least one merged PR resolves the report; otherwise all closed PRs suppress it
PR-driven resolutions emit `signal_report_status_changed` with `resolution_reason=pr_merged`, including when attaching an already-merged PR completes a report. `dismissal_reason` remains reserved for feedback supplied with the transition. Outcome queries should prefer `resolution_reason` and fall back to `dismissal_reason`; a missing reason alone does not imply that no PR merged.
+PR-driven dismissals emit `dismissal_cause=pr_closed_without_merge` when all linked implementation PRs are closed without a merge. This also covers reconciliation after attaching an already-closed PR. Dismissal queries should prefer `dismissal_cause` and fall back to `dismissal_reason`, which remains the caller's feedback. The cause identifies automatic reconciliation, not who closed the PR or why they closed it.
+
A person can resolve a report by recording a manual implementation or a useful finding that needs no action. Feedback from the state API, Slack, PR closures, report merges, refunds, and plan rollups saves its verdict so the activity log distinguishes resolutions from dismissals even after later state changes. Feedback predating recorded verdicts uses a neutral activity label.
The `no_action_needed` reason requires a resolved state. It leaves the report resolved, cancels its open follow-up checks, and is excluded from fixed outcomes in inbox ranking. Manual resolution closes an open implementation PR; the resulting GitHub close event preserves the resolved report status.
diff --git a/products/signals/backend/receivers.py b/products/signals/backend/receivers.py
index a74e8c3bd494..92b05fe43e93 100644
--- a/products/signals/backend/receivers.py
+++ b/products/signals/backend/receivers.py
@@ -957,8 +957,11 @@ def capture_status_change_analytics(
# Snapshot now — the instance may be mutated again before the commit callback runs.
properties = _status_change_properties(instance, prior_status, pending_reason=pending_reason)
# PR reconciliation supplies a known outcome without creating caller-provided dismissal feedback.
- if instance.status == SignalReport.Status.RESOLVED and getattr(instance, "_status_from_pr_state", False):
- properties["resolution_reason"] = "pr_merged"
+ if getattr(instance, "_status_from_pr_state", False):
+ if instance.status == SignalReport.Status.RESOLVED:
+ properties["resolution_reason"] = "pr_merged"
+ elif instance.status == SignalReport.Status.SUPPRESSED:
+ properties["dismissal_cause"] = "pr_closed_without_merge"
report_id = str(instance.id)
new_status = instance.status
team = instance.team
diff --git a/products/signals/backend/test/test_status_change_telemetry.py b/products/signals/backend/test/test_status_change_telemetry.py
index 1e7691dd7b04..637f1117dc4a 100644
--- a/products/signals/backend/test/test_status_change_telemetry.py
+++ b/products/signals/backend/test/test_status_change_telemetry.py
@@ -53,6 +53,7 @@ class TestCaptureStatusChangeAnalytics(BaseTest):
assert kwargs["properties"]["signal_count"] == 3
assert kwargs["properties"]["total_weight"] == 2.5
assert kwargs["properties"].get("resolution_reason") is None
+ assert kwargs["properties"].get("dismissal_cause") is None
@parameterized.expand(
[
diff --git a/products/tasks/backend/tests/test_webhooks.py b/products/tasks/backend/tests/test_webhooks.py
index 320272763046..66d5ee8f4186 100644
--- a/products/tasks/backend/tests/test_webhooks.py
+++ b/products/tasks/backend/tests/test_webhooks.py
@@ -1316,6 +1316,7 @@ class TestGitHubPRWebhookResolvesSignalReports(TestCase):
if relationship == "implementation":
assert len(status_events) == 1
assert status_events[0].get("resolution_reason") == ("pr_merged" if merged else None)
+ assert status_events[0].get("dismissal_cause") == (None if merged else "pr_closed_without_merge")
assert status_events[0]["dismissal_reason"] is None
else:
assert status_events == []