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.

957 B
Raw Blame
import type { RunEnvironmentEnumApi, WizardRunApi } from '../generated/api.schemas'

export function wizardEventProperties(
    projectId: number | string | null,
    environment: RunEnvironmentEnumApi
): Record<string, string | null> {
    return {
        event_source: 'wizard_ui',
        project_id: projectId === null ? null : String(projectId),
        environment,
        run_surface: environment,
    }
}

export function wizardRunEventProperties(run: WizardRunApi): Record<string, string | null> {
    return {
        ...wizardEventProperties(run.team_id, run.environment),
        wizard_run_id: run.id,
        ...(run.environment === 'cloud' ? { task_run_id: run.id } : {}),
        program_id: run.program.id,
        wizard_version: run.program.wizard_version,
        version: run.program.wizard_version,
        command: run.program.command[0] ?? 'default',
        workspace_type: run.workspace.type,
        status: run.status,
    }
}