Skip to content

Commit

Permalink
fix(Mixpanel): Set a timeout on the mixpanel requests & never retry t…
Browse files Browse the repository at this point in the history
…o send events (#895)

Fixes OPENHEXA-1CH & OPENHEXA-1BM
  • Loading branch information
qgerome committed Jan 9, 2025
1 parent db9829a commit ad741a7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hexa/analytics/api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
from django.conf import settings
from django.http import HttpRequest
from mixpanel import Mixpanel
from mixpanel import Consumer, Mixpanel
from sentry_sdk import capture_exception
from ua_parser import user_agent_parser

from hexa.user_management.models import AnonymousUser, User

mixpanel = None
if settings.MIXPANEL_TOKEN:
mixpanel = Mixpanel(token=settings.MIXPANEL_TOKEN)
mixpanel = Mixpanel(
token=settings.MIXPANEL_TOKEN,
consumer=Consumer(
retry_limit=0,
# It’s a good practice to set connect timeouts to slightly larger than a multiple of 3, which is the default TCP packet retransmission window.
# https://requests.readthedocs.io/en/latest/user/advanced/#timeouts
request_timeout=3.05,
),
)


def track(
Expand Down

0 comments on commit ad741a7

Please sign in to comment.