Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions scrapegraphai/telemetry/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import uuid
from typing import Callable, Dict
from urllib import request

VERSION = importlib.metadata.version("scrapegraphai")
TRACK_URL = "https://sgai-oss-tracing.onrender.com/v1/telemetry"
TIMEOUT = 2
DEFAULT_CONFIG_LOCATION = os.path.expanduser("~/.scrapegraphai.conf")

logger = logging.getLogger(__name__)


def _load_config(config_location: str) -> configparser.ConfigParser:
config = configparser.ConfigParser()
try:
Expand Down Expand Up @@ -45,12 +47,8 @@ def _check_config_and_environ_for_telemetry_flag(default_value: bool, config_obj
pass

if os.environ.get("SCRAPEGRAPHAI_TELEMETRY_ENABLED") is not None:
try:
telemetry_enabled = config_obj.getboolean(
"DEFAULT", "telemetry_enabled"
)
except Exception:
pass
env_value = os.environ.get("SCRAPEGRAPHAI_TELEMETRY_ENABLED")
telemetry_enabled = env_value.strip().lower() in ("true", "1", "yes")

return telemetry_enabled

Expand Down Expand Up @@ -200,4 +198,5 @@ def wrapped_fn(*args, **kwargs):
finally:
if is_telemetry_enabled():
log_event("function_usage", {"function_name": call_fn.__name__})

return wrapped_fn