Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkakkar committed Jun 5, 2023
1 parent 4d04a13 commit a284675
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion posthog/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def ready(self):
posthoganalytics.disabled = True

# load feature flag definitions if not already loaded
if posthoganalytics.feature_flag_definitions() is None:
if not posthoganalytics.disabled and posthoganalytics.feature_flag_definitions() is None:
posthoganalytics.default_client.load_feature_flags()

if not settings.SKIP_SERVICE_VERSION_REQUIREMENTS:
Expand Down
4 changes: 2 additions & 2 deletions posthog/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from posthog.metrics import pushed_metrics_registry
from posthog.redis import get_client
from posthog.utils import get_crontab, get_instance_region
from posthoganalytics import Posthog

# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "posthog.settings")
Expand Down Expand Up @@ -758,6 +757,7 @@ def calculate_decide_usage() -> None:
from posthog.models.feature_flag.flag_analytics import capture_team_decide_usage
from posthog.models import Team
from django.db.models import Q
from posthoganalytics import Posthog

# send EU data to EU, US data to US
api_key = "phc_dZ4GK1LRjhB97XozMSkEwPXx7OVANaJEwLErkY1phUF" if get_instance_region() == "EU" else "sTMFPsFhdP1Ssg"
Expand All @@ -769,7 +769,7 @@ def calculate_decide_usage() -> None:
):
capture_team_decide_usage(ph_client, team.id, team.uuid)

ph_client.flush()
ph_client.shutdown()


@app.task(ignore_result=True)
Expand Down
7 changes: 5 additions & 2 deletions posthog/models/feature_flag/flag_analytics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from typing import TYPE_CHECKING
from posthog.redis import redis, get_client
import time
from posthoganalytics import Posthog
from sentry_sdk import capture_exception

if TYPE_CHECKING:
from posthoganalytics import Posthog

REDIS_LOCK_TOKEN = "posthog:decide_analytics:lock"
CACHE_BUCKET_SIZE = 60 * 2 # duration in seconds

Expand All @@ -21,7 +24,7 @@ def increment_request_count(team_id: int, count: int = 1) -> None:
capture_exception(error)


def capture_team_decide_usage(ph_client: Posthog, team_id: int, team_uuid: str) -> None:
def capture_team_decide_usage(ph_client: "Posthog", team_id: int, team_uuid: str) -> None:
try:
client = get_client()
total_request_count = 0
Expand Down

0 comments on commit a284675

Please sign in to comment.