SCRAPEGRAPHAI_TELEMETRY_ENABLED=false 不会禁用遥测

作者: hakoke创建于 2026年7月28日更新于 2026年7月31日
标签bug

README(Telemetry 部分)中提到,可以通过设置 SCRAPEGRAPHAI_TELEMETRY_ENABLED=false 来禁用使用量收集。设置此值不会产生任何影响,无论设置的值为何。scrapegraphai/telemetry/telemetry.py 中的检查(当前主分支中的第 47-53 行)仅测试了变量是否存在,然后从 ~/.scrapegraphai.conf 中读取 telemetry_enabled 关键字,而不是变量的值:

python
if os.environ.get("SCRAPEGRAPHAI_TELEMETRY_ENABLED") is not None:
    try:
        telemetry_enabled = config_obj.getboolean(
            "DEFAULT", "telemetry_enabled"
        )
    except Exception:
        pass

在默认安装中,该关键字不存在,因此 getboolean 会引发 NoOptionError,简单的 except 会将其捕获,并且该标志保持其默认值(已启用)。重现问题:

python
import os, subprocess, sys
for val in ("false", "False", "FALSE", "0", "no", "off", "true"):
    out = subprocess.run(
        [sys.executable, "-c",
         "from scrapegraphai.telemetry import telemetry;"
         "print(telemetry.g_telemetry_enabled)"],
        env={**os.environ, "SCRAPEGRAPHAI_TELEMETRY_ENABLED": val},
        capture_output=True, text=True,
    )
    print(val, "->", out.stdout.strip())

在 2.1.6 中,每个值都会打印为 True。由于 log_graph_execution 在所有字段都存在时都会发送 user_promptwebsite_contentllm_response,因此文档中描述的禁用选项很重要。disable_telemetry() 确实可以工作,但仅适用于在源代码中找到此方法的人。我已经准备好一个小修复,将在几分钟后提交 PR。

内容来源: ScrapeGraphAI/Scrapegraph-ai