Skip to content

Commit

Permalink
airbyte-ci: disable telemetry with env var (airbytehq#35438)
Browse files Browse the repository at this point in the history
  • Loading branch information
alafanechere authored and jatinyadav-cc committed Feb 26, 2024
1 parent 8426a35 commit 5dd9879
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 5 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 Expand Up @@ -640,6 +644,7 @@ E.G.: running Poe tasks on the modified internal packages of the current branch:

| Version | PR | Description |
| ------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| 4.3.0 | [#35438](https://github.com/airbytehq/airbyte/pull/35438) | Optionally disable telemetry with environment variable. |
| 4.2.4 | [#35325](https://github.com/airbytehq/airbyte/pull/35325) | Use `connectors_qa` for QA checks and remove redundant checks. |
| 4.2.3 | [#35322](https://github.com/airbytehq/airbyte/pull/35322) | Declare `connectors_qa` as an internal package for testing. |
| 4.2.2 | [#35364](https://github.com/airbytehq/airbyte/pull/35364) | Fix connector tests following gradle changes in #35307. |
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("AIRBYTE_CI_DISABLE_TELEMETRY", "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
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/pipelines/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pipelines"
version = "4.2.4"
version = "4.3.0"
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
authors = ["Airbyte <contact@airbyte.io>"]

Expand Down

0 comments on commit 5dd9879

Please sign in to comment.