feat(omo-codex): wire Codex SessionStart telemetry for DAU/WAU/MAU
Adds a new Codex plugin component `telemetry` that emits a single omo_codex_daily_active event (reason: session_start) from every Codex SessionStart hook, with the same UTC-day deduplication, hashed installation identifier, and four-flag opt-out as the install-time event. Previously omo-codex telemetry only fired on install_completed, so DAU/WAU/MAU under-reported real Codex usage. - New plugin component packages/omo-codex/plugin/components/telemetry/ mirrors the rules/comment-checker/lsp pattern: own src/, tsc build, vitest tests, package.json (posthog-node dep), hooks/hooks.json. - src/codex-hook.ts wraps createPluginPostHog().trackActive(..., "session_start") with safeShutdown so Codex session startup never blocks on telemetry. - Plugin root hooks.json + workspaces register the new component alongside rules and ultrawork on SessionStart. - Aggregate test expectations updated to include the telemetry directory. - cross-package-equivalence.test.ts pins product-identity constants and shouldDisablePostHog behavior to stay byte-equivalent between the CLI installer (src/telemetry/) and the plugin runtime (plugin/components/telemetry/src/), so the two PostHog sources never drift on event name, distinct_id base, dedup file path, or opt-out flags. - PostHogActivityReason union in the CLI-side posthog.ts gains "session_start" so future CLI paths can emit the same reason without a type break.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
export const PRODUCT_NAME = "omo-codex";
|
||||
export const PACKAGE_NAME = "@oh-my-opencode/omo-codex";
|
||||
export const CACHE_DIR_NAME = "omo-codex";
|
||||
export const EVENT_NAME = "omo_codex_daily_active";
|
||||
export const LEGACY_PARENT_PACKAGE = "oh-my-opencode";
|
||||
export const DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
|
||||
export const DEFAULT_POSTHOG_API_KEY = "phc_CFJhj5HyvA62QPhvyaUCtaq23aUfznnijg5VaaGkNk74";
|
||||
|
||||
type ComponentPackageManifest = { readonly version?: string };
|
||||
|
||||
function isComponentPackageManifest(value: unknown): value is ComponentPackageManifest {
|
||||
return value !== null && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
|
||||
function readComponentVersionFromManifest(): string {
|
||||
try {
|
||||
const manifestUrl = new URL("../package.json", import.meta.url);
|
||||
const manifestText = readFileSync(manifestUrl, "utf-8");
|
||||
const parsed: unknown = JSON.parse(manifestText);
|
||||
if (isComponentPackageManifest(parsed) && typeof parsed.version === "string") {
|
||||
return parsed.version;
|
||||
}
|
||||
} catch {
|
||||
return "0.0.0";
|
||||
}
|
||||
return "0.0.0";
|
||||
}
|
||||
|
||||
const COMPONENT_VERSION_CACHE = readComponentVersionFromManifest();
|
||||
|
||||
export function getComponentVersion(): string {
|
||||
return COMPONENT_VERSION_CACHE;
|
||||
}
|
||||
Reference in New Issue
Block a user