Skip to content

Commit

Permalink
airbyte-ci: disable telemetry with env var
Browse files Browse the repository at this point in the history
  • Loading branch information
alafanechere committed Feb 20, 2024
1 parent 98ed774 commit 56c75d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions airbyte-ci/connectors/pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ To clean the airbyte-ci install, run the following command:
make tools.airbyte-ci.clean
```

## Disabling telemetry

We collect anonymous usage data to help improve the tool. If you would like to disable this, you can set the `AIRBYTE_CI_DISABLE_TELEMETRY` environment variable to `true`.

## Installation for development

#### Pre-requisites
Expand Down
10 changes: 6 additions & 4 deletions airbyte-ci/connectors/pipelines/pipelines/cli/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
import segment.analytics as analytics # type: ignore
from asyncclick import get_current_context

DISABLE_TELEMETRY = os.environ.get(" ", "false").lower() == "true"

if TYPE_CHECKING:
from typing import Any, Callable, Dict, Tuple

from asyncclick import Command

analytics.write_key = "G6G7whgro81g9xM00kN2buclGKvcOjFd"
analytics.send = True
analytics.send = not DISABLE_TELEMETRY
analytics.debug = False


Expand Down Expand Up @@ -49,13 +51,13 @@ def click_track_command(f: Callable) -> Callable:

def wrapper(*args: Tuple, **kwargs: Dict[str, Any]) -> Command:
ctx = get_current_context()

top_level_command = ctx.command_path
full_cmd = " ".join(sys.argv)

# remove anything prior to the command name f.__name__
# to avoid logging inline secrets
santized_cmd = full_cmd[full_cmd.find(top_level_command) :]

sanitized_cmd = full_cmd[full_cmd.find(top_level_command) :]
sys_id = _get_anonymous_system_id()
sys_user_name = f"anonymous:{sys_id}"
airbyter = _is_airbyte_user()
Expand All @@ -65,7 +67,7 @@ def wrapper(*args: Tuple, **kwargs: Dict[str, Any]) -> Command:
event = f"airbyte-ci:{f.__name__}"

# IMPORTANT! do not log kwargs as they may contain secrets
analytics.track(user_id, event, {"username": sys_user_name, "command": santized_cmd, "airbyter": airbyter})
analytics.track(user_id, event, {"username": sys_user_name, "command": sanitized_cmd, "airbyter": airbyter})

return f(*args, **kwargs)

Expand Down

0 comments on commit 56c75d9

Please sign in to comment.