portia.telemetry.telemetry_service
Telemetry service for capturing anonymized usage data.
xdg_cache_home
def xdg_cache_home() -> Path
Get the XDG cache home directory path.
Returns:
Path
- The path to the cache directory, either from XDG_CACHE_HOME environment variable or the default ~/.portia location.
get_project_id_key
def get_project_id_key() -> str
Get the project ID key.
Returns:
str
- The project ID key
BaseProductTelemetry Objects
class BaseProductTelemetry(ABC)
Base interface for capturing anonymized telemetry data.
This class handles the collection and transmission of anonymized usage data to PostHog.
Telemetry can be disabled by setting the environment variable ANONYMIZED_TELEMETRY=False
.
capture
@abstractmethod
def capture(event: BaseTelemetryEvent) -> None
Capture and send a telemetry event.
Arguments:
event
BaseTelemetryEvent - The telemetry event to capture
ProductTelemetry Objects
@singleton
class ProductTelemetry(BaseProductTelemetry)
Service for capturing anonymized telemetry data.
This class handles the collection and transmission of anonymized usage data to PostHog.
Telemetry can be disabled by setting the environment variable ANONYMIZED_TELEMETRY=False
.
Attributes:
USER_ID_PATH
str - Path where the user ID is storedPROJECT_API_KEY
str - PostHog project API keyHOST
str - PostHog server host URLUNKNOWN_USER_ID
str - Default user ID when user identification fails
__init__
def __init__() -> None
Initialize the telemetry service.
Sets up the PostHog client if telemetry is enabled and configures logging.
capture
def capture(event: BaseTelemetryEvent) -> None
Capture and send a telemetry event.
Arguments:
event
BaseTelemetryEvent - The telemetry event to capture
user_id
@property
def user_id() -> str
Get the current user ID, generating a new one if it doesn't exist.
Returns:
str
- The user ID, either from cache or newly generated