diff --git a/backend/config.py b/backend/config.py index 308f3d2eb..9f8407b4f 100644 --- a/backend/config.py +++ b/backend/config.py @@ -59,6 +59,10 @@ def SQLALCHEMY_DATABASE_URI(self): self.POSTGRES_DB, ) + @property + def MIXPANEL_TOKEN(self): + return os.environ.get("MIXPANEL_TOKEN", None) + SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_ECHO = False diff --git a/backend/mixpanel/mix.py b/backend/mixpanel/mix.py index c85c46939..05234c624 100644 --- a/backend/mixpanel/mix.py +++ b/backend/mixpanel/mix.py @@ -1,12 +1,14 @@ from mixpanel import Mixpanel +from backend.config import Config from ua_parser import user_agent_parser from flask_jwt_extended import get_jwt -from backend import config # Path: backend/mixpanel/mix.py +config = Config() + # Mixpanel connection -mp = Mixpanel.init(config.MIXPANEL_TOKEN) +mp = Mixpanel(config.MIXPANEL_TOKEN) def track_to_mp(request, event_name, properties): @@ -20,7 +22,7 @@ def track_to_mp(request, event_name, properties): "$os": parsed["os"]["family"], }) - if properties["user_id"] is None: + if "user_id" not in properties: user_id = get_jwt()["sub"] else: user_id = properties["user_id"]