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.

2.4 KB
Raw Blame
import { OnboardingComponentsContext, createInstallation } from 'scenes/onboarding/shared/OnboardingDocsContentWrapper'

import { StepDefinition } from '../steps'

interface LibraryDocsOptions {
    title: string
    guidance: string
    docsLink: string
    code?: string
    language?: string
}

const createLibraryDocsSteps =
    (options: LibraryDocsOptions) =>
    (ctx: OnboardingComponentsContext): StepDefinition[] => {
        const { CodeBlock, Markdown, dedent } = ctx

        return [
            {
                title: options.title,
                badge: 'required',
                content: (
                    <>
                        <Markdown>
                            {dedent`
                                ${options.guidance}

                                [Open the SDK documentation](${options.docsLink}) for installation and configuration details.
                            `}
                        </Markdown>
                        {options.code && options.language ? (
                            <CodeBlock language={options.language} code={dedent(options.code)} />
                        ) : null}
                    </>
                ),
            },
        ]
    }

export const JavaErrorTrackingInstallation = createInstallation(
    createLibraryDocsSteps({
        title: 'Capture Java exceptions',
        guidance:
            'The Java server SDK supports manual exception capture. It does not install an uncaught-exception handler, so call `captureException` from your application or framework error handler.',
        docsLink: 'https://posthog.com/docs/libraries/java#request-context',
        language: 'java',
        code: 'posthog.captureException(error);',
    })
)

export const ConvexErrorTrackingInstallation = createInstallation(
    createLibraryDocsSteps({
        title: 'Capture Convex exceptions',
        guidance:
            "Configure Convex's first-party PostHog Error Tracking destination to capture uncaught exceptions automatically. Convex exception reporting currently requires a Convex Pro plan. Use `captureException` for handled errors that need custom properties.",
        docsLink: 'https://posthog.com/docs/libraries/convex#6-capture-exceptions-with-custom-properties',
        language: 'typescript',
        code: `await posthog.captureException(ctx, {
    error,
    distinctId: userId,
    additionalProperties: { flow: "checkout" },
})`,
    })
)