Skip to content

Commit

Permalink
fix: only generate metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Oct 26, 2023
1 parent 9c56b7b commit eef9798
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions eventtracking/backends/event_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

logger = logging.getLogger(__name__)

EVENT_BUS_SOURCE = "openedx/eventtracking"

class EventBusRoutingBackend(RoutingBackend):
"""
Event tracker backend that emits an Open edX public signal.
Expand All @@ -38,22 +36,13 @@ def send(self, event):
context=context,
)

metadata = TRACKING_EVENT_EMITTED.generate_signal_metadata()

logger.info(f"Sending tracking event emitted signal for event for {tracking_log.name}")
get_producer().send(
signal=TRACKING_EVENT_EMITTED,
topic="analytics",
event_key_field="tracking_log.name",
event_data={"tracking_log": tracking_log},
event_metadata=generate_signal_metadata()
event_metadata=metadata,
)


def generate_signal_metadata():
"""
Generate the metadata for the signal with a custom source.
"""
metadata = TRACKING_EVENT_EMITTED.generate_signal_metadata()
medata_dict = asdict(metadata)
medata_dict["source"] = EVENT_BUS_SOURCE
metadata = EventsMetadata(**medata_dict)
return metadata
2 changes: 1 addition & 1 deletion eventtracking/backends/tests/test_event_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_successful_send_event(self, mock_get_producer):
data=json.dumps(self.sample_event['data']),
context=json.dumps(self.sample_event['context']),
)

)

@patch('eventtracking.backends.event_bus.SEND_TRACKING_EVENT_EMITTED_SIGNAL.is_enabled')
@patch('eventtracking.backends.event_bus.get_producer')
Expand Down

0 comments on commit eef9798

Please sign in to comment.