repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import json |
| #2 | import logging |
| #3 | import os |
| #4 | import uuid |
| #5 | |
| #6 | from posthog import Posthog |
| #7 | |
| #8 | import embedchain |
| #9 | from embedchain.constants import CONFIG_DIR, CONFIG_FILE |
| #10 | |
| #11 | |
| #12 | class AnonymousTelemetry: |
| #13 | def __init__(self, host="https://app.posthog.com", enabled=True): |
| #14 | self.project_api_key = "phc_PHQDA5KwztijnSojsxJ2c1DuJd52QCzJzT2xnSGvjN2" |
| #15 | self.host = host |
| #16 | self.posthog = Posthog(project_api_key=self.project_api_key, host=self.host) |
| #17 | self.user_id = self._get_user_id() |
| #18 | self.enabled = enabled |
| #19 | |
| #20 | # Check if telemetry tracking is disabled via environment variable |
| #21 | if "EC_TELEMETRY" in os.environ and os.environ["EC_TELEMETRY"].lower() not in [ |
| #22 | "1", |
| #23 | "true", |
| #24 | "yes", |
| #25 | ]: |
| #26 | self.enabled = False |
| #27 | |
| #28 | if not self.enabled: |
| #29 | self.posthog.disabled = True |
| #30 | |
| #31 | # Silence posthog logging |
| #32 | posthog_logger = logging.getLogger("posthog") |
| #33 | posthog_logger.disabled = True |
| #34 | |
| #35 | @staticmethod |
| #36 | def _get_user_id(): |
| #37 | os.makedirs(CONFIG_DIR, exist_ok=True) |
| #38 | if os.path.exists(CONFIG_FILE): |
| #39 | with open(CONFIG_FILE, "r") as f: |
| #40 | data = json.load(f) |
| #41 | if "user_id" in data: |
| #42 | return data["user_id"] |
| #43 | |
| #44 | user_id = str(uuid.uuid4()) |
| #45 | with open(CONFIG_FILE, "w") as f: |
| #46 | json.dump({"user_id": user_id}, f) |
| #47 | return user_id |
| #48 | |
| #49 | def capture(self, event_name, properties=None): |
| #50 | default_properties = { |
| #51 | "version": embedchain.__version__, |
| #52 | "language": "python", |
| #53 | "pid": os.getpid(), |
| #54 | } |
| #55 | properties.update(default_properties) |
| #56 | |
| #57 | try: |
| #58 | self.posthog.capture(self.user_id, event_name, properties) |
| #59 | except Exception: |
| #60 | logging.exception(f"Failed to send telemetry {event_name=}") |
| #61 |