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.

503 B
Raw Blame
import posthog from 'posthog-js'
import type { ErrorInfo } from 'react'

/** `onError` handler for hog-charts trends adapters. Captures the React error
 *  boundary's error/info to PostHog, tagged with the chart `feature` name. */
export function makeChartErrorHandler(feature: string): (error: Error, info: ErrorInfo) => void {
    return (error, info) => {
        posthog.captureException(error, {
            feature,
            componentStack: info.componentStack ?? undefined,
        })
    }
}