This commit is contained in:
teh_coderer
2023-05-02 08:59:53 -04:00
parent 409317406e
commit b596d0c8b3
3 changed files with 8 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
import os
from typing import Dict
from pydantic.dataclasses import dataclass
@@ -35,7 +36,8 @@ class ProfileModel(BaseModel):
self.email = email
self.username = self.email[: self.email.find("@")]
self.remember = remember
openbb_posthog.identify(self.uuid, {"email": self.email})
if os.environ.get("OPENBB_LOG_COLLECT", "false").lower() == "true":
openbb_posthog.identify(self.uuid, {"email": self.email})
def get_uuid(self) -> str:
"""Get uuid.

View File

@@ -145,13 +145,10 @@ class Backend(PyWry):
"""Get the json update for the backend."""
current_user = get_current_user()
current_system = get_current_system()
collect_logs = os.environ.get("OPENBB_LOG_COLLECT", "false").lower() == "true"
posthog: Dict[str, Any] = dict(collect_logs=current_system.LOG_COLLECT)
if (
current_system.LOG_COLLECT
and current_user.profile.email
and not self.logged_in
):
posthog: Dict[str, Any] = dict(collect_logs=collect_logs)
if collect_logs and current_user.profile.email and not self.logged_in:
self.logged_in = True
posthog.update(
dict(

View File

@@ -5,6 +5,7 @@ __docformat__ = "numpy"
import atexit
import json
import logging
import os
import re
import sys
import time
@@ -261,7 +262,7 @@ def setup_handlers(settings: Settings):
if (
not any([current_system.TEST_MODE, current_system.LOGGING_SUPPRESS])
and current_system.LOG_COLLECT
and os.environ.get("OPENBB_LOG_COLLECT", "false").lower() == "true"
):
add_posthog_handler(settings=settings)