ai-cc-router 0.2.5 → 0.2.7
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/cli/cmd-setup.js +0 -29
- package/dist/config/telemetry.js +1 -3
- package/dist/proxy/server.js +1 -1
- package/dist/utils/telemetry.js +10 -5
- package/package.json +1 -1
package/dist/cli/cmd-setup.js
CHANGED
|
@@ -13,7 +13,6 @@ import { DEFAULT_RATE_LIMITS } from "../proxy/types.js";
|
|
|
13
13
|
import { existsSync } from "fs";
|
|
14
14
|
import { checkMitmproxyInstalled, isCaCertInstalled, generateCaCert, installCaCert, writeAddonScript, getNetworkExtensionStatus, openNetworkExtensionSettings, } from "../interceptor/mitmproxy-manager.js";
|
|
15
15
|
import { printDesktopSupportExplainer, printNetworkExtensionInstructions } from "./cmd-client.js";
|
|
16
|
-
import { loadTelemetryState, writeTelemetryState } from "../config/telemetry.js";
|
|
17
16
|
import { trackEvent } from "../utils/telemetry.js";
|
|
18
17
|
const execFileAsync = promisify(execFile);
|
|
19
18
|
// ─── Public registration ──────────────────────────────────────────────────────
|
|
@@ -214,38 +213,10 @@ async function runSetupWizard({ addMode }) {
|
|
|
214
213
|
console.log(chalk.bold(`\n${"━".repeat(40)}\n Saving\n${"━".repeat(40)}\n`));
|
|
215
214
|
saveAccounts(merged);
|
|
216
215
|
console.log(chalk.green(` ✓ ${merged.length} account(s) saved to ~/.cc-router/accounts.json`));
|
|
217
|
-
showTelemetryDisclosureIfNeeded();
|
|
218
216
|
void trackEvent("setup_completed", { account_count: merged.length });
|
|
219
217
|
// ─── Post-setup interactive flow ─────────────────────────────────────────
|
|
220
218
|
await runPostSetupFlow(merged.length);
|
|
221
219
|
}
|
|
222
|
-
// Anonymous telemetry disclosure, shown exactly once after a successful setup.
|
|
223
|
-
// Controlled by telemetry.disclosureShown in ~/.cc-router/telemetry.json.
|
|
224
|
-
function showTelemetryDisclosureIfNeeded() {
|
|
225
|
-
try {
|
|
226
|
-
const state = loadTelemetryState();
|
|
227
|
-
if (state.disclosureShown)
|
|
228
|
-
return;
|
|
229
|
-
console.log();
|
|
230
|
-
console.log(chalk.dim("─".repeat(60)));
|
|
231
|
-
console.log(chalk.bold(" Anonymous usage analytics"));
|
|
232
|
-
console.log();
|
|
233
|
-
console.log(" CC-Router sends anonymous lifecycle events (version, OS,");
|
|
234
|
-
console.log(" startup, heartbeat) to help us understand usage and prioritize");
|
|
235
|
-
console.log(" improvements. No IPs, no tokens, no prompts, no request content.");
|
|
236
|
-
console.log();
|
|
237
|
-
console.log(` Disable: ${chalk.cyan("cc-router telemetry off")}`);
|
|
238
|
-
console.log(` Or set: ${chalk.cyan("DO_NOT_TRACK=1")} | ${chalk.cyan("CC_ROUTER_TELEMETRY=0")}`);
|
|
239
|
-
console.log(` Source: ${chalk.dim("src/utils/telemetry.ts")}`);
|
|
240
|
-
console.log(chalk.dim("─".repeat(60)));
|
|
241
|
-
console.log();
|
|
242
|
-
state.disclosureShown = true;
|
|
243
|
-
writeTelemetryState(state);
|
|
244
|
-
}
|
|
245
|
-
catch {
|
|
246
|
-
// never block setup on telemetry errors
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
220
|
// ─── Post-setup interactive flow ─────────────────────────────────────────────
|
|
250
221
|
async function runPostSetupFlow(accountCount) {
|
|
251
222
|
console.log(chalk.bold(`\n${"━".repeat(40)}\n Configure this machine\n${"━".repeat(40)}\n`));
|
package/dist/config/telemetry.js
CHANGED
|
@@ -7,7 +7,6 @@ function defaultState() {
|
|
|
7
7
|
enabled: true,
|
|
8
8
|
installId: randomUUID(),
|
|
9
9
|
firstRunAt: new Date().toISOString(),
|
|
10
|
-
disclosureShown: false,
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
12
|
// Read the telemetry state, creating and persisting a fresh one on first run.
|
|
@@ -25,9 +24,8 @@ export function loadTelemetryState() {
|
|
|
25
24
|
enabled: raw.enabled ?? true,
|
|
26
25
|
installId: raw.installId ?? randomUUID(),
|
|
27
26
|
firstRunAt: raw.firstRunAt ?? new Date().toISOString(),
|
|
28
|
-
disclosureShown: raw.disclosureShown ?? false,
|
|
29
27
|
};
|
|
30
|
-
if (!raw.installId
|
|
28
|
+
if (!raw.installId) {
|
|
31
29
|
writeTelemetryState(state);
|
|
32
30
|
}
|
|
33
31
|
return state;
|
package/dist/proxy/server.js
CHANGED
|
@@ -385,7 +385,7 @@ export async function startServer(opts = {}) {
|
|
|
385
385
|
logStartup(port, host, mode, target, accounts.length);
|
|
386
386
|
if (autoUpdate)
|
|
387
387
|
console.log(chalk.gray(" Auto-update: enabled (patch/minor)"));
|
|
388
|
-
// Anonymous telemetry — fire-and-forget, never blocks proxy startup
|
|
388
|
+
// Anonymous telemetry — fire-and-forget, never blocks proxy startup.
|
|
389
389
|
try {
|
|
390
390
|
const telemetryState = loadTelemetryState();
|
|
391
391
|
// First-run detection: if the install is brand new, emit app_started too
|
package/dist/utils/telemetry.js
CHANGED
|
@@ -18,10 +18,12 @@ function getOsName() {
|
|
|
18
18
|
}
|
|
19
19
|
function getLocale() {
|
|
20
20
|
try {
|
|
21
|
-
|
|
21
|
+
// Aptabase limits locale to 10 characters — truncate extended subtags
|
|
22
|
+
const raw = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
23
|
+
return raw.length <= 10 ? raw : raw.slice(0, 10);
|
|
22
24
|
}
|
|
23
25
|
catch {
|
|
24
|
-
return process.env["LANG"]?.split(".")[0] ?? "unknown";
|
|
26
|
+
return process.env["LANG"]?.split(".")[0]?.slice(0, 10) ?? "unknown";
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
function getSystemProps() {
|
|
@@ -36,11 +38,14 @@ function getSystemProps() {
|
|
|
36
38
|
sdkVersion: `cc-router@${getCurrentVersion()}`,
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
|
-
// Session ID
|
|
40
|
-
//
|
|
41
|
+
// Session ID groups events from the same install within an hourly window,
|
|
42
|
+
// without leaking timing precision finer than 1h.
|
|
43
|
+
// Aptabase limits sessionId to 36 characters. A UUID with dashes is already 36,
|
|
44
|
+
// so we strip dashes and take the first 24 hex chars + epochHours (~6-7 digits).
|
|
41
45
|
function getSessionId(installId) {
|
|
42
46
|
const epochHours = Math.floor(Date.now() / 3_600_000);
|
|
43
|
-
|
|
47
|
+
const shortId = installId.replace(/-/g, "").slice(0, 24);
|
|
48
|
+
return `${shortId}${epochHours}`;
|
|
44
49
|
}
|
|
45
50
|
// ─── Public API ──────────────────────────────────────────────────────────────
|
|
46
51
|
// Fire-and-forget: never throws, never blocks the caller. If telemetry is
|