Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/configuration/posthog.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def posthog_error_handler(error, batch):
if not is_production():
posthog_client.disabled = True

# https://github.com/PostHog/posthog-python/issues/353
# without this, a newly-created client will be used for things like catching context exceptions
# Module-level APIs (`posthog.new_context`, `posthog.capture`, …) use this client.
# Without it, contexts fall back to a separately constructed default instance.
posthog.default_client = posthog_client


Expand Down
5 changes: 2 additions & 3 deletions app/routes/dependencies/posthog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def inject_posthog_identity(request: Request):
> If two users have the same distinct ID, their data is merged and they are considered one user in PostHog.
"""

with posthog.new_context(capture_exceptions=False):
with posthog.new_context():
# by using clerk_id, we can easily use the same UUID on frontend events
posthog.identify_context(request.state.user.clerk_id)
yield
Expand All @@ -42,8 +42,7 @@ async def inject_posthog_tags(request: Request):
"""

# by default, there is not a context, so we must define one
# `capture_exceptions=False` https://github.com/PostHog/posthog-python/issues/353
with posthog.new_context(capture_exceptions=False):
with posthog.new_context():
# intentionally overwrite any other session or distinct id set previously
# it's up to the user to add dependencies in the correct order
if distinct_id := request.headers.get("X-Posthog-Distinct-Id"):
Expand Down
Loading