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.

1.3 KB
Raw Blame
export type GetHelpAction = () => void

/**
 * Where people without in-app support end up: self-hosted instances, the toolbar, the exporter.
 * The docs page lists the channels open to each plan; posthog.com/support sells the support product.
 */
export function openSupportOptions(utmCampaign: string = 'error-toast'): void {
    // `noopener` because window.open, unlike an <a target="_blank">, leaves window.opener reachable
    // by the opened page.
    window.open(
        `https://posthog.com/docs/support-options?utm_medium=in-product&utm_campaign=${utmCampaign}`,
        '_blank',
        'noopener'
    )
}

let getHelpAction: GetHelpAction = openSupportOptions

/**
 * Replaces what the error toast's "Get help" button does. The app registers the in-product support
 * form in `bootApp()`; bundles without one (toolbar, exporter) keep the docs fallback.
 * A seam rather than a direct call because `supportLogic` already imports the toast module, so
 * reaching back into it from here would close a cycle.
 */
export function setGetHelpAction(action: GetHelpAction): void {
    getHelpAction = action
}

/** Restores the docs fallback. Test-only: keeps a registered action from leaking across tests. */
export function resetGetHelpAction(): void {
    getHelpAction = openSupportOptions
}

export function getHelp(): void {
    getHelpAction()
}