Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/uipath/docs/core/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Telemetry is enabled by default. You can opt out by setting the `UIPATH_TELEMETR
UIPATH_TELEMETRY_ENABLED=false
```

Setting `UIPATH_TELEMETRY_DISABLED=true` has the same effect and takes precedence over `UIPATH_TELEMETRY_ENABLED`.

## Runtime

When executing processes or starting jobs, you can configure environment variables through the UiPath Orchestrator interface. For sensitive information like API keys and secrets, we strongly recommend using secret assets instead of environment variables. Secret assets provide enhanced security and better management capabilities.
Expand Down
2 changes: 1 addition & 1 deletion packages/uipath/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath"
version = "2.14.39.post1"
version = "2.14.39.post2"
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
4 changes: 4 additions & 0 deletions packages/uipath/src/uipath/telemetry/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

PERIODIC_TELEMETRY_FLUSH_FEATURE_FLAG = "EnablePeriodicTelemetryFlush"

# Set to "true" by a host environment that turns telemetry off.
# Wins over UIPATH_TELEMETRY_ENABLED.
_ENV_TELEMETRY_DISABLED = "UIPATH_TELEMETRY_DISABLED"

_APP_INSIGHTS_EVENT_MARKER_ATTRIBUTE = "APPLICATION_INSIGHTS_EVENT_MARKER_ATTRIBUTE"
_OTEL_RESOURCE_ATTRIBUTES = "OTEL_RESOURCE_ATTRIBUTES"
_SDK_VERSION = "SdkVersion"
Expand Down
10 changes: 9 additions & 1 deletion packages/uipath/src/uipath/telemetry/_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
_CONNECTION_STRING_ALPHA,
_CONNECTION_STRING_PROD,
_CONNECTION_STRING_STAGING,
_ENV_TELEMETRY_DISABLED,
_OTEL_RESOURCE_ATTRIBUTES,
_PROJECT_KEY,
_SDK_VERSION,
Expand Down Expand Up @@ -512,7 +513,14 @@ class _TelemetryClient:

@staticmethod
def _is_enabled() -> bool:
"""Check if telemetry is enabled at runtime."""
"""Check if telemetry is enabled at runtime.

``UIPATH_TELEMETRY_DISABLED=true`` turns it off whatever
``UIPATH_TELEMETRY_ENABLED`` says, so a host environment can switch
telemetry off for the processes it starts.
"""
if os.getenv(_ENV_TELEMETRY_DISABLED, "").strip().lower() in ("true", "1"):
return False
return os.getenv(ENV_TELEMETRY_ENABLED, "true").lower() == "true"

@staticmethod
Expand Down
27 changes: 27 additions & 0 deletions packages/uipath/tests/telemetry/test_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,33 @@ def test_is_enabled_case_insensitive(self):
with patch.dict(os.environ, {"UIPATH_TELEMETRY_ENABLED": "False"}):
assert _TelemetryClient._is_enabled() is False

def test_is_enabled_false_when_telemetry_disabled(self):
"""UIPATH_TELEMETRY_DISABLED=true turns telemetry off."""
with patch.dict(os.environ, {"UIPATH_TELEMETRY_DISABLED": "true"}, clear=True):
assert _TelemetryClient._is_enabled() is False

def test_disabled_wins_over_enabled(self):
"""UIPATH_TELEMETRY_DISABLED=true wins over UIPATH_TELEMETRY_ENABLED=true."""
env = {"UIPATH_TELEMETRY_DISABLED": "True", "UIPATH_TELEMETRY_ENABLED": "true"}
with patch.dict(os.environ, env, clear=True):
assert _TelemetryClient._is_enabled() is False

def test_disabled_not_true_keeps_telemetry_on(self):
"""Any other UIPATH_TELEMETRY_DISABLED value leaves the default in place."""
for value in ("false", "", "0"):
with patch.dict(
os.environ, {"UIPATH_TELEMETRY_DISABLED": value}, clear=True
):
assert _TelemetryClient._is_enabled() is True

def test_track_event_sends_nothing_when_telemetry_disabled(self):
"""No event reaches the App Insights client when telemetry is disabled."""
with patch.dict(os.environ, {"UIPATH_TELEMETRY_DISABLED": "true"}, clear=True):
with patch.object(_AppInsightsEventClient, "track_event") as mock_track:
_TelemetryClient.track_event("test_event", {"key": "value"})

mock_track.assert_not_called()

@patch.object(_TelemetryClient, "_is_enabled", return_value=False)
def test_track_event_disabled(self, mock_is_enabled):
"""Test that track_event does nothing when telemetry is disabled."""
Expand Down
2 changes: 1 addition & 1 deletion packages/uipath/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading