Skip to content

Commit 34c4849

Browse files
authored
fix(experiments): create a shared retention metric (#42462)
1 parent 09292a9 commit 34c4849

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ee/clickhouse/views/experiment_saved_metrics.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ExperimentMeanMetric,
1313
ExperimentMetricType,
1414
ExperimentRatioMetric,
15+
ExperimentRetentionMetric,
1516
ExperimentTrendsQuery,
1617
)
1718

@@ -88,8 +89,12 @@ def validate_query(self, value):
8889
ExperimentFunnelMetric(**metric_query)
8990
elif metric_query["metric_type"] == ExperimentMetricType.RATIO:
9091
ExperimentRatioMetric(**metric_query)
92+
elif metric_query["metric_type"] == ExperimentMetricType.RETENTION:
93+
ExperimentRetentionMetric(**metric_query)
9194
else:
92-
raise ValidationError("ExperimentMetric metric_type must be 'mean', 'funnel', or 'ratio'")
95+
raise ValidationError(
96+
"ExperimentMetric metric_type must be 'mean', 'funnel', 'ratio', or 'retention'"
97+
)
9398
elif metric_query["kind"] == "ExperimentTrendsQuery":
9499
ExperimentTrendsQuery(**metric_query)
95100
elif metric_query["kind"] == "ExperimentFunnelsQuery":

ee/clickhouse/views/test/test_experiment_saved_metrics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ def test_create_saved_metric_with_experiment_metric_invalid_metric_type(self):
259259
)
260260

261261
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
262-
self.assertIn("ExperimentMetric metric_type must be 'mean', 'funnel', or 'ratio'", response.json()["detail"])
262+
self.assertIn(
263+
"ExperimentMetric metric_type must be 'mean', 'funnel', 'ratio', or 'retention'", response.json()["detail"]
264+
)
263265

264266
def test_create_saved_metric_with_experiment_metric_ratio(self):
265267
response = self.client.post(

0 commit comments

Comments
 (0)