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.9 KB
Raw Blame
import posthog from 'posthog-js'

import { ExportedData } from '~/exporter/types'

declare global {
    // Monaco Editor environment configuration
    // See: https://github.com/microsoft/monaco-editor/blob/main/docs/integrate-esm.md
    interface MonacoEnvironment {
        getWorker?(moduleId: string, label: string): Worker
        getWorkerUrl?(moduleId: string, label: string): string
    }

    // eslint-disable-next-line no-var
    var MonacoEnvironment: MonacoEnvironment | undefined

    // Build-time constant injected by esbuild's `define` (see
    // frontend/toolbar-config.mjs). Empty string in posthog/posthog's own
    // builds; set to e.g. `https://us-assets.i.posthog.com/static/1.358.0/`
    // when the toolbar is built by posthog-js's release workflow as part of a
    // self-contained, version-pinned bundle. Used by the toolbar to load
    // sibling files (currently just toolbar.css) from the same versioned URL.
    const __POSTHOG_TOOLBAR_PUBLIC_PATH__: string

    // Build-time constant injected into the toolbar loader (frontend/src/toolbar/floating/loader.ts):
    // the basename of the toolbar app's ESM entry inside dist/toolbar/ — hashed in prod
    // builds (e.g. `toolbar-app-ABC123.js`), plain `toolbar-app.js` in dev. See
    // finalizeToolbarBuild in frontend/toolbar-config.mjs.
    const __POSTHOG_TOOLBAR_APP_ENTRY__: string

    interface Window {
        JS_URL?: string
        JS_POSTHOG_API_KEY?: string
        JS_POSTHOG_HOST?: string
        JS_POSTHOG_UI_HOST?: string
        JS_POSTHOG_SELF_CAPTURE?: boolean
        JS_POSTHOG_IDENTITY_DISTINCT_ID?: string
        JS_POSTHOG_IDENTITY_HASH?: string
        JS_POSTHOG_IDENTITY_CLAIMS?: Record<string, { value: string; hash: string; expires_at: number }>
        JS_CAPTURE_TIME_TO_SEE_DATA?: boolean
        posthog?: posthog
        ESBUILD_LOAD_SCRIPT: (name) => void
        ESBUILD_LOAD_CHUNKS: (name) => void
        ESBUILD_LOADED_CHUNKS: Set<string>
        /** Set by the HTML loader script: resolves when the boot stylesheet has loaded (true) or failed (false). */
        ESBUILD_CSS_READY?: Promise<boolean>
        /** Chunk hashes per lazy entry; the full map arrives from a hashed static file after boot. */
        ESBUILD_CHUNK_MAP: Record<string, string[]>
        /** Scenes requested before the chunk map loaded; null once it has loaded or failed. */
        ESBUILD_PENDING_CHUNK_SCENES: string[] | null
        POSTHOG_EXPORTED_DATA: ExportedData
        POSTHOG_USER_IDENTITY_WITH_FLAGS?: {
            distinctID?: string
            isIdentifiedID?: boolean
            featureFlags?: Record<string, boolean | string> | null
        }
        IMPERSONATED_SESSION?: boolean
        POSTHOG_JS_UUID_VERSION?: string

        // These are used to track global errors across the app.
        // Can be used to determine whether we should show warnings in different places in the app.
        POSTHOG_GLOBAL_ERRORS?: Record<string, boolean>
    }
}