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(experiments): Describe value-only metric edits in the activity log (#78789)

Juraj Majerik43ebd096c63e
diff --git a/frontend/src/scenes/experiments/activity-descriptions/metricChangeDescriptions.test.tsx b/frontend/src/scenes/experiments/activity-descriptions/metricChangeDescriptions.test.tsx
index 0c65f131f77e..d3d714b04bef 100644
--- a/frontend/src/scenes/experiments/activity-descriptions/metricChangeDescriptions.test.tsx
+++ b/frontend/src/scenes/experiments/activity-descriptions/metricChangeDescriptions.test.tsx
@@ -182,6 +182,18 @@ describe('metric-change-descriptions', () => {
after: { conversion_window: 14, conversion_window_unit: FunnelConversionWindowTimeUnit.Day },
expectedText: 'set the conversion window to 14 day',
},
+ {
+ name: 'detects conversion window value change',
+ before: { conversion_window: 7, conversion_window_unit: FunnelConversionWindowTimeUnit.Day },
+ after: { conversion_window: 14, conversion_window_unit: FunnelConversionWindowTimeUnit.Day },
+ expectedText: 'set the conversion window to 14 day',
+ },
+ {
+ name: 'detects conversion window unit change',
+ before: { conversion_window: 7, conversion_window_unit: FunnelConversionWindowTimeUnit.Day },
+ after: { conversion_window: 7, conversion_window_unit: FunnelConversionWindowTimeUnit.Hour },
+ expectedText: 'set the conversion window to 7 hour',
+ },
])('$name', (testCase) => {
const before: ExperimentMetric[] = [createBaseMeanMetric({ fingerprint: 'old', ...testCase.before })]
const after: ExperimentMetric[] = [createBaseMeanMetric({ fingerprint: 'new', ...testCase.after })]
@@ -197,6 +209,30 @@ describe('metric-change-descriptions', () => {
})
})
+ describe('unrecognized changes fallback', () => {
+ it('renders a generic sentence when the fingerprint changed but no branch matched', () => {
+ const before: ExperimentMetric[] = [
+ createBaseMeanMetric({
+ fingerprint: 'old',
+ lower_bound_percentile: 0.01,
+ upper_bound_percentile: 0.99,
+ }),
+ ]
+ const after: ExperimentMetric[] = [
+ createBaseMeanMetric({
+ fingerprint: 'new',
+ lower_bound_percentile: 0.05,
+ upper_bound_percentile: 0.95,
+ }),
+ ]
+
+ const result = getMetricChanges(before, after)
+ const { container } = render(<>{result}</>)
+ expect(container.textContent).toContain('changed the metric')
+ expect(container.textContent).toContain('Test Metric')
+ })
+ })
+
describe('funnel-specific changes', () => {
it('detects funnel order type change', () => {
const before: ExperimentMetric[] = [
diff --git a/frontend/src/scenes/experiments/activity-descriptions/metricChangeDescriptions.tsx b/frontend/src/scenes/experiments/activity-descriptions/metricChangeDescriptions.tsx
index 014945d42dc1..7250c02e1450 100644
--- a/frontend/src/scenes/experiments/activity-descriptions/metricChangeDescriptions.tsx
+++ b/frontend/src/scenes/experiments/activity-descriptions/metricChangeDescriptions.tsx
@@ -164,8 +164,11 @@ export const getMetricChanges = (
if (metricBefore.conversion_window && !metricAfter.conversion_window) {
changes.push('set the conversion window to the experiment duration')
}
- // check if conversion window was added (set to time window)
- if (!metricBefore.conversion_window && metricAfter.conversion_window) {
+ if (
+ metricAfter.conversion_window &&
+ (metricBefore.conversion_window !== metricAfter.conversion_window ||
+ metricBefore.conversion_window_unit !== metricAfter.conversion_window_unit)
+ ) {
changes.push(
`set the conversion window to ${metricAfter.conversion_window} ${metricAfter.conversion_window_unit}`
)
@@ -210,6 +213,14 @@ export const getMetricChanges = (
changes.push(ratioChanges)
}
+ if (changes.length === 0) {
+ return (
+ <span>
+ changed the metric <LemonTag>{metricBefore.name || getDefaultMetricTitle(metricBefore)}</LemonTag>
+ </span>
+ )
+ }
+
/**
* let's add a way to identify which metric was changed
* appending the name or series identifier to the last change