Skip to content

Commit

Permalink
fix telemetry for init event (#2736)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lendemor committed Feb 27, 2024
1 parent 39175f5 commit 467fb79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions reflex/reflex.py
Expand Up @@ -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()

Expand Down
4 changes: 3 additions & 1 deletion reflex/utils/telemetry.py
Expand Up @@ -12,6 +12,8 @@
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.
Expand Down Expand Up @@ -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

0 comments on commit 467fb79

Please sign in to comment.