From 2fc6de0ad8d58974e8d8c912e3f09f920abcc280 Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Fri, 2 Jun 2023 13:39:19 -0500 Subject: [PATCH] feat: add event bus backend --- eventtracking/backends/event_bus.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 eventtracking/backends/event_bus.py diff --git a/eventtracking/backends/event_bus.py b/eventtracking/backends/event_bus.py new file mode 100644 index 00000000..87fe085d --- /dev/null +++ b/eventtracking/backends/event_bus.py @@ -0,0 +1,26 @@ +"""Event tracker backend that emits events to the event-bus.""" +from openedx_events.analytics.signals import TRACKING_EVENT_EMITTED +from openedx_events.analytics.data import TrackingLogData + +class EventBusRoutingBackend: + """ + Event tracker backend that emits an Open edX public signal. + """ + + def __init__(self, **kwargs): + """ + Event tracker backend that emits an Open edX public signal. + """ + + def send(self, event): + """Emit the Open edX public signal""" + tracking_data = TrackingLogData( + name = event.get('name'), + timestamp = event.get('timestamp'), + data = event.get('data'), + context = event.get('context') + ) + + TRACKING_EVENT_EMITTED.send_event( + tracking_log=tracking_data + )