Context
Issue #362 proposed three ways to globally disable telemetry. PR #364 implemented the .swamp.yaml telemetryDisabled: true config option but the environment variable mechanism was left out. This is needed for UAT/CI environments where editing .swamp.yaml on every run isn't practical.
Proposed Priority Order (highest to lowest)
--no-telemetry CLI flag
SWAMP_NO_TELEMETRY env var ← this issue
.swamp.yaml telemetryDisabled: true
- Default (telemetry enabled)
Implementation Plan
1. Add isTelemetryDisabledByEnv() to src/cli/mod.ts
Add after isTelemetryDisabledByConfig(), following the same pattern as resolveModelsDir() which already uses Deno.env.get("SWAMP_MODELS_DIR"):
/**
* Checks whether telemetry is disabled via SWAMP_NO_TELEMETRY environment variable.
* Any value other than "0", "false", or empty string disables telemetry.
*
* @internal Exported for testing
*/
export function isTelemetryDisabledByEnv(): boolean {
const val = Deno.env.get("SWAMP_NO_TELEMETRY");
if (val === undefined) return false;
return val !== "0" && val !== "false" && val !== "";
}
2. Update runCli() in src/cli/mod.ts
// Before:
const telemetryDisabled = isTelemetryDisabled(args);
// After:
const telemetryDisabled = isTelemetryDisabled(args) || isTelemetryDisabledByEnv();
This gives the correct precedence: the flag and env var are both pre-parse checks evaluated before initTelemetryService() (which checks the config file internally).
3. Add tests to src/cli/mod_test.ts
Following the exact pattern of the resolveModelsDir env var tests (save original, modify, restore in finally). Cover:
- env var not set → telemetry enabled
- env var set to
"1" → disabled
- env var set to
"true" → disabled
- env var set to
"0" → enabled (explicit opt-in override)
- env var set to
"false" → enabled (explicit opt-in override)
- env var set to
"" → enabled (empty = unset)
4. Update README.md
Extend the "Disabling Telemetry" section to include:
Via environment variable (useful for CI/UAT environments):
```bash
export SWAMP_NO_TELEMETRY=1
swamp workflow run my-workflow
Priority order (highest to lowest): --no-telemetry flag → SWAMP_NO_TELEMETRY env var → .swamp.yaml telemetryDisabled: true.
## Files to Modify
- `src/cli/mod.ts` — Add `isTelemetryDisabledByEnv()`, update `runCli()`
- `src/cli/mod_test.ts` — Add 6 tests for the new function
- `README.md` — Document env var and precedence order
Closes #362 (remaining piece)
Context
Issue #362 proposed three ways to globally disable telemetry. PR #364 implemented the
.swamp.yamltelemetryDisabled: trueconfig option but the environment variable mechanism was left out. This is needed for UAT/CI environments where editing.swamp.yamlon every run isn't practical.Proposed Priority Order (highest to lowest)
--no-telemetryCLI flagSWAMP_NO_TELEMETRYenv var ← this issue.swamp.yamltelemetryDisabled: trueImplementation Plan
1. Add
isTelemetryDisabledByEnv()tosrc/cli/mod.tsAdd after
isTelemetryDisabledByConfig(), following the same pattern asresolveModelsDir()which already usesDeno.env.get("SWAMP_MODELS_DIR"):2. Update
runCli()insrc/cli/mod.tsThis gives the correct precedence: the flag and env var are both pre-parse checks evaluated before
initTelemetryService()(which checks the config file internally).3. Add tests to
src/cli/mod_test.tsFollowing the exact pattern of the
resolveModelsDirenv var tests (save original, modify, restore infinally). Cover:"1"→ disabled"true"→ disabled"0"→ enabled (explicit opt-in override)"false"→ enabled (explicit opt-in override)""→ enabled (empty = unset)4. Update
README.mdExtend the "Disabling Telemetry" section to include:
Priority order (highest to lowest):
--no-telemetryflag →SWAMP_NO_TELEMETRYenv var →.swamp.yamltelemetryDisabled: true.