Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions reflex/utils/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ def get_reflex_version() -> str:
return constants.Reflex.VERSION


def _get_app_class_name() -> str | None:
"""Get the app class name if available.

Returns:
The app class name (e.g. "App", "AppEnterprise") or None if not available.
"""
try:
from reflex.utils.prerequisites import get_and_validate_app

app_info = get_and_validate_app()
except Exception:
return None
else:
return app_info.app.__class__.__name__


def get_cpu_count() -> int:
"""Get the number of CPUs.

Expand Down Expand Up @@ -184,12 +200,16 @@ def _prepare_event(event: str, **kwargs) -> _Event | None:
if not event_data:
return None

additional_keys = ["template", "context", "detail", "user_uuid"]
additional_keys = ["template", "context", "detail", "user_uuid", "app_class"]

properties = event_data["properties"]

# Auto-detect app class if not provided
if "app_class" not in kwargs:
kwargs["app_class"] = _get_app_class_name()

for key in additional_keys:
if key in properties or key not in kwargs:
if key in properties or key not in kwargs or kwargs[key] is None:
continue

properties[key] = kwargs[key]
Expand Down