Skip to content

Commit

Permalink
Moving analytics to Core app
Browse files Browse the repository at this point in the history
  • Loading branch information
roquebetioljr committed Dec 19, 2024
1 parent 80be7fb commit 77e9f22
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
20 changes: 0 additions & 20 deletions src/planscape/analytics/services.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@
import requests
import json
from typing import Dict, AnyStr, Any

from django.conf import settings
from django.utils.timezone import now
from planscape.celery import app

log = logging.getLogger(__name__)


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)



@app.task()
def async_collect_metric(event_name: AnyStr, event_params: Dict[str, Any]) -> None:
def _async_collect_metric(event_name: AnyStr, event_params: Dict[str, Any]) -> None:
""" """
if not all(
(
Expand Down
2 changes: 1 addition & 1 deletion src/planscape/planscape/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
"planning.tasks.*": {"queue": "forsys"},
"impacts.tasks.*": {"queue": "impacts"},
"e2e.tasks.*": {"queue": "default"},
"analytics.tasks.*": {"queue": "default"},
"core.tasks.*": {"queue": "default"},
}

CELERY_ALWAYS_EAGER = config("CELERY_ALWAYS_EAGER", False)
Expand Down

0 comments on commit 77e9f22

Please sign in to comment.