fix sync on oss side (#4797)

This commit is contained in:
Shuchang Zheng
2026-02-18 15:41:33 -08:00
committed by GitHub
parent bf92eea8ea
commit da175fee70
3 changed files with 27 additions and 17 deletions

View File

@@ -1,12 +1,16 @@
import functools
import importlib.metadata
import platform
from typing import Any, Dict
import structlog
import typer
from posthog import Posthog
from skyvern.config import settings
LOG = structlog.get_logger(__name__)
posthog = Posthog(
"phc_bVT2ugnZhMHRWqMvSRHPdeTjaPxQqT3QSsI3r5FlQR5",
host="https://app.posthog.com",
@@ -23,7 +27,9 @@ def get_oss_version() -> str:
return "unknown"
@functools.lru_cache(maxsize=1)
def analytics_metadata() -> Dict[str, Any]:
# Cached: all fields are process-lifetime constants. Do not add dynamic fields here.
return {
"os": platform.system().lower(),
"oss_version": get_oss_version(),
@@ -38,26 +44,15 @@ def capture(
event: str,
data: dict[str, Any] | None = None,
) -> None:
# If telemetry is disabled, don't send any data
if not settings.SKYVERN_TELEMETRY:
return
distinct_id = settings.ANALYTICS_ID
payload: dict[str, Any] = data or {}
try:
distinct_id = settings.ANALYTICS_ID
payload: dict[str, Any] = data or {}
posthog.capture(distinct_id=distinct_id, event=event, properties=payload)
except Exception as e:
payload.update(
{
"capture_error": str(e),
}
)
posthog.capture(
distinct_id=distinct_id,
event="failure",
properties=payload,
)
except Exception:
LOG.debug("analytics capture failed", event=event, exc_info=True)
# This is the main function that will be called by the typer CLI. This is separate from capture because typer