Skip to content

Commit

Permalink
Feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
roquebetioljr committed Dec 12, 2024
1 parent 5e50f9c commit 5ce5f92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/planscape/analytics/services.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
from typing import AnyStr

from django.conf import settings
from django.utils.timezone import now

from analytics.tasks import async_collect_metric


def collect_metric(event_name: AnyStr, **kwargs) -> None:
if not settings.ANALYTICS_ENABLED:
return

event_params = {
"timestamp": now(),
**kwargs
}
if settings.ANALYTICS_DEBUG_MODE:
event_params.update({"debug_mode": True})

async_collect_metric.delay(event_name, event_params)
2 changes: 2 additions & 0 deletions src/planscape/planscape/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@
GDAL_CACHE_MAX = config("GDAL_CACHE_MAX", "15%")

# Analytics
ANALYTICS_ENABLED = config("ANALYTICS_ENABLED", default=False)
ANALYTICS_DEBUG_MODE = config("ANALYTICS_DEBUG_MODE", default=False)
FIREBASE_APP_ID = config("FIREBASE_APP_ID", default=None)
FIREBASE_APP_INSTANCE_ID = config("FIREBASE_APP_INSTANCE_ID", default=None)
FIREBASE_API_SECRET = config("FIREBASE_API_SECRET", default=None)

0 comments on commit 5ce5f92

Please sign in to comment.