nat.cli.commands.configure.telemetry#

nat configure telemetry — manage the user’s telemetry consent decision.

Three modes:

  • --enable: persist consent as enabled.

  • --disable: persist consent as disabled.

  • --status (default if no flag): print the current effective state and the source that determined it (env var, persisted file, or default).

Functions#

telemetry_command(→ None)

Manage NAT telemetry consent.

_persist_and_verify(→ None)

Persist state and read it back to confirm it actually landed.

_warn_on_env_var_override(→ None)

If NAT_TELEMETRY_ENABLED is set, the persisted decision is overridden.

Module Contents#

telemetry_command(action: str) None#

Manage NAT telemetry consent.

_persist_and_verify(
state: nat.utils.telemetry.consent.ConsentState,
) None#

Persist state and read it back to confirm it actually landed.

write_persisted_consent swallows write failures by design (the interactive consent flow can tolerate a re-prompt next run). The explicit nat configure telemetry --enable | --disable path cannot tolerate that: a failed write would leave the user confidently believing they opted out while the next invocation still emits. Verify the readback and surface a hard error if the state did not land.

A readback mismatch usually means filesystem permission issues, a full disk, or an env var overriding the persisted decision (we don’t fail on env override — that’s reported separately by _warn_on_env_var_override; we only fail on outright persistence failure).

_warn_on_env_var_override() None#

If NAT_TELEMETRY_ENABLED is set, the persisted decision is overridden.

Tell the user so they aren’t surprised when their next nat run doesn’t behave as they just configured.