Captures, flushes, and manages telemetry events via PostHog, handling disabled mode and error reporting.
// Source: https://github.com/mperkins0155/crm | License: MIT | Copyright 2026 Comp AI
// Provided via justclaw.it.com; keep this notice with the code.
import "@crm/env/load";
import { PostHog } from "posthog-node";
import { type Properties, permitted } from "./allowlist";
import { telemetryDisabled } from "./disabled";
import { daysSince, readInstall } from "./install";
import { POSTHOG_HOST, POSTHOG_KEY } from "./project";
import { commitSha } from "./version";
const FLUSH_TIMEOUT_MS = 3_000;
type CaptureMessage = Parameters<PostHog["capture"]>[0];
type Debug = (message: string) => void;
let debug: Debug = () => {};
export function onTelemetryProblem(sink: Debug | null): void {
debug = sink ?? (() => {});
}
let client: PostHog | null = null;
let built = false;
let failures = 0;
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key