: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 type { z } from 'zod'
import { wrapError } from '@/lib/errors'
import type { ApiPropertyDefinition } from '@/schema/api'
import { PropertyDefinitionUpdateSchema } from '@/schema/tool-inputs'
import type { Context, ToolBase } from '@/tools/types'
const schema = PropertyDefinitionUpdateSchema
type Params = z.infer<typeof schema>
type Result = ApiPropertyDefinition & { url: string }
export const updatePropertyDefinitionHandler: ToolBase<typeof schema, Result>['handler'] = async (
context: Context,
params: Params
) => {
const projectId = await context.stateManager.getProjectId()
const result = await context.api.projects().updatePropertyDefinition({
projectId,
propertyName: params.propertyName,
type: params.type,
groupTypeIndex: params.groupTypeIndex,
data: params.data,
})
if (!result.success) {
throw wrapError(`Failed to update property definition: ${result.error.message}`, result.error)
}
return {
...result.data,
url: `${context.api.getProjectBaseUrl(projectId)}/data-management/properties/${encodeURIComponent(result.data.id)}`,
}
}
const tool = (): ToolBase<typeof schema, Result> => ({
name: 'property-definition-update',
schema,
handler: updatePropertyDefinitionHandler,
})
export default tool