mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
chore(cli): switched analytics to use fetch instead of posthog-node
This commit is contained in:
@@ -62,7 +62,6 @@
|
|||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
"jsonc-parser": "^3.3.1",
|
"jsonc-parser": "^3.3.1",
|
||||||
"picocolors": "^1.1.1",
|
"picocolors": "^1.1.1",
|
||||||
"posthog-node": "^5.6.0",
|
|
||||||
"trpc-cli": "^0.10.2",
|
"trpc-cli": "^0.10.2",
|
||||||
"ts-morph": "^26.0.0",
|
"ts-morph": "^26.0.0",
|
||||||
"zod": "^4.0.14"
|
"zod": "^4.0.14"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PostHog } from "posthog-node";
|
|
||||||
import type { ProjectConfig } from "../types";
|
import type { ProjectConfig } from "../types";
|
||||||
import { getLatestCLIVersion } from "./get-latest-cli-version";
|
import { getLatestCLIVersion } from "./get-latest-cli-version";
|
||||||
import { isTelemetryEnabled } from "./telemetry";
|
import { isTelemetryEnabled } from "./telemetry";
|
||||||
@@ -7,35 +6,30 @@ const POSTHOG_API_KEY = process.env.POSTHOG_API_KEY || "";
|
|||||||
const POSTHOG_HOST = process.env.POSTHOG_HOST;
|
const POSTHOG_HOST = process.env.POSTHOG_HOST;
|
||||||
|
|
||||||
export async function trackProjectCreation(config: ProjectConfig) {
|
export async function trackProjectCreation(config: ProjectConfig) {
|
||||||
const posthog = new PostHog(POSTHOG_API_KEY, {
|
if (!isTelemetryEnabled()) return;
|
||||||
host: POSTHOG_HOST,
|
|
||||||
flushAt: 1,
|
const sessionId = `cli_${crypto.randomUUID().replace(/-/g, "")}`;
|
||||||
flushInterval: 0,
|
// biome-ignore lint/correctness/noUnusedVariables: `projectName`, `projectDir`, and `relativePath` are not used in the event properties
|
||||||
privacyMode: true,
|
const { projectName, projectDir, relativePath, ...safeConfig } = config;
|
||||||
disableGeoip: true,
|
|
||||||
disabled: !isTelemetryEnabled(),
|
const payload = {
|
||||||
});
|
api_key: POSTHOG_API_KEY,
|
||||||
|
event: "project_created",
|
||||||
|
properties: {
|
||||||
|
...safeConfig,
|
||||||
|
cli_version: getLatestCLIVersion(),
|
||||||
|
node_version: process.version,
|
||||||
|
platform: process.platform,
|
||||||
|
$ip: null,
|
||||||
|
},
|
||||||
|
distinct_id: sessionId,
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const sessionId = `cli_${crypto.randomUUID().replace(/-/g, "")}`;
|
await fetch(`${POSTHOG_HOST}/capture`, {
|
||||||
|
method: "POST",
|
||||||
// biome-ignore lint/correctness/noUnusedVariables: `projectName`, `projectDir`, and `relativePath` are not used in the event properties
|
headers: { "Content-Type": "application/json" },
|
||||||
const { projectName, projectDir, relativePath, ...safeConfig } = config;
|
body: JSON.stringify(payload),
|
||||||
|
|
||||||
posthog.capture({
|
|
||||||
distinctId: sessionId,
|
|
||||||
event: "project_created",
|
|
||||||
properties: {
|
|
||||||
...safeConfig,
|
|
||||||
cli_version: getLatestCLIVersion(),
|
|
||||||
node_version: process.version,
|
|
||||||
platform: process.platform,
|
|
||||||
$ip: null,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
} catch (_error) {
|
} catch (_error) {}
|
||||||
// consola.debug("Analytics tracking failed:", error);
|
|
||||||
} finally {
|
|
||||||
await posthog.shutdown();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
3
bun.lock
3
bun.lock
@@ -28,7 +28,6 @@
|
|||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
"jsonc-parser": "^3.3.1",
|
"jsonc-parser": "^3.3.1",
|
||||||
"picocolors": "^1.1.1",
|
"picocolors": "^1.1.1",
|
||||||
"posthog-node": "^5.6.0",
|
|
||||||
"trpc-cli": "^0.10.2",
|
"trpc-cli": "^0.10.2",
|
||||||
"ts-morph": "^26.0.0",
|
"ts-morph": "^26.0.0",
|
||||||
"zod": "^4.0.14",
|
"zod": "^4.0.14",
|
||||||
@@ -2115,8 +2114,6 @@
|
|||||||
|
|
||||||
"posthog-js": ["posthog-js@1.258.5", "", { "dependencies": { "core-js": "^3.38.1", "fflate": "^0.4.8", "preact": "^10.19.3", "web-vitals": "^4.2.4" }, "peerDependencies": { "@rrweb/types": "2.0.0-alpha.17", "rrweb-snapshot": "2.0.0-alpha.17" }, "optionalPeers": ["@rrweb/types", "rrweb-snapshot"] }, "sha512-Tx6CzS8MsGAQGPrQth5TbkGxGQgAY01SktNW773/KDmVOWiRVZq/WQF/MRJRiuFxJ7qjethZQi3aBWfWKdr1RA=="],
|
"posthog-js": ["posthog-js@1.258.5", "", { "dependencies": { "core-js": "^3.38.1", "fflate": "^0.4.8", "preact": "^10.19.3", "web-vitals": "^4.2.4" }, "peerDependencies": { "@rrweb/types": "2.0.0-alpha.17", "rrweb-snapshot": "2.0.0-alpha.17" }, "optionalPeers": ["@rrweb/types", "rrweb-snapshot"] }, "sha512-Tx6CzS8MsGAQGPrQth5TbkGxGQgAY01SktNW773/KDmVOWiRVZq/WQF/MRJRiuFxJ7qjethZQi3aBWfWKdr1RA=="],
|
||||||
|
|
||||||
"posthog-node": ["posthog-node@5.6.0", "", {}, "sha512-MVXxKmqAYp2cPBrN1YMhnhYsJYIu6yc6wumbHz1dbo67wZBf2WtMm67Uh+4VCrp07049qierWlxQqz1W5zGDeg=="],
|
|
||||||
|
|
||||||
"preact": ["preact@10.27.0", "", {}, "sha512-/DTYoB6mwwgPytiqQTh/7SFRL98ZdiD8Sk8zIUVOxtwq4oWcwrcd1uno9fE/zZmUaUrFNYzbH14CPebOz9tZQw=="],
|
"preact": ["preact@10.27.0", "", {}, "sha512-/DTYoB6mwwgPytiqQTh/7SFRL98ZdiD8Sk8zIUVOxtwq4oWcwrcd1uno9fE/zZmUaUrFNYzbH14CPebOz9tZQw=="],
|
||||||
|
|
||||||
"prelude-ls": ["prelude-ls@1.2.1", "", {}, "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g=="],
|
"prelude-ls": ["prelude-ls@1.2.1", "", {}, "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g=="],
|
||||||
|
|||||||
Reference in New Issue
Block a user