Skip to content

Commit

Permalink
Merge pull request #273 from openedx/cag/whitelist
Browse files Browse the repository at this point in the history
fix: whitelist multiple events
  • Loading branch information
Ian2012 committed Apr 2, 2024
2 parents 68fb152 + 1a9dbbd commit 488c1da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion eventtracking/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""A simple event tracking library"""

__version__ = '2.3.1'
__version__ = '2.3.2'
9 changes: 8 additions & 1 deletion eventtracking/processors/whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ def __init__(self, whitelist=None, **_kwargs):
) from error

def __call__(self, event):
if event['name'] not in self.whitelist:
"""
Filter out events whose names aren't on the whitelist.
The event can be a single event or a list of events (when using event-routing-backends with batching enabled).
"""
if isinstance(event, list):
return [e for e in event if e['name'] in self.whitelist]
elif event['name'] not in self.whitelist:
raise EventEmissionExit()

return event

0 comments on commit 488c1da

Please sign in to comment.