fix telemetry for init event (#2736)

This commit is contained in:
Thomas Brandého 2024-02-27 18:53:57 +01:00 committed by GitHub
parent 39175f5812
commit 467fb794da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -94,13 +94,16 @@ def _init(
template = prerequisites.prompt_for_template()
prerequisites.create_config(app_name)
prerequisites.initialize_app_directory(app_name, template)
telemetry.send("init")
telemetry_event = "init"
else:
telemetry.send("reinit")
telemetry_event = "reinit"
# Set up the web project.
prerequisites.initialize_frontend_dependencies()
# Send the telemetry event after the .web folder is initialized.
telemetry.send(telemetry_event)
# Migrate Pynecone projects to Reflex.
prerequisites.migrate_to_reflex()

View File

@ -12,6 +12,8 @@ import psutil
from reflex import constants
from reflex.utils.prerequisites import ensure_reflex_installation_id
POSTHOG_API_URL: str = "https://app.posthog.com/capture/"
def get_os() -> str:
"""Get the operating system.
@ -102,7 +104,7 @@ def send(event: str, telemetry_enabled: bool | None = None) -> bool:
},
"timestamp": datetime.utcnow().isoformat(),
}
httpx.post("https://app.posthog.com/capture/", json=post_hog)
httpx.post(POSTHOG_API_URL, json=post_hog)
return True
except Exception:
return False