openclaw/scripts/build-plugin-env.mjs
kumarabhirup aa97489785
👌 IMPROVE: feat(telemetry): add DenchClaw and OpenClaw version tracking
Integrate version tracking for DenchClaw and OpenClaw into the telemetry system. The versions are now read from the package.json and environment variables, and are included in the PostHog client initialization and telemetry events. This enhancement allows for better monitoring and analytics of the versions in use.
2026-03-15 04:33:44 -07:00

25 lines
792 B
JavaScript

import { readFileSync, writeFileSync } from "node:fs";
import { createRequire } from "node:module";
const key = process.env.POSTHOG_KEY || "";
const rootPkg = JSON.parse(readFileSync("package.json", "utf-8"));
const denchclawVersion = rootPkg.version || "";
let openclawVersion = "";
try {
const req = createRequire(import.meta.url);
const oclPkg = req("openclaw/package.json");
openclawVersion = oclPkg.version || "";
} catch { /* openclaw not resolvable at build time */ }
writeFileSync(
"extensions/posthog-analytics/lib/build-env.js",
[
`export const POSTHOG_KEY = ${JSON.stringify(key)};`,
`export const DENCHCLAW_VERSION = ${JSON.stringify(denchclawVersion)};`,
`export const OPENCLAW_VERSION = ${JSON.stringify(openclawVersion)};`,
"",
].join("\n"),
);