: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 { MakeLogicType, actions, afterMount, kea, key, listeners, path, props, reducers } from 'kea'
import { loaders } from 'kea-loaders'
import { EvaluationRun } from './evaluations/types'
import { queryEvaluationRuns } from './utils'
export interface GenerationEvaluationRunsLogicProps {
traceId: string
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface generationEvaluationRunsLogicValues {
generationEvaluationRuns: EvaluationRun[]
generationEvaluationRunsLoading: boolean
isForceRefresh: boolean
selectedEvaluationId: string | null
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface generationEvaluationRunsLogicActions {
loadGenerationEvaluationRuns: () => any
loadGenerationEvaluationRunsFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadGenerationEvaluationRunsSuccess: (
generationEvaluationRuns: EvaluationRun[],
payload?: any
) => {
generationEvaluationRuns: EvaluationRun[]
payload?: any
}
refreshGenerationEvaluationRuns: () => {
value: true
}
setSelectedEvaluationId: (evaluationId: string | null) => {
evaluationId: string | null
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface generationEvaluationRunsLogicMeta {
key: string
}
export type generationEvaluationRunsLogicType = MakeLogicType<
generationEvaluationRunsLogicValues,
generationEvaluationRunsLogicActions,
GenerationEvaluationRunsLogicProps,
generationEvaluationRunsLogicMeta
>
export const generationEvaluationRunsLogic = kea<generationEvaluationRunsLogicType>([
path(['products', 'ai_observability', 'frontend', 'generationEvaluationRunsLogic']),
props({} as GenerationEvaluationRunsLogicProps),
key((props) => `trace-${props.traceId}`),
actions({
refreshGenerationEvaluationRuns: true,
setSelectedEvaluationId: (evaluationId: string | null) => ({ evaluationId }),
}),
loaders(({ props, values }) => ({
generationEvaluationRuns: [
[] as EvaluationRun[],
{
loadGenerationEvaluationRuns: async () => {
try {
return await queryEvaluationRuns({
traceId: props.traceId,
forceRefresh: values.isForceRefresh,
})
} catch (error) {
console.error('Failed to load generation evaluation runs:', error)
return []
}
},
},
],
})),
reducers({
isForceRefresh: [
false,
{
refreshGenerationEvaluationRuns: () => true,
loadGenerationEvaluationRunsSuccess: () => false,
loadGenerationEvaluationRunsFailure: () => false,
},
],
selectedEvaluationId: [
null as string | null,
{
setSelectedEvaluationId: (_, { evaluationId }) => evaluationId,
},
],
}),
listeners(({ actions }) => ({
refreshGenerationEvaluationRuns: () => {
actions.loadGenerationEvaluationRuns()
},
})),
afterMount(({ actions }) => {
actions.loadGenerationEvaluationRuns()
}),
])