diff --git a/eventtracking/backends/event_bus.py b/eventtracking/backends/event_bus.py index d1e4588..8315f91 100644 --- a/eventtracking/backends/event_bus.py +++ b/eventtracking/backends/event_bus.py @@ -5,6 +5,7 @@ from openedx_events.analytics.data import TrackingLogData from openedx_events.analytics.signals import TRACKING_EVENT_EMITTED from openedx_events.event_bus import get_producer +from datetime import datetime from eventtracking.backends.routing import RoutingBackend from eventtracking.config import SEND_TRACKING_EVENT_EMITTED_SIGNAL @@ -28,9 +29,14 @@ def send(self, event): data = json.dumps(event.get("data")) context = json.dumps(event.get("context")) + timestamp = event.get("timestamp") + + if isinstance(timestamp, str): + timestamp = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%f%z") + tracking_log = TrackingLogData( name=event.get("name"), - timestamp=event.get("timestamp"), + timestamp=timestamp, data=data, context=context, )