ChemPal Documentation - v1.15.1
    Preparing search index...

    Module helpers/analytics

    Functions

    trackEvent

    Sends one event to PostHog's capture endpoint, identified by getFingerprintDistinctId and tagged with the current getSessionId. No-ops (before touching session storage) when canSendAnalytics says not to. Text params are truncated to PARAM_VALUE_LIMIT; numeric params pass through as numbers. Never throws.

    trackInstallOrUpgrade

    Reports a fresh install as extension_installed or a version change as extension_upgraded, the latter carrying both the old and new version. Driven by the service worker's chrome.runtime.onInstalled listener.

    trackRenderError

    Reports a React render-boundary crash to PostHog as a $exception event, shaped like posthog-js's own captureException output ($exception_list with parsed stack frames, $exception_level), so it lands in PostHog's Error Tracking product with a stack-trace viewer, per-frame file/line, and automatic issue grouping. error_name/error_message are also kept as flat properties alongside the structured list, for any existing dashboard built on those two fields; error_cause is added the same way when error.cause is set, even though the full cause chain is also walked into $exception_list (see buildExceptionList) — this flat field makes the immediate cause filterable/visible without opening the stack trace.

    Type Aliases - Helpers

    AnalyticsValue

    A JSON-safe value a PostHog event property may hold — the primitives trackEvent always accepted, plus arrays/objects for structured properties like $exception_list.

    Variables - Helpers

    CAPTURE_PATH

    PostHog single-event capture path, appended to the configured host.

    PARAM_VALUE_LIMIT

    Self-imposed cap on the length of a text property value, from config.json (analytics.paramValueLimit). Not a PostHog limit (its ceiling is ~1MB) — a privacy guard bounding how much of a search term or error message can leave the device.

    COMPONENT_STACK_LIMIT

    Self-imposed cap on how much of a React component stack rides along in a $exception event, from config.json (analytics.componentStackLimit). Unlike JS stack frames (capped by count via STACKTRACE_FRAME_LIMIT), a component stack is one unstructured string, so it's bounded by length.