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): record automatic pr merge resolution outcomes (#121290)

Georgiy Tarasovd49890172a58
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.md
index 4a57f5f5e6e8..15a026ed3937 100644
--- a/docs/internal/signals-pr-lifecycle.md
+++ b/docs/internal/signals-pr-lifecycle.md
@@ -3,6 +3,8 @@
A report completes after all linked implementation PRs are closed or merged.
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.
+
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 feaa67c4553f..a74e8c3bd494 100644
--- a/products/signals/backend/receivers.py
+++ b/products/signals/backend/receivers.py
@@ -956,6 +956,9 @@ 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"
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 e22d5ccc0680..1e7691dd7b04 100644
--- a/products/signals/backend/test/test_status_change_telemetry.py
+++ b/products/signals/backend/test/test_status_change_telemetry.py
@@ -31,7 +31,7 @@ class TestCaptureStatusChangeAnalytics(BaseTest):
@parameterized.expand(
[
("dismiss", SignalReport.Status.READY, SignalReport.Status.SUPPRESSED, {}),
- ("resolve_on_pr_merge", SignalReport.Status.READY, SignalReport.Status.RESOLVED, {}),
+ ("resolve_without_feedback", SignalReport.Status.READY, SignalReport.Status.RESOLVED, {}),
("snooze", SignalReport.Status.READY, SignalReport.Status.POTENTIAL, {"snooze_for": 5}),
]
)
@@ -52,6 +52,7 @@ class TestCaptureStatusChangeAnalytics(BaseTest):
assert kwargs["properties"]["status"] == new_status
assert kwargs["properties"]["signal_count"] == 3
assert kwargs["properties"]["total_weight"] == 2.5
+ assert kwargs["properties"].get("resolution_reason") is None
@parameterized.expand(
[
diff --git a/products/tasks/backend/tests/test_webhooks.py b/products/tasks/backend/tests/test_webhooks.py
index 04486d7ac9a2..320272763046 100644
--- a/products/tasks/backend/tests/test_webhooks.py
+++ b/products/tasks/backend/tests/test_webhooks.py
@@ -1308,6 +1308,17 @@ class TestGitHubPRWebhookResolvesSignalReports(TestCase):
self.report.refresh_from_db()
self.assertEqual(self.report.status, expected_status)
close_task.delay.assert_not_called()
+ status_events = [
+ call.kwargs["properties"]
+ for call in _mock_capture.call_args_list
+ if call.kwargs.get("event") == "signal_report_status_changed"
+ ]
+ 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]["dismissal_reason"] is None
+ else:
+ assert status_events == []
if relationship == "implementation":
assignment = SignalReportAssignment.objects.for_team(self.team.id).filter(report=self.report).first()
self.assertEqual(assignment.actor_kind if assignment else None, actor_kind)