mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-07 02:07:45 +02:00
[eric] analytics: trim my authored comments to one-line WHY-only; drop _locale leading-underscore
This commit is contained in:
@@ -18,10 +18,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
P_CLIENT: Optional[AnalyticsClient] = None
|
||||
|
||||
# Where the SDK ships events. Configurable so local dev hits a local
|
||||
# product-analytics-v1 (its .env BACKEND_PORT) while prod points at the
|
||||
# cloud-hosted ingest via OPENSWARM_ANALYTICS_URL. NOT the desktop backend's
|
||||
# port (8324); the analytics service listens on 6792.
|
||||
# Env-overridable so prod points at the cloud edge; this default is the analytics service's own port, not the desktop's 8324.
|
||||
P_DEFAULT_ANALYTICS_URL = "http://127.0.0.1:6792"
|
||||
|
||||
|
||||
|
||||
@@ -46,9 +46,7 @@ _TIMEOUT_SECONDS = 5.0
|
||||
|
||||
|
||||
def resolve_timezone() -> str:
|
||||
"""Best-effort IANA timezone for analytics. Prefers the renderer-reported
|
||||
value persisted in settings (the only source that works on dev / OSS where
|
||||
Electron's env injection never runs), then the OS, then UTC."""
|
||||
"""Settings-first (the only source that works on dev / OSS), then OS, then UTC."""
|
||||
try:
|
||||
from backend.apps.settings.store import load_settings
|
||||
tz = getattr(load_settings(), "timezone", None)
|
||||
@@ -79,8 +77,8 @@ def resolve_locale() -> str:
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
import locale as _locale
|
||||
code = _locale.getlocale()[0]
|
||||
import locale
|
||||
code = locale.getlocale()[0]
|
||||
if code:
|
||||
return code.replace("_", "-")
|
||||
except Exception:
|
||||
|
||||
@@ -190,9 +190,7 @@ async def service_lifespan():
|
||||
|
||||
svc.sync({"identity": id_props})
|
||||
|
||||
# swarm-analytics: bootstrap the client (registers + persists a token on
|
||||
# first run), prove the pipe with one diagnostic log write, and link the
|
||||
# user's email. All best-effort; the wrappers swallow every error.
|
||||
# First-boot log write doubles as the token-registration trigger.
|
||||
from backend.apps.service.analytics import get_analytics_client, track_link_email
|
||||
analytics_client = get_analytics_client()
|
||||
if analytics_client is not None:
|
||||
@@ -251,8 +249,7 @@ async def service_lifespan():
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# swarm-analytics: fire the app-closed event and flush+close the client so
|
||||
# buffered events land before the process exits. Best-effort.
|
||||
# Flush before the process exits or buffered events are lost.
|
||||
try:
|
||||
from backend.apps.service.analytics import track_app_closed, shutdown_analytics
|
||||
track_app_closed()
|
||||
|
||||
@@ -16,9 +16,7 @@ python-dotenv==1.1.1
|
||||
Pillow==12.2.0
|
||||
httpx==0.28.1
|
||||
trafilatura==2.0.0
|
||||
# swarm-analytics: typed client for the product-analytics ingest service.
|
||||
# Validates payloads against the server schema locally; all calls are
|
||||
# fire-and-forget and swallow errors so analytics can never break the app.
|
||||
# swarm-analytics: typed client for the product-analytics ingest; fire-and-forget so it never breaks the app.
|
||||
swarm-analytics==0.1.1
|
||||
# tzlocal: dev-mode fallback for resolving the user's IANA timezone when
|
||||
# Electron's OPENSWARM_TIMEZONE env var isn't set (i.e. `bash run.sh`).
|
||||
|
||||
Reference in New Issue
Block a user