mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
fix(cli): fix telemetry
This commit is contained in:
5
.changeset/violet-moose-feel.md
Normal file
5
.changeset/violet-moose-feel.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"create-better-t-stack": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix telemetry logic
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user