: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { match } from 'ts-pattern'
import { ActivityChange } from 'lib/components/ActivityLog/humanizeActivity'
import { ExperimentHoldoutType } from '~/types'
type AllowedHoldoutFields = Pick<ExperimentHoldoutType, 'name' | 'description' | 'filters'>
export const getHoldoutChangeDescription = (holdoutChange: ActivityChange): string =>
match(holdoutChange.field as keyof AllowedHoldoutFields)
.with('name', () => {
return 'updated experiment holdout name:'
})
.with('description', () => {
return 'updated experiment holdout description:'
})
.with('filters', () => {
return 'updated experiment holdout filters:'
})
.otherwise(() => {
if (!holdoutChange.field) {
return 'updated experiment holdout'
}
// Fallback for unhandled fields - ensures all activity is visible
const fieldName = holdoutChange.field.replace(/_/g, ' ')
return match(holdoutChange.action)
.with('created', () => `added ${fieldName} to`)
.with('deleted', () => `removed ${fieldName} from`)
.with('changed', () => `updated ${fieldName} for`)
.otherwise(() => `modified ${fieldName} for`)
})