Skip to content

Commit

Permalink
[fix] Analytics sender need to be started
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Apr 9, 2024
1 parent c156e36 commit 4c2d72a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fixbackend/analytics/analytics_event_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from async_lru import alru_cache
from fixcloudutils.asyncio.periodic import Periodic
from fixcloudutils.service import Service
from fixcloudutils.types import Json
from fixcloudutils.util import uuid_str, utc
from httpx import AsyncClient
Expand All @@ -50,7 +51,7 @@ async def user_id_from_workspace(self, workspace_id: WorkspaceId) -> UserId:
return UserId(uuid.uuid5(uuid.NAMESPACE_DNS, "fixbackend"))


class MultiAnalyticsEventSender(AnalyticsEventSender):
class MultiAnalyticsEventSender(AnalyticsEventSender, Service):
def __init__(self, senders: List[AnalyticsEventSender]) -> None:
self.senders = senders
self.event_handler: Optional[Any] = None
Expand All @@ -64,6 +65,14 @@ async def user_id_from_workspace(self, workspace_id: WorkspaceId) -> UserId:
return await sender.user_id_from_workspace(workspace_id)
raise ValueError("No senders configured")

async def start(self) -> Any:
for sender in self.senders:
await sender.start()

async def stop(self) -> None:
for sender in self.senders:
await sender.stop()


class GoogleAnalyticsEventSender(AnalyticsEventSender):
def __init__(
Expand Down

0 comments on commit 4c2d72a

Please sign in to comment.