Skip to content

Commit 8f6c011

Browse files
authored
Chore: Add telemetry tracking flag for langchain-airbyte; Fix: incorrect telemetry URL printed in first-time execution (#125)
1 parent 3b26f81 commit 8f6c011

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

airbyte/_util/meta.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ def is_ci() -> bool:
3030
return "CI" in os.environ
3131

3232

33+
@lru_cache
34+
def is_langchain() -> bool:
35+
"""Return True if running in a Langchain environment.
36+
37+
This checks for the presence of the 'langchain-airbyte' package.
38+
39+
TODO: A more robust check would inspect the call stack or another flag to see if we are actually
40+
being invoked via LangChain, vs being installed side-by-side.
41+
42+
This is cached for performance reasons.
43+
"""
44+
return "langchain_airbyte" in sys.modules
45+
46+
3347
@lru_cache
3448
def is_colab() -> bool:
3549
return bool(get_colab_release_version())

airbyte/_util/telemetry.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ def _setup_analytics() -> str | bool:
104104
if not _ANALYTICS_FILE.exists():
105105
# This is a one-time message to inform the user that we are tracking anonymous usage stats.
106106
print(
107-
"Anonymous usage reporting is enabled. For more information or to opt out, please"
108-
" see https://docs.airbyte.io/pyairbyte/anonymized-usage-statistics"
107+
"Thank you for using PyAirbyte!\n"
108+
"Anonymous usage reporting is currently enabled. For more information, please"
109+
" see https://docs.airbyte.com/telemetry"
109110
)
110111

111112
if _ANALYTICS_FILE.exists():
@@ -227,6 +228,7 @@ def one_way_hash(
227228
def get_env_flags() -> dict[str, Any]:
228229
flags: dict[str, bool | str] = {
229230
"CI": meta.is_ci(),
231+
"LANGCHAIN": meta.is_langchain(),
230232
"NOTEBOOK_RUNTIME": (
231233
"GOOGLE_COLAB"
232234
if meta.is_colab()

0 commit comments

Comments
 (0)