we don't have to read it every time
This commit is contained in:
parent
38f3e5c683
commit
858c1420b2
1 changed files with 6 additions and 2 deletions
|
|
@ -7,9 +7,13 @@ _posthog: Posthog = Posthog(
|
|||
project_api_key="phc_aUO790jHd7z1SXwsYCz8dRApxueplZlZWeDSpKc5hol", host="https://us.posthog.com"
|
||||
)
|
||||
|
||||
ENVIRONMENT_TYPE = os.environ.get("ENVIRONMENT", default="None")
|
||||
OPENAI_API_TYPE = os.environ.get("OPENAI_API_TYPE", default="azure")
|
||||
|
||||
|
||||
def ph(user_id: str, event: str, properties: dict[str, Any] | None = None) -> None:
|
||||
"""Log an event to PostHog.
|
||||
|
||||
:param user_id: user id e.g. github|1234567890
|
||||
:param event: The name of the event.
|
||||
:param properties: A dictionary of properties to attach to the event.
|
||||
|
|
@ -17,7 +21,7 @@ def ph(user_id: str, event: str, properties: dict[str, Any] | None = None) -> No
|
|||
if properties is None:
|
||||
properties = {}
|
||||
|
||||
properties["environment"] = os.environ.get("ENVIRONMENT", default="None")
|
||||
properties["openai_api_type"] = os.environ.get("OPENAI_API_TYPE", default="azure")
|
||||
properties["environment"] = ENVIRONMENT_TYPE
|
||||
properties["openai_api_type"] = OPENAI_API_TYPE
|
||||
|
||||
_posthog.capture(distinct_id=user_id, event=event, properties=properties)
|
||||
|
|
|
|||
Loading…
Reference in a new issue