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.

681 B
Raw Blame
export type FeedbackSessionKind = 'conversation' | 'task'

/** Appends the session and trace ids to a support ticket body so support can find the run. */
export function appendTicketMetadata(
    body: string,
    { sessionId, sessionKind, traceId }: { sessionId: string; sessionKind: FeedbackSessionKind; traceId: string | null }
): string {
    const trimmedBody = body.trim()
    if (!trimmedBody) {
        return ''
    }
    const idLabel = sessionKind === 'task' ? 'Task ID' : 'Conversation ID'
    const metadataLines = [`${idLabel}: ${sessionId}`, traceId ? `Trace ID: ${traceId}` : null].filter(Boolean)
    return `${trimmedBody}\n\n----\n${metadataLines.join('\n')}`
}