pax8-cta 0.1.0
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/LICENSE +200 -0
- package/README.md +659 -0
- package/demo-data/solutions/ProductQADemo_1_0_0_2_managed.zip +0 -0
- package/dist/commands/analyze.d.ts +28 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +571 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/auth.d.ts +18 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +171 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/config.d.ts +34 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +299 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/demo.d.ts +33 -0
- package/dist/commands/demo.d.ts.map +1 -0
- package/dist/commands/demo.js +362 -0
- package/dist/commands/demo.js.map +1 -0
- package/dist/commands/deploy.d.ts +18 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +1186 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/deployments/helpers.d.ts +68 -0
- package/dist/commands/deployments/helpers.d.ts.map +1 -0
- package/dist/commands/deployments/helpers.js +414 -0
- package/dist/commands/deployments/helpers.js.map +1 -0
- package/dist/commands/deployments/index.d.ts +24 -0
- package/dist/commands/deployments/index.d.ts.map +1 -0
- package/dist/commands/deployments/index.js +47 -0
- package/dist/commands/deployments/index.js.map +1 -0
- package/dist/commands/deployments/list.d.ts +18 -0
- package/dist/commands/deployments/list.d.ts.map +1 -0
- package/dist/commands/deployments/list.js +97 -0
- package/dist/commands/deployments/list.js.map +1 -0
- package/dist/commands/deployments/show.d.ts +18 -0
- package/dist/commands/deployments/show.d.ts.map +1 -0
- package/dist/commands/deployments/show.js +81 -0
- package/dist/commands/deployments/show.js.map +1 -0
- package/dist/commands/deployments/undo.d.ts +18 -0
- package/dist/commands/deployments/undo.d.ts.map +1 -0
- package/dist/commands/deployments/undo.js +295 -0
- package/dist/commands/deployments/undo.js.map +1 -0
- package/dist/commands/export.d.ts +18 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +133 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +18 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +129 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/init-config.d.ts +26 -0
- package/dist/commands/init-config.d.ts.map +1 -0
- package/dist/commands/init-config.js +123 -0
- package/dist/commands/init-config.js.map +1 -0
- package/dist/commands/init-validation.d.ts +47 -0
- package/dist/commands/init-validation.d.ts.map +1 -0
- package/dist/commands/init-validation.js +339 -0
- package/dist/commands/init-validation.js.map +1 -0
- package/dist/commands/init-wizard.d.ts +25 -0
- package/dist/commands/init-wizard.d.ts.map +1 -0
- package/dist/commands/init-wizard.js +433 -0
- package/dist/commands/init-wizard.js.map +1 -0
- package/dist/commands/init.d.ts +18 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +46 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/resolve-url.d.ts +18 -0
- package/dist/commands/resolve-url.d.ts.map +1 -0
- package/dist/commands/resolve-url.js +126 -0
- package/dist/commands/resolve-url.js.map +1 -0
- package/dist/commands/setup.d.ts +18 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +239 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/solutions/drift-analysis.d.ts +73 -0
- package/dist/commands/solutions/drift-analysis.d.ts.map +1 -0
- package/dist/commands/solutions/drift-analysis.js +416 -0
- package/dist/commands/solutions/drift-analysis.js.map +1 -0
- package/dist/commands/solutions/drift.d.ts +32 -0
- package/dist/commands/solutions/drift.d.ts.map +1 -0
- package/dist/commands/solutions/drift.js +641 -0
- package/dist/commands/solutions/drift.js.map +1 -0
- package/dist/commands/solutions/fix-planner.d.ts +48 -0
- package/dist/commands/solutions/fix-planner.d.ts.map +1 -0
- package/dist/commands/solutions/fix-planner.js +43 -0
- package/dist/commands/solutions/fix-planner.js.map +1 -0
- package/dist/commands/solutions/helpers.d.ts +35 -0
- package/dist/commands/solutions/helpers.d.ts.map +1 -0
- package/dist/commands/solutions/helpers.js +54 -0
- package/dist/commands/solutions/helpers.js.map +1 -0
- package/dist/commands/solutions/index.d.ts +18 -0
- package/dist/commands/solutions/index.d.ts.map +1 -0
- package/dist/commands/solutions/index.js +30 -0
- package/dist/commands/solutions/index.js.map +1 -0
- package/dist/commands/solutions/list.d.ts +18 -0
- package/dist/commands/solutions/list.d.ts.map +1 -0
- package/dist/commands/solutions/list.js +174 -0
- package/dist/commands/solutions/list.js.map +1 -0
- package/dist/commands/solutions/remove.d.ts +18 -0
- package/dist/commands/solutions/remove.d.ts.map +1 -0
- package/dist/commands/solutions/remove.js +137 -0
- package/dist/commands/solutions/remove.js.map +1 -0
- package/dist/commands/solutions/risk-calculator.d.ts +33 -0
- package/dist/commands/solutions/risk-calculator.d.ts.map +1 -0
- package/dist/commands/solutions/risk-calculator.js +79 -0
- package/dist/commands/solutions/risk-calculator.js.map +1 -0
- package/dist/commands/solutions/show.d.ts +18 -0
- package/dist/commands/solutions/show.d.ts.map +1 -0
- package/dist/commands/solutions/show.js +165 -0
- package/dist/commands/solutions/show.js.map +1 -0
- package/dist/commands/status.d.ts +18 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +573 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/telemetry.d.ts +18 -0
- package/dist/commands/telemetry.d.ts.map +1 -0
- package/dist/commands/telemetry.js +85 -0
- package/dist/commands/telemetry.js.map +1 -0
- package/dist/commands/tenants/health.d.ts +18 -0
- package/dist/commands/tenants/health.d.ts.map +1 -0
- package/dist/commands/tenants/health.js +172 -0
- package/dist/commands/tenants/health.js.map +1 -0
- package/dist/commands/tenants/helpers.d.ts +44 -0
- package/dist/commands/tenants/helpers.d.ts.map +1 -0
- package/dist/commands/tenants/helpers.js +72 -0
- package/dist/commands/tenants/helpers.js.map +1 -0
- package/dist/commands/tenants/index.d.ts +19 -0
- package/dist/commands/tenants/index.d.ts.map +1 -0
- package/dist/commands/tenants/index.js +39 -0
- package/dist/commands/tenants/index.js.map +1 -0
- package/dist/commands/tenants/inspect.d.ts +18 -0
- package/dist/commands/tenants/inspect.d.ts.map +1 -0
- package/dist/commands/tenants/inspect.js +176 -0
- package/dist/commands/tenants/inspect.js.map +1 -0
- package/dist/commands/tenants/list.d.ts +18 -0
- package/dist/commands/tenants/list.d.ts.map +1 -0
- package/dist/commands/tenants/list.js +144 -0
- package/dist/commands/tenants/list.js.map +1 -0
- package/dist/commands/tenants/manage.d.ts +20 -0
- package/dist/commands/tenants/manage.d.ts.map +1 -0
- package/dist/commands/tenants/manage.js +206 -0
- package/dist/commands/tenants/manage.js.map +1 -0
- package/dist/commands/tenants/show.d.ts +18 -0
- package/dist/commands/tenants/show.d.ts.map +1 -0
- package/dist/commands/tenants/show.js +191 -0
- package/dist/commands/tenants/show.js.map +1 -0
- package/dist/commands/validate.d.ts +18 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +536 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +258 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/auth.d.ts +51 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +153 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/banner.d.ts +19 -0
- package/dist/lib/banner.d.ts.map +1 -0
- package/dist/lib/banner.js +78 -0
- package/dist/lib/banner.js.map +1 -0
- package/dist/lib/command-wrapper.d.ts +56 -0
- package/dist/lib/command-wrapper.d.ts.map +1 -0
- package/dist/lib/command-wrapper.js +71 -0
- package/dist/lib/command-wrapper.js.map +1 -0
- package/dist/lib/credentials.d.ts +56 -0
- package/dist/lib/credentials.d.ts.map +1 -0
- package/dist/lib/credentials.js +146 -0
- package/dist/lib/credentials.js.map +1 -0
- package/dist/lib/demo-banner.d.ts +15 -0
- package/dist/lib/demo-banner.d.ts.map +1 -0
- package/dist/lib/demo-banner.js +33 -0
- package/dist/lib/demo-banner.js.map +1 -0
- package/dist/lib/error-handler.d.ts +51 -0
- package/dist/lib/error-handler.d.ts.map +1 -0
- package/dist/lib/error-handler.js +458 -0
- package/dist/lib/error-handler.js.map +1 -0
- package/dist/lib/errors.d.ts +61 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +168 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/formatters.d.ts +55 -0
- package/dist/lib/formatters.d.ts.map +1 -0
- package/dist/lib/formatters.js +163 -0
- package/dist/lib/formatters.js.map +1 -0
- package/dist/lib/graph-client.d.ts +74 -0
- package/dist/lib/graph-client.d.ts.map +1 -0
- package/dist/lib/graph-client.js +231 -0
- package/dist/lib/graph-client.js.map +1 -0
- package/dist/lib/input.d.ts +22 -0
- package/dist/lib/input.d.ts.map +1 -0
- package/dist/lib/input.js +120 -0
- package/dist/lib/input.js.map +1 -0
- package/dist/lib/interactive-wizard.d.ts +26 -0
- package/dist/lib/interactive-wizard.d.ts.map +1 -0
- package/dist/lib/interactive-wizard.js +550 -0
- package/dist/lib/interactive-wizard.js.map +1 -0
- package/dist/lib/oss-surface.d.ts +21 -0
- package/dist/lib/oss-surface.d.ts.map +1 -0
- package/dist/lib/oss-surface.js +29 -0
- package/dist/lib/oss-surface.js.map +1 -0
- package/dist/lib/output.d.ts +74 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +156 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/picker.d.ts +75 -0
- package/dist/lib/picker.d.ts.map +1 -0
- package/dist/lib/picker.js +115 -0
- package/dist/lib/picker.js.map +1 -0
- package/dist/lib/repl.d.ts +19 -0
- package/dist/lib/repl.d.ts.map +1 -0
- package/dist/lib/repl.js +158 -0
- package/dist/lib/repl.js.map +1 -0
- package/dist/lib/spinner.d.ts +41 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/dist/lib/spinner.js +126 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/telemetry.d.ts +96 -0
- package/dist/lib/telemetry.d.ts.map +1 -0
- package/dist/lib/telemetry.js +367 -0
- package/dist/lib/telemetry.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REPL-safe spinner wrapper.
|
|
3
|
+
*
|
|
4
|
+
* ora's spinner animation corrupts readline's terminal state,
|
|
5
|
+
* breaking subsequent prompts in the REPL. This module provides
|
|
6
|
+
* the same API but falls back to plain console.log when stdin
|
|
7
|
+
* is being shared with readline (i.e. in REPL / interactive mode).
|
|
8
|
+
*
|
|
9
|
+
* In quiet mode (--quiet flag or PAX8_CTA_QUIET=1) all spinners are
|
|
10
|
+
* replaced with a no-op implementation that produces zero output.
|
|
11
|
+
*/
|
|
12
|
+
export declare function setReplMode(enabled: boolean): void;
|
|
13
|
+
/**
|
|
14
|
+
* Returns true when the process is running in quiet mode.
|
|
15
|
+
*
|
|
16
|
+
* Quiet mode is active when either:
|
|
17
|
+
* - `--quiet` appears anywhere in the raw argv (catches global flag before
|
|
18
|
+
* Commander has finished parsing subcommands), or
|
|
19
|
+
* - the environment variable `PAX8_CTA_QUIET` is set to "1" or "true"
|
|
20
|
+
* (allows CI pipelines to opt in without modifying every invocation).
|
|
21
|
+
*/
|
|
22
|
+
export declare function isQuietMode(): boolean;
|
|
23
|
+
export interface Spinner {
|
|
24
|
+
text: string;
|
|
25
|
+
start(text?: string): Spinner;
|
|
26
|
+
stop(): Spinner;
|
|
27
|
+
succeed(text?: string): Spinner;
|
|
28
|
+
fail(text?: string): Spinner;
|
|
29
|
+
warn(text?: string): Spinner;
|
|
30
|
+
info(text?: string): Spinner;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Drop-in replacement for `ora(text).start()`.
|
|
34
|
+
*
|
|
35
|
+
* - In quiet mode returns a no-op spinner that produces zero output.
|
|
36
|
+
* - In REPL mode returns a plain-text spinner that won't corrupt readline.
|
|
37
|
+
* - Otherwise returns a real ora spinner with animation.
|
|
38
|
+
*/
|
|
39
|
+
export { createSpinner as spinner };
|
|
40
|
+
export declare function createSpinner(text?: string): Spinner;
|
|
41
|
+
//# sourceMappingURL=spinner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../src/lib/spinner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAElD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAMrC;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,IAAI,IAAI,OAAO,CAAC;IAChB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AA2ED;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,CAAC;AAEpC,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAQpD"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REPL-safe spinner wrapper.
|
|
3
|
+
*
|
|
4
|
+
* ora's spinner animation corrupts readline's terminal state,
|
|
5
|
+
* breaking subsequent prompts in the REPL. This module provides
|
|
6
|
+
* the same API but falls back to plain console.log when stdin
|
|
7
|
+
* is being shared with readline (i.e. in REPL / interactive mode).
|
|
8
|
+
*
|
|
9
|
+
* In quiet mode (--quiet flag or PAX8_CTA_QUIET=1) all spinners are
|
|
10
|
+
* replaced with a no-op implementation that produces zero output.
|
|
11
|
+
*/
|
|
12
|
+
import ora from "ora";
|
|
13
|
+
/** True when running inside the interactive REPL. */
|
|
14
|
+
let replMode = false;
|
|
15
|
+
export function setReplMode(enabled) {
|
|
16
|
+
replMode = enabled;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns true when the process is running in quiet mode.
|
|
20
|
+
*
|
|
21
|
+
* Quiet mode is active when either:
|
|
22
|
+
* - `--quiet` appears anywhere in the raw argv (catches global flag before
|
|
23
|
+
* Commander has finished parsing subcommands), or
|
|
24
|
+
* - the environment variable `PAX8_CTA_QUIET` is set to "1" or "true"
|
|
25
|
+
* (allows CI pipelines to opt in without modifying every invocation).
|
|
26
|
+
*/
|
|
27
|
+
export function isQuietMode() {
|
|
28
|
+
return (process.argv.includes("--quiet") ||
|
|
29
|
+
process.env.PAX8_CTA_QUIET === "1" ||
|
|
30
|
+
process.env.PAX8_CTA_QUIET === "true");
|
|
31
|
+
}
|
|
32
|
+
function createPlainSpinner(text) {
|
|
33
|
+
let currentText = text ?? "";
|
|
34
|
+
const self = {
|
|
35
|
+
get text() {
|
|
36
|
+
return currentText;
|
|
37
|
+
},
|
|
38
|
+
set text(t) {
|
|
39
|
+
currentText = t;
|
|
40
|
+
},
|
|
41
|
+
start(t) {
|
|
42
|
+
if (t)
|
|
43
|
+
currentText = t;
|
|
44
|
+
return self;
|
|
45
|
+
},
|
|
46
|
+
stop() {
|
|
47
|
+
return self;
|
|
48
|
+
},
|
|
49
|
+
succeed(t) {
|
|
50
|
+
console.error(`✔ ${t ?? currentText}`);
|
|
51
|
+
return self;
|
|
52
|
+
},
|
|
53
|
+
fail(t) {
|
|
54
|
+
console.error(`✖ ${t ?? currentText}`);
|
|
55
|
+
return self;
|
|
56
|
+
},
|
|
57
|
+
warn(t) {
|
|
58
|
+
console.error(`⚠ ${t ?? currentText}`);
|
|
59
|
+
return self;
|
|
60
|
+
},
|
|
61
|
+
info(t) {
|
|
62
|
+
console.error(`ℹ ${t ?? currentText}`);
|
|
63
|
+
return self;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
return self;
|
|
67
|
+
}
|
|
68
|
+
/** No-op spinner used in quiet mode — produces zero output on any method call. */
|
|
69
|
+
function createNoOpSpinner(text) {
|
|
70
|
+
let currentText = text ?? "";
|
|
71
|
+
const self = {
|
|
72
|
+
get text() {
|
|
73
|
+
return currentText;
|
|
74
|
+
},
|
|
75
|
+
set text(t) {
|
|
76
|
+
currentText = t;
|
|
77
|
+
},
|
|
78
|
+
start(t) {
|
|
79
|
+
if (t)
|
|
80
|
+
currentText = t;
|
|
81
|
+
return self;
|
|
82
|
+
},
|
|
83
|
+
stop() {
|
|
84
|
+
return self;
|
|
85
|
+
},
|
|
86
|
+
succeed(t) {
|
|
87
|
+
if (t)
|
|
88
|
+
currentText = t;
|
|
89
|
+
return self;
|
|
90
|
+
},
|
|
91
|
+
fail(t) {
|
|
92
|
+
if (t)
|
|
93
|
+
currentText = t;
|
|
94
|
+
return self;
|
|
95
|
+
},
|
|
96
|
+
warn(t) {
|
|
97
|
+
if (t)
|
|
98
|
+
currentText = t;
|
|
99
|
+
return self;
|
|
100
|
+
},
|
|
101
|
+
info(t) {
|
|
102
|
+
if (t)
|
|
103
|
+
currentText = t;
|
|
104
|
+
return self;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
return self;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Drop-in replacement for `ora(text).start()`.
|
|
111
|
+
*
|
|
112
|
+
* - In quiet mode returns a no-op spinner that produces zero output.
|
|
113
|
+
* - In REPL mode returns a plain-text spinner that won't corrupt readline.
|
|
114
|
+
* - Otherwise returns a real ora spinner with animation.
|
|
115
|
+
*/
|
|
116
|
+
export { createSpinner as spinner };
|
|
117
|
+
export function createSpinner(text) {
|
|
118
|
+
if (isQuietMode()) {
|
|
119
|
+
return createNoOpSpinner(text);
|
|
120
|
+
}
|
|
121
|
+
if (replMode) {
|
|
122
|
+
return createPlainSpinner(text);
|
|
123
|
+
}
|
|
124
|
+
return ora({ text, stream: process.stderr });
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../src/lib/spinner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,qDAAqD;AACrD,IAAI,QAAQ,GAAG,KAAK,CAAC;AAErB,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,QAAQ,GAAG,OAAO,CAAC;AACrB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,CACL,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,GAAG;QAClC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,CACtC,CAAC;AACJ,CAAC;AAYD,SAAS,kBAAkB,CAAC,IAAa;IACvC,IAAI,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,MAAM,IAAI,GAAY;QACpB,IAAI,IAAI;YACN,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,IAAI,IAAI,CAAC,CAAS;YAChB,WAAW,GAAG,CAAC,CAAC;QAClB,CAAC;QACD,KAAK,CAAC,CAAU;YACd,IAAI,CAAC;gBAAE,WAAW,GAAG,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAU;YAChB,OAAO,CAA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C;QACD,IAAI,CAAC,CAAU;YACb,IAAI,CAAC;gBAAE,WAAW,GAAG,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,CAAC;AAEpC,MAAM,UAAU,aAAa,CAAC,IAAa;IACzC,IAAI,WAAW,EAAE,EAAE,CAAC;QAClB,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAuB,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Pax8, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Check if telemetry is enabled
|
|
18
|
+
*/
|
|
19
|
+
export declare function isTelemetryEnabled(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Enable telemetry
|
|
22
|
+
*/
|
|
23
|
+
export declare function enableTelemetry(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Disable telemetry
|
|
26
|
+
*/
|
|
27
|
+
export declare function disableTelemetry(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Check if first run notice has been shown
|
|
30
|
+
*/
|
|
31
|
+
export declare function hasShownFirstRunNotice(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Mark first run notice as shown
|
|
34
|
+
*/
|
|
35
|
+
export declare function markFirstRunNoticeShown(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Filesystem path to the Conf-managed telemetry preferences file.
|
|
38
|
+
* Used by `pax8-cta config` to surface where preferences live.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getTelemetryConfigPath(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Stored telemetry preference (ignores env-var overrides).
|
|
43
|
+
*
|
|
44
|
+
* `isTelemetryEnabled()` factors in env-var opt-outs (DO_NOT_TRACK,
|
|
45
|
+
* PAX8_CTA_TELEMETRY_DISABLED, CI, missing PostHog key). This raw getter
|
|
46
|
+
* lets `config` distinguish a user's saved choice from a runtime override.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getStoredTelemetryPreference(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Reason telemetry is currently disabled, if it is.
|
|
51
|
+
*
|
|
52
|
+
* Mirrors the precedence inside `isTelemetryEnabled()`:
|
|
53
|
+
* 1. PAX8_CTA_TELEMETRY_DISABLED env var
|
|
54
|
+
* 2. DO_NOT_TRACK env var
|
|
55
|
+
* 3. CI env var
|
|
56
|
+
* 4. Missing PostHog key
|
|
57
|
+
* 5. User preference (config file)
|
|
58
|
+
*
|
|
59
|
+
* Returns `null` when telemetry is enabled.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getTelemetryDisabledSource(): "env" | "do-not-track" | "ci" | "no-key" | "config" | null;
|
|
62
|
+
/**
|
|
63
|
+
* Shutdown telemetry client gracefully
|
|
64
|
+
*/
|
|
65
|
+
export declare function shutdownTelemetry(): Promise<void>;
|
|
66
|
+
export type TelemetryEvent = "cli_command" | "cli_error" | "cli_not_found" | "cli_first_run";
|
|
67
|
+
export interface CommandContext {
|
|
68
|
+
command: string;
|
|
69
|
+
subcommand?: string;
|
|
70
|
+
flags?: string[];
|
|
71
|
+
success: boolean;
|
|
72
|
+
durationMs: number;
|
|
73
|
+
errorType?: string;
|
|
74
|
+
demoMode?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Track a CLI command execution
|
|
78
|
+
*/
|
|
79
|
+
export declare function trackCommand(ctx: CommandContext): void;
|
|
80
|
+
/**
|
|
81
|
+
* Track a "not found" error (like a 404)
|
|
82
|
+
*/
|
|
83
|
+
export declare function trackNotFound(resource: "tenant" | "deployment" | "agent" | "command", query: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* Track an error (without sensitive details)
|
|
86
|
+
*/
|
|
87
|
+
export declare function trackError(errorType: string, command?: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Track first run
|
|
90
|
+
*/
|
|
91
|
+
export declare function trackFirstRun(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Get the first run notice text
|
|
94
|
+
*/
|
|
95
|
+
export declare function getFirstRunNotice(): string;
|
|
96
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/lib/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAqFH;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CA8B5C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAMvC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAMhD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAM9C;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,IAAI,OAAO,CAMtD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,IACtC,KAAK,GACL,cAAc,GACd,IAAI,GACJ,QAAQ,GACR,QAAQ,GACR,IAAI,CAYP;AA2CD;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAcvD;AAMD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,WAAW,GAAG,eAAe,GAAG,eAAe,CAAC;AAE7F,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CA6BtD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,EACvD,KAAK,EAAE,MAAM,GACZ,IAAI,CA0BN;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAsBpE;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAqBpC;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAU1C"}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Pax8, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import Conf from "conf";
|
|
17
|
+
import { createHash } from "crypto";
|
|
18
|
+
import { hostname } from "os";
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Configuration
|
|
21
|
+
// ============================================================================
|
|
22
|
+
const CLI_VERSION = "0.1.0";
|
|
23
|
+
// PostHog project key - safe to be public, only allows event ingestion
|
|
24
|
+
const POSTHOG_KEY = process.env.PAX8_CTA_POSTHOG_KEY || process.env.NEXT_PUBLIC_POSTHOG_KEY || "";
|
|
25
|
+
const POSTHOG_HOST = process.env.PAX8_CTA_POSTHOG_HOST || "https://us.i.posthog.com";
|
|
26
|
+
// Config store for telemetry preferences
|
|
27
|
+
const config = new Conf({
|
|
28
|
+
projectName: "pax8-cta-cli",
|
|
29
|
+
defaults: {
|
|
30
|
+
telemetryEnabled: false, // Opt-in: disabled by default, enable with `pax8-cta telemetry on`
|
|
31
|
+
firstRunShown: false,
|
|
32
|
+
machineId: "",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Machine ID (anonymous)
|
|
37
|
+
// ============================================================================
|
|
38
|
+
/**
|
|
39
|
+
* Get or create an anonymous machine ID.
|
|
40
|
+
* This is a one-way hash - cannot be reversed to identify the machine.
|
|
41
|
+
*/
|
|
42
|
+
function getMachineId() {
|
|
43
|
+
let machineId = config.get("machineId");
|
|
44
|
+
if (!machineId) {
|
|
45
|
+
// Create anonymous hash from hostname + random salt
|
|
46
|
+
const salt = Math.random().toString(36).substring(2);
|
|
47
|
+
const raw = `${hostname()}-${salt}-${Date.now()}`;
|
|
48
|
+
machineId = createHash("sha256").update(raw).digest("hex").substring(0, 16);
|
|
49
|
+
config.set("machineId", machineId);
|
|
50
|
+
}
|
|
51
|
+
return machineId;
|
|
52
|
+
}
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Telemetry State
|
|
55
|
+
// ============================================================================
|
|
56
|
+
/**
|
|
57
|
+
* Check if telemetry is enabled
|
|
58
|
+
*/
|
|
59
|
+
export function isTelemetryEnabled() {
|
|
60
|
+
// Environment variable override (highest priority)
|
|
61
|
+
if (process.env.PAX8_CTA_TELEMETRY_DISABLED === "1" ||
|
|
62
|
+
process.env.PAX8_CTA_TELEMETRY_DISABLED === "true") {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// Respect DO_NOT_TRACK convention (https://consoledonottrack.com)
|
|
66
|
+
if (process.env.DO_NOT_TRACK === "1") {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
// CI environments - disable by default
|
|
70
|
+
if (process.env.CI === "true" || process.env.CI === "1") {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
// No PostHog key configured
|
|
74
|
+
if (!POSTHOG_KEY) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
// User preference
|
|
78
|
+
try {
|
|
79
|
+
return config.get("telemetryEnabled");
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Enable telemetry
|
|
87
|
+
*/
|
|
88
|
+
export function enableTelemetry() {
|
|
89
|
+
try {
|
|
90
|
+
config.set("telemetryEnabled", true);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// Non-fatal: telemetry preference persistence should not break CLI.
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Disable telemetry
|
|
98
|
+
*/
|
|
99
|
+
export function disableTelemetry() {
|
|
100
|
+
try {
|
|
101
|
+
config.set("telemetryEnabled", false);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// Non-fatal: telemetry preference persistence should not break CLI.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Check if first run notice has been shown
|
|
109
|
+
*/
|
|
110
|
+
export function hasShownFirstRunNotice() {
|
|
111
|
+
try {
|
|
112
|
+
return config.get("firstRunShown");
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Mark first run notice as shown
|
|
120
|
+
*/
|
|
121
|
+
export function markFirstRunNoticeShown() {
|
|
122
|
+
try {
|
|
123
|
+
config.set("firstRunShown", true);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// Non-fatal: telemetry preference persistence should not break CLI.
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Filesystem path to the Conf-managed telemetry preferences file.
|
|
131
|
+
* Used by `pax8-cta config` to surface where preferences live.
|
|
132
|
+
*/
|
|
133
|
+
export function getTelemetryConfigPath() {
|
|
134
|
+
return config.path;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Stored telemetry preference (ignores env-var overrides).
|
|
138
|
+
*
|
|
139
|
+
* `isTelemetryEnabled()` factors in env-var opt-outs (DO_NOT_TRACK,
|
|
140
|
+
* PAX8_CTA_TELEMETRY_DISABLED, CI, missing PostHog key). This raw getter
|
|
141
|
+
* lets `config` distinguish a user's saved choice from a runtime override.
|
|
142
|
+
*/
|
|
143
|
+
export function getStoredTelemetryPreference() {
|
|
144
|
+
try {
|
|
145
|
+
return config.get("telemetryEnabled");
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Reason telemetry is currently disabled, if it is.
|
|
153
|
+
*
|
|
154
|
+
* Mirrors the precedence inside `isTelemetryEnabled()`:
|
|
155
|
+
* 1. PAX8_CTA_TELEMETRY_DISABLED env var
|
|
156
|
+
* 2. DO_NOT_TRACK env var
|
|
157
|
+
* 3. CI env var
|
|
158
|
+
* 4. Missing PostHog key
|
|
159
|
+
* 5. User preference (config file)
|
|
160
|
+
*
|
|
161
|
+
* Returns `null` when telemetry is enabled.
|
|
162
|
+
*/
|
|
163
|
+
export function getTelemetryDisabledSource() {
|
|
164
|
+
if (process.env.PAX8_CTA_TELEMETRY_DISABLED === "1" ||
|
|
165
|
+
process.env.PAX8_CTA_TELEMETRY_DISABLED === "true") {
|
|
166
|
+
return "env";
|
|
167
|
+
}
|
|
168
|
+
if (process.env.DO_NOT_TRACK === "1")
|
|
169
|
+
return "do-not-track";
|
|
170
|
+
if (process.env.CI === "true" || process.env.CI === "1")
|
|
171
|
+
return "ci";
|
|
172
|
+
if (!POSTHOG_KEY)
|
|
173
|
+
return "no-key";
|
|
174
|
+
if (!getStoredTelemetryPreference())
|
|
175
|
+
return "config";
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
// ============================================================================
|
|
179
|
+
// PostHog Client
|
|
180
|
+
// ============================================================================
|
|
181
|
+
let client = null;
|
|
182
|
+
let clientPromise = null;
|
|
183
|
+
async function getClient() {
|
|
184
|
+
if (!isTelemetryEnabled()) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
if (client) {
|
|
188
|
+
return client;
|
|
189
|
+
}
|
|
190
|
+
// De-duplicate concurrent initializations
|
|
191
|
+
if (!clientPromise) {
|
|
192
|
+
clientPromise = (async () => {
|
|
193
|
+
try {
|
|
194
|
+
// Lazy-load posthog-node so the dependency isn't pulled into
|
|
195
|
+
// every cold start (telemetry is opt-in; most invocations skip this).
|
|
196
|
+
const mod = await import("posthog-node");
|
|
197
|
+
const PostHogCtor = mod.PostHog;
|
|
198
|
+
client = new PostHogCtor(POSTHOG_KEY, {
|
|
199
|
+
host: POSTHOG_HOST,
|
|
200
|
+
flushAt: 10,
|
|
201
|
+
flushInterval: 30000, // 30 seconds
|
|
202
|
+
});
|
|
203
|
+
return client;
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
// posthog-node may not be installed (e.g. trimmed bundle).
|
|
207
|
+
// Telemetry should silently no-op rather than break the CLI.
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
})();
|
|
211
|
+
}
|
|
212
|
+
return clientPromise;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Shutdown telemetry client gracefully
|
|
216
|
+
*/
|
|
217
|
+
export async function shutdownTelemetry() {
|
|
218
|
+
try {
|
|
219
|
+
// If a client init is still in flight, wait for it so we can flush.
|
|
220
|
+
if (clientPromise) {
|
|
221
|
+
await clientPromise;
|
|
222
|
+
}
|
|
223
|
+
if (client) {
|
|
224
|
+
await client.shutdown();
|
|
225
|
+
client = null;
|
|
226
|
+
}
|
|
227
|
+
clientPromise = null;
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
// Telemetry should never affect CLI functionality
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Track a CLI command execution
|
|
235
|
+
*/
|
|
236
|
+
export function trackCommand(ctx) {
|
|
237
|
+
// Fast-path: avoid even kicking off the dynamic import if telemetry is off.
|
|
238
|
+
if (!isTelemetryEnabled())
|
|
239
|
+
return;
|
|
240
|
+
void (async () => {
|
|
241
|
+
try {
|
|
242
|
+
const posthog = await getClient();
|
|
243
|
+
if (!posthog)
|
|
244
|
+
return;
|
|
245
|
+
posthog.capture({
|
|
246
|
+
distinctId: getMachineId(),
|
|
247
|
+
event: "cli_command",
|
|
248
|
+
properties: {
|
|
249
|
+
command: ctx.command,
|
|
250
|
+
subcommand: ctx.subcommand,
|
|
251
|
+
flags: ctx.flags,
|
|
252
|
+
success: ctx.success,
|
|
253
|
+
duration_ms: ctx.durationMs,
|
|
254
|
+
error_type: ctx.errorType,
|
|
255
|
+
demo_mode: ctx.demoMode,
|
|
256
|
+
cli_version: CLI_VERSION,
|
|
257
|
+
os: process.platform,
|
|
258
|
+
node_version: process.version,
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
// Telemetry should never affect CLI functionality
|
|
264
|
+
}
|
|
265
|
+
})();
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Track a "not found" error (like a 404)
|
|
269
|
+
*/
|
|
270
|
+
export function trackNotFound(resource, query) {
|
|
271
|
+
if (!isTelemetryEnabled())
|
|
272
|
+
return;
|
|
273
|
+
// Hash the query synchronously so we don't hold a reference to the raw value.
|
|
274
|
+
const queryHash = createHash("sha256").update(query).digest("hex").substring(0, 8);
|
|
275
|
+
void (async () => {
|
|
276
|
+
try {
|
|
277
|
+
const posthog = await getClient();
|
|
278
|
+
if (!posthog)
|
|
279
|
+
return;
|
|
280
|
+
// Don't track the actual query value for privacy - just the resource type
|
|
281
|
+
posthog.capture({
|
|
282
|
+
distinctId: getMachineId(),
|
|
283
|
+
event: "cli_not_found",
|
|
284
|
+
properties: {
|
|
285
|
+
resource_type: resource,
|
|
286
|
+
query_hash: queryHash,
|
|
287
|
+
cli_version: CLI_VERSION,
|
|
288
|
+
os: process.platform,
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
// Telemetry should never affect CLI functionality
|
|
294
|
+
}
|
|
295
|
+
})();
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Track an error (without sensitive details)
|
|
299
|
+
*/
|
|
300
|
+
export function trackError(errorType, command) {
|
|
301
|
+
if (!isTelemetryEnabled())
|
|
302
|
+
return;
|
|
303
|
+
void (async () => {
|
|
304
|
+
try {
|
|
305
|
+
const posthog = await getClient();
|
|
306
|
+
if (!posthog)
|
|
307
|
+
return;
|
|
308
|
+
posthog.capture({
|
|
309
|
+
distinctId: getMachineId(),
|
|
310
|
+
event: "cli_error",
|
|
311
|
+
properties: {
|
|
312
|
+
error_type: errorType,
|
|
313
|
+
command,
|
|
314
|
+
cli_version: CLI_VERSION,
|
|
315
|
+
os: process.platform,
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
// Telemetry should never affect CLI functionality
|
|
321
|
+
}
|
|
322
|
+
})();
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Track first run
|
|
326
|
+
*/
|
|
327
|
+
export function trackFirstRun() {
|
|
328
|
+
if (!isTelemetryEnabled())
|
|
329
|
+
return;
|
|
330
|
+
void (async () => {
|
|
331
|
+
try {
|
|
332
|
+
const posthog = await getClient();
|
|
333
|
+
if (!posthog)
|
|
334
|
+
return;
|
|
335
|
+
posthog.capture({
|
|
336
|
+
distinctId: getMachineId(),
|
|
337
|
+
event: "cli_first_run",
|
|
338
|
+
properties: {
|
|
339
|
+
cli_version: CLI_VERSION,
|
|
340
|
+
os: process.platform,
|
|
341
|
+
node_version: process.version,
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
// Telemetry should never affect CLI functionality
|
|
347
|
+
}
|
|
348
|
+
})();
|
|
349
|
+
}
|
|
350
|
+
// ============================================================================
|
|
351
|
+
// First Run Notice
|
|
352
|
+
// ============================================================================
|
|
353
|
+
/**
|
|
354
|
+
* Get the first run notice text
|
|
355
|
+
*/
|
|
356
|
+
export function getFirstRunNotice() {
|
|
357
|
+
return `
|
|
358
|
+
┌────────────────────────────────────────────────────────────────────────────┐
|
|
359
|
+
│ Pax8 CTA CLI can collect anonymous usage data to help improve the tool. │
|
|
360
|
+
│ │
|
|
361
|
+
│ Telemetry is disabled by default. To opt in: │
|
|
362
|
+
│ • Run 'telemetry on' │
|
|
363
|
+
│ • Learn more: github.com/pax8labs/pax8-cta/tree/main/packages/cli │
|
|
364
|
+
└────────────────────────────────────────────────────────────────────────────┘
|
|
365
|
+
`;
|
|
366
|
+
}
|
|
367
|
+
//# sour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