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(signals): snapshot resolve clicks in inbox ranking labels (#92455)

posthog[bot]970a6cc4b77a
diff --git a/products/signals/dags/inbox_ranking/dataset/dag.py b/products/signals/dags/inbox_ranking/dataset/dag.py
index 36d2d7614fac..1938c0f80dd9 100644
--- a/products/signals/dags/inbox_ranking/dataset/dag.py
+++ b/products/signals/dags/inbox_ranking/dataset/dag.py
@@ -92,7 +92,7 @@ from products.signals.dags.inbox_ranking.dataset.queries import (
valid_report_uuids,
)
-FEATURE_SCHEMA_VERSION = 4
+FEATURE_SCHEMA_VERSION = 5
# Statuses a report can be authored straight into and still be in the inbox (`create_scout_report`
# and `create_custom_agent_ready_report`), which is how a report reaches the spine without a
@@ -242,6 +242,8 @@ LABEL_FIELDS: list[tuple[str, pa.DataType]] = [
("first_reviewer_added_at", _TIMESTAMP),
("reviewer_remove_count", pa.int32()),
("first_reviewer_removed_at", _TIMESTAMP),
+ ("resolve_click_count", pa.int32()),
+ ("first_resolve_clicked_at", _TIMESTAMP),
]
_LABELS_FIELDS: list[tuple[str, pa.DataType]] = [
diff --git a/products/signals/dags/inbox_ranking/dataset/queries.py b/products/signals/dags/inbox_ranking/dataset/queries.py
index dd19b325c9f9..6a3c8495423e 100644
--- a/products/signals/dags/inbox_ranking/dataset/queries.py
+++ b/products/signals/dags/inbox_ranking/dataset/queries.py
@@ -300,6 +300,8 @@ ACTIONS_COLUMNS = (
"first_reviewer_added_at",
"reviewer_remove_count",
"first_reviewer_removed_at",
+ "resolve_click_count",
+ "first_resolve_clicked_at",
)
# Bulk action rows carry no report_id and are excluded; bulk dismissals are recovered from the
# server-side status stream instead. minIf misses fill non-nullable datetimes with epoch 0, hence
@@ -309,6 +311,16 @@ ACTIONS_COLUMNS = (
# engagement signal, removing one plausibly means the suggested-reviewer heuristic mis-routed the
# report, which is useful to the policy layer even if never a model head. `click_suggested_reviewer`
# also exists but is deliberately not aggregated: it fires so rarely it carries no signal.
+#
+# `resolve` marks a report done without an inbox PR, so it is a distinct positive outcome the
+# `create_pr` click does not cover. The `*_click*` names keep it apart from the status stream's
+# `first_resolved_at`, which conflates every path a report reaches `resolved`. `restore`
+# (un-dismissing a report) shares this aggregation shape and is a follow-up.
+#
+# Blind spot: a bulk-bar resolve fires one report_id-less event and drops here like every bulk
+# action. Bulk dismissals are recovered from the status stream; bulk resolves are not, because the
+# same `first_resolved_at` conflation rules it out as a substitute. So a head must read
+# `resolve_click_count` = 0 as unknown, not as "the report was never resolved".
ACTIONS_SQL = """
SELECT
toString(properties.report_id) AS report_id,
@@ -321,7 +333,9 @@ SELECT
countIf(toString(properties.action_type) = 'add_suggested_reviewer') AS reviewer_add_count,
nullIf(minIf(timestamp, toString(properties.action_type) = 'add_suggested_reviewer'), fromUnixTimestamp(0)) AS first_reviewer_added_at,
countIf(toString(properties.action_type) = 'remove_suggested_reviewer') AS reviewer_remove_count,
- nullIf(minIf(timestamp, toString(properties.action_type) = 'remove_suggested_reviewer'), fromUnixTimestamp(0)) AS first_reviewer_removed_at
+ nullIf(minIf(timestamp, toString(properties.action_type) = 'remove_suggested_reviewer'), fromUnixTimestamp(0)) AS first_reviewer_removed_at,
+ countIf(toString(properties.action_type) = 'resolve') AS resolve_click_count,
+ nullIf(minIf(timestamp, toString(properties.action_type) = 'resolve'), fromUnixTimestamp(0)) AS first_resolve_clicked_at
FROM events
WHERE event = 'Inbox report action'
AND timestamp >= toDateTime({labels_epoch}) AND timestamp < toDateTime({snapshot_end})
@@ -582,6 +596,8 @@ LABEL_DEFAULTS: dict[str, Any] = {
"first_reviewer_added_at": None,
"reviewer_remove_count": 0,
"first_reviewer_removed_at": None,
+ "resolve_click_count": 0,
+ "first_resolve_clicked_at": None,
}
_TIMESTAMP_LABEL_COLUMNS = frozenset(name for name in LABEL_DEFAULTS if name.endswith("_at"))
diff --git a/products/signals/dags/inbox_ranking/tests/test_dataset.py b/products/signals/dags/inbox_ranking/tests/test_dataset.py
index 19c98e0af710..9687f57ec555 100644
--- a/products/signals/dags/inbox_ranking/tests/test_dataset.py
+++ b/products/signals/dags/inbox_ranking/tests/test_dataset.py
@@ -163,10 +163,10 @@ def test_merge_label_streams_fills_defaults_and_maps_columns():
"impressions": [(UUID_A, T1.replace(tzinfo=None), 5, 2, 3, 1, ["error_tracking"])],
"opens": [(UUID_A.upper(), T2, 4, 2), (UUID_B, T2, 1, 1)],
"actions": [
- ("bogus-id", 1, T1, 1, T1, 1, 1, 1, T1, 1, T1),
+ ("bogus-id", 1, T1, 1, T1, 1, 1, 1, T1, 1, T1, 1, T1),
# Distinct values per column, so a shifted or swapped ACTIONS_SQL/ACTIONS_COLUMNS
# position lands a wrong value in some asserted field below.
- (UUID_B, 5, T1, 0, None, 0, 0, 2, T1, 3, T2),
+ (UUID_B, 5, T1, 0, None, 0, 0, 2, T1, 3, T2, 4, T1),
],
"status_changes": [],
"pr_events": [],
@@ -192,6 +192,8 @@ def test_merge_label_streams_fills_defaults_and_maps_columns():
assert r2["first_reviewer_added_at"] == T1
assert r2["reviewer_remove_count"] == 3
assert r2["first_reviewer_removed_at"] == T2
+ assert r2["resolve_click_count"] == 4
+ assert r2["first_resolve_clicked_at"] == T1
@pytest.mark.parametrize("alias_first", [True, False])