Skip to content

Commit

Permalink
Chore: Add telemetry tracking flag for langchain-airbyte; Fix: inco…
Browse files Browse the repository at this point in the history
…rrect telemetry URL printed in first-time execution (#125)
  • Loading branch information
aaronsteers authored Mar 13, 2024
1 parent 3b26f81 commit 8f6c011
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions airbyte/_util/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ def is_ci() -> bool:
return "CI" in os.environ


@lru_cache
def is_langchain() -> bool:
"""Return True if running in a Langchain environment.
This checks for the presence of the 'langchain-airbyte' package.
TODO: A more robust check would inspect the call stack or another flag to see if we are actually
being invoked via LangChain, vs being installed side-by-side.
This is cached for performance reasons.
"""
return "langchain_airbyte" in sys.modules


@lru_cache
def is_colab() -> bool:
return bool(get_colab_release_version())
Expand Down
6 changes: 4 additions & 2 deletions airbyte/_util/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ def _setup_analytics() -> str | bool:
if not _ANALYTICS_FILE.exists():
# This is a one-time message to inform the user that we are tracking anonymous usage stats.
print(
"Anonymous usage reporting is enabled. For more information or to opt out, please"
" see https://docs.airbyte.io/pyairbyte/anonymized-usage-statistics"
"Thank you for using PyAirbyte!\n"
"Anonymous usage reporting is currently enabled. For more information, please"
" see https://docs.airbyte.com/telemetry"
)

if _ANALYTICS_FILE.exists():
Expand Down Expand Up @@ -227,6 +228,7 @@ def one_way_hash(
def get_env_flags() -> dict[str, Any]:
flags: dict[str, bool | str] = {
"CI": meta.is_ci(),
"LANGCHAIN": meta.is_langchain(),
"NOTEBOOK_RUNTIME": (
"GOOGLE_COLAB"
if meta.is_colab()
Expand Down

0 comments on commit 8f6c011

Please sign in to comment.