fix(cli): fix telemetry

This commit is contained in:
Aman Varshney
2025-07-13 20:35:51 +05:30
parent 1a750c1597
commit 901e1fffd9
2 changed files with 18 additions and 25 deletions

View File

@@ -0,0 +1,5 @@
---
"create-better-t-stack": patch
---
fix telemetry logic

View File

@@ -1,34 +1,22 @@
/** /**
* Utility function to determine if telemetry should be enabled. * Returns true if telemetry/analytics should be enabled, false otherwise.
* *
* Telemetry is enabled by default in production, but can be disabled by: * - If BTS_TELEMETRY_DISABLED is present and "1", disables analytics.
* - Setting BTS_TELEMETRY=0 or BTS_TELEMETRY=false * - Otherwise, BTS_TELEMETRY: "0" disables, "1" enables (default: enabled).
* - Running in development environment (NODE_ENV=development)
*/ */
export function isTelemetryEnabled(): boolean { export function isTelemetryEnabled(): boolean {
// If user explicitly disabled telemetry const BTS_TELEMETRY_DISABLED = process.env.BTS_TELEMETRY_DISABLED;
if ( const BTS_TELEMETRY = process.env.BTS_TELEMETRY;
process.env.BTS_TELEMETRY === "0" ||
process.env.BTS_TELEMETRY === "false"
) {
return false;
}
// If user explicitly enabled telemetry console.log("BTS_TELEMETRY_DISABLED:", BTS_TELEMETRY_DISABLED);
if ( console.log("BTS_TELEMETRY:", BTS_TELEMETRY);
process.env.BTS_TELEMETRY === "1" ||
process.env.BTS_TELEMETRY === "true"
) {
return true;
}
if ( if (BTS_TELEMETRY_DISABLED !== undefined) {
process.env.BTS_TELEMETRY_DISABLED === "1" || return BTS_TELEMETRY_DISABLED !== "1";
process.env.BTS_TELEMETRY_DISABLED === "true"
) {
return false;
} }
if (BTS_TELEMETRY !== undefined) {
// Default to enabled in production return BTS_TELEMETRY === "1";
}
// Default: enabled
return true; return true;
} }