@elmohq/cli 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +961 -1000
- package/package.json +10 -7
- package/dist/telemetry.js +0 -67
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elmohq/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"marketing",
|
|
@@ -28,19 +28,22 @@
|
|
|
28
28
|
],
|
|
29
29
|
"type": "module",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@clack/prompts": "^1.5.
|
|
31
|
+
"@clack/prompts": "^1.5.1",
|
|
32
32
|
"commander": "^15.0.0",
|
|
33
33
|
"dotenv": "17.4.2",
|
|
34
34
|
"picocolors": "^1.1.1",
|
|
35
|
-
"posthog-node": "^5.
|
|
36
|
-
"semver": "^7.8.
|
|
35
|
+
"posthog-node": "^5.36.4",
|
|
36
|
+
"semver": "^7.8.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^25.9.
|
|
39
|
+
"@types/node": "^25.9.2",
|
|
40
40
|
"@types/semver": "^7.7.1",
|
|
41
|
-
"
|
|
41
|
+
"rolldown": "^1.1.0",
|
|
42
|
+
"typescript": "^6.0.3",
|
|
43
|
+
"@workspace/config": "0.2.13"
|
|
42
44
|
},
|
|
43
45
|
"scripts": {
|
|
44
|
-
"build": "
|
|
46
|
+
"build": "node scripts/build.mjs",
|
|
47
|
+
"check-types": "tsc -p tsconfig.json"
|
|
45
48
|
}
|
|
46
49
|
}
|
package/dist/telemetry.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { parse } from "dotenv";
|
|
4
|
-
import { PostHog } from "posthog-node";
|
|
5
|
-
const POSTHOG_PUBLIC_KEY = "phc_Jhx9LnI9cTDFHpQmpOzJSDTW127qD9pFU65KRnYym6z";
|
|
6
|
-
const POSTHOG_HOST = "https://us.i.posthog.com";
|
|
7
|
-
function envDisabled() {
|
|
8
|
-
return Boolean(process.env.DISABLE_TELEMETRY);
|
|
9
|
-
}
|
|
10
|
-
async function readEnvKey(configDir, key) {
|
|
11
|
-
try {
|
|
12
|
-
const contents = await fs.readFile(path.join(configDir, ".env"), "utf8");
|
|
13
|
-
return parse(contents)[key];
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
async function isTelemetryDisabled(configDir) {
|
|
20
|
-
if (envDisabled())
|
|
21
|
-
return true;
|
|
22
|
-
return Boolean(await readEnvKey(configDir, "DISABLE_TELEMETRY"));
|
|
23
|
-
}
|
|
24
|
-
export async function trackCliEvent(configDir, eventName, properties, personProperties) {
|
|
25
|
-
if (await isTelemetryDisabled(configDir))
|
|
26
|
-
return;
|
|
27
|
-
const distinctId = await readEnvKey(configDir, "DEPLOYMENT_ID");
|
|
28
|
-
if (!distinctId)
|
|
29
|
-
return;
|
|
30
|
-
try {
|
|
31
|
-
const client = new PostHog(POSTHOG_PUBLIC_KEY, { host: POSTHOG_HOST });
|
|
32
|
-
client.capture({
|
|
33
|
-
distinctId,
|
|
34
|
-
event: eventName,
|
|
35
|
-
properties,
|
|
36
|
-
...(personProperties ? { $set: personProperties } : {}),
|
|
37
|
-
});
|
|
38
|
-
await client.shutdown();
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
// Telemetry should never block the CLI
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Newsletter signup is an explicit user action with clear intent, so it
|
|
45
|
-
// fires even when anonymous telemetry is disabled. When telemetry is on the
|
|
46
|
-
// event is keyed off the deployment UUID and the email is attached as a
|
|
47
|
-
// person property — same identity as the rest of the CLI events. When
|
|
48
|
-
// telemetry is off the event is keyed off the email itself, so it is never
|
|
49
|
-
// linked back to the anonymous deployment UUID.
|
|
50
|
-
export async function submitNewsletterSignup(configDir, email) {
|
|
51
|
-
try {
|
|
52
|
-
const disabled = await isTelemetryDisabled(configDir);
|
|
53
|
-
const deploymentId = disabled ? null : await readEnvKey(configDir, "DEPLOYMENT_ID");
|
|
54
|
-
const distinctId = deploymentId ?? email;
|
|
55
|
-
const client = new PostHog(POSTHOG_PUBLIC_KEY, { host: POSTHOG_HOST });
|
|
56
|
-
client.capture({
|
|
57
|
-
distinctId,
|
|
58
|
-
event: "newsletter_signup",
|
|
59
|
-
properties: { source: "cli_init" },
|
|
60
|
-
...{ $set: { $email: email, wants_updates: true } },
|
|
61
|
-
});
|
|
62
|
-
await client.shutdown();
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
// Newsletter signup should never block the CLI
|
|
66
|
-
}
|
|
67
|
-
}
|