diff --git a/openbb_terminal/core/models/profile_model.py b/openbb_terminal/core/models/profile_model.py index 4db43c45ded..cb4c2d300ad 100644 --- a/openbb_terminal/core/models/profile_model.py +++ b/openbb_terminal/core/models/profile_model.py @@ -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. diff --git a/openbb_terminal/core/plots/backend.py b/openbb_terminal/core/plots/backend.py index 569ae67ae61..48d614a0e9f 100644 --- a/openbb_terminal/core/plots/backend.py +++ b/openbb_terminal/core/plots/backend.py @@ -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( diff --git a/openbb_terminal/loggers.py b/openbb_terminal/loggers.py index 0f66070c20c..33195e9d969 100644 --- a/openbb_terminal/loggers.py +++ b/openbb_terminal/loggers.py @@ -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)