Skip to content

Commit

Permalink
fix: token retrieval for sdk in debug (#27669)
Browse files Browse the repository at this point in the history
  • Loading branch information
skoob13 authored Jan 18, 2025
1 parent 921b310 commit b56d6d1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions posthog/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def ready(self):
{"git_rev": get_git_commit_short(), "git_branch": get_git_branch()},
)

local_api_key = get_self_capture_api_token(
User.objects.filter(last_login__isnull=False).order_by("-last_login").first()
)
try:
user = User.objects.filter(last_login__isnull=False).order_by("-last_login").first()
except:
user = None

local_api_key = get_self_capture_api_token(user)

if SELF_CAPTURE and local_api_key:
posthoganalytics.api_key = local_api_key
posthoganalytics.host = settings.SITE_URL
Expand Down

0 comments on commit b56d6d1

Please sign in to comment.