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(error-tracking): gate fingerprint auto-merge behind a global switch (#64218)

Hugues Pouillot24cd65b613f4
diff --git a/posthog/settings/temporal.py b/posthog/settings/temporal.py
index 844d3b71fa4c..5c665dab7590 100644
--- a/posthog/settings/temporal.py
+++ b/posthog/settings/temporal.py
@@ -130,9 +130,11 @@ LOGS_ALERTING_TASK_QUEUE = _set_temporal_task_queue("logs-alerting-task-queue")
RASTERIZATION_TASK_QUEUE = "rasterization-task-queue" # Not collapsed in dev — separate Node.js worker process
# Error tracking
-ERROR_TRACKING_AUTO_MERGE_FINGERPRINT_TEAM_IDS: list[int] = [
- int(team_id) for team_id in get_list(os.getenv("ERROR_TRACKING_AUTO_MERGE_FINGERPRINT_TEAM_IDS", "")) if team_id
-]
+# Global on/off switch for auto-merging close fingerprints into their nearest issue.
+# Off by default; enabled per-deployment (e.g. EU).
+ERROR_TRACKING_AUTO_MERGE_ENABLED: bool = get_from_env(
+ "ERROR_TRACKING_AUTO_MERGE_ENABLED", False, type_cast=str_to_bool
+)
# Signals inbox notification: how long to wait for an auto-started implementation PR before
# notifying anyway, and how often to poll for it.
diff --git a/products/error_tracking/backend/temporal/fingerprint_embedding_result/activities.py b/products/error_tracking/backend/temporal/fingerprint_embedding_result/activities.py
index 212d29cd3333..a02d976521dd 100644
--- a/products/error_tracking/backend/temporal/fingerprint_embedding_result/activities.py
+++ b/products/error_tracking/backend/temporal/fingerprint_embedding_result/activities.py
@@ -218,7 +218,7 @@ def _merge_fingerprint_into_closest_issue(
) -> int:
closest_fingerprint = closest_fingerprints[0] if closest_fingerprints else None
team_id = team.id
- if team_id not in settings.ERROR_TRACKING_AUTO_MERGE_FINGERPRINT_TEAM_IDS or closest_fingerprint is None:
+ if not settings.ERROR_TRACKING_AUTO_MERGE_ENABLED or closest_fingerprint is None:
return 0
if closest_fingerprint.distance >= AUTO_MERGE_DISTANCE_THRESHOLD:
return 0
diff --git a/products/error_tracking/backend/temporal/fingerprint_embedding_result/test/test_fingerprint_embedding_result.py b/products/error_tracking/backend/temporal/fingerprint_embedding_result/test/test_fingerprint_embedding_result.py
index 7447f4c6596e..361c8aacb06b 100644
--- a/products/error_tracking/backend/temporal/fingerprint_embedding_result/test/test_fingerprint_embedding_result.py
+++ b/products/error_tracking/backend/temporal/fingerprint_embedding_result/test/test_fingerprint_embedding_result.py
@@ -207,17 +207,18 @@ class TestFingerprintEmbeddingResultActivity:
assert result.query_duration_ms is not None
assert result.closest_fingerprints == closest_fingerprints
- def test_merge_fingerprint_skips_teams_without_rollout(self) -> None:
- result = _merge_fingerprint_into_closest_issue(
- team=MagicMock(id=1),
- fingerprint="test-fingerprint",
- closest_fingerprints=[SimilarFingerprintDistance(fingerprint="fingerprint-1", distance=0.01)],
- )
+ def test_merge_fingerprint_skips_when_auto_merge_disabled(self) -> None:
+ with override_settings(ERROR_TRACKING_AUTO_MERGE_ENABLED=False):
+ result = _merge_fingerprint_into_closest_issue(
+ team=MagicMock(id=1),
+ fingerprint="test-fingerprint",
+ closest_fingerprints=[SimilarFingerprintDistance(fingerprint="fingerprint-1", distance=0.01)],
+ )
assert result == 0
def test_merge_fingerprint_skips_distances_above_threshold(self) -> None:
- with override_settings(ERROR_TRACKING_AUTO_MERGE_FINGERPRINT_TEAM_IDS=[2]):
+ with override_settings(ERROR_TRACKING_AUTO_MERGE_ENABLED=True):
result = _merge_fingerprint_into_closest_issue(
team=MagicMock(id=2),
fingerprint="test-fingerprint",
@@ -232,7 +233,7 @@ class TestFingerprintEmbeddingResultActivity:
fingerprint_query.filter.return_value.select_related.return_value.order_by.return_value = []
with (
- override_settings(ERROR_TRACKING_AUTO_MERGE_FINGERPRINT_TEAM_IDS=[2]),
+ override_settings(ERROR_TRACKING_AUTO_MERGE_ENABLED=True),
patch(
"products.error_tracking.backend.temporal.fingerprint_embedding_result.activities.ErrorTrackingIssueFingerprintV2.objects.select_for_update",
return_value=fingerprint_query,
@@ -263,7 +264,7 @@ class TestFingerprintEmbeddingResultActivity:
capture_context.__enter__.return_value = capture
with (
- override_settings(ERROR_TRACKING_AUTO_MERGE_FINGERPRINT_TEAM_IDS=[2]),
+ override_settings(ERROR_TRACKING_AUTO_MERGE_ENABLED=True),
patch(
"products.error_tracking.backend.temporal.fingerprint_embedding_result.activities.ErrorTrackingIssueFingerprintV2.objects.select_for_update",
return_value=fingerprint_query,
@@ -312,7 +313,7 @@ class TestMergeFingerprintCrossTeamIsolation(BaseTest):
capture_context.__enter__.return_value = MagicMock()
with (
- override_settings(ERROR_TRACKING_AUTO_MERGE_FINGERPRINT_TEAM_IDS=[self.team.id]),
+ override_settings(ERROR_TRACKING_AUTO_MERGE_ENABLED=True),
patch(
"products.error_tracking.backend.temporal.fingerprint_embedding_result.activities.ph_scoped_capture",
return_value=capture_context,