Skip to content

Commit

Permalink
Mixpanel Token Not leading
Browse files Browse the repository at this point in the history
  • Loading branch information
DMalone87 authored and Mike Yavorsky committed Nov 15, 2023
1 parent 1e5f2b9 commit db42177
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions backend/mixpanel/mix.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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"]
Expand Down

0 comments on commit db42177

Please sign in to comment.