Skip to content

Commit ed18a38

Browse files
Revert "feat(notification-center): Add LogEvent notification (#204)"
This reverts commit 7d291fe.
1 parent 7d291fe commit ed18a38

File tree

4 files changed

+5
-71
lines changed

4 files changed

+5
-71
lines changed

optimizely/event/event_processor.py

+2-18
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
from six.moves import queue
2020

2121
from optimizely import logger as _logging
22-
from optimizely import notification_center as _notification_center
2322
from optimizely.event_dispatcher import EventDispatcher as default_event_dispatcher
24-
from optimizely.helpers import enums
2523
from optimizely.helpers import validator
2624
from .event_factory import EventFactory
2725
from .user_event import UserEvent
@@ -64,10 +62,8 @@ def __init__(self,
6462
event_queue=None,
6563
batch_size=None,
6664
flush_interval=None,
67-
timeout_interval=None,
68-
notification_center=None):
69-
""" EventProcessor init method to configure event batching.
70-
65+
timeout_interval=None):
66+
""" BatchEventProcessor init method to configure event batching.
7167
Args:
7268
event_dispatcher: Provides a dispatch_event method which if given a URL and params sends a request to it.
7369
logger: Provides a log method to log messages. By default nothing would be logged.
@@ -80,7 +76,6 @@ def __init__(self,
8076
be flushed.
8177
timeout_interval: Optional floating point number representing time interval in seconds before joining the consumer
8278
thread.
83-
notification_center: Optional instance of notification_center.NotificationCenter.
8479
"""
8580
self.event_dispatcher = event_dispatcher or default_event_dispatcher
8681
self.logger = _logging.adapt_logger(logger or _logging.NoOpLogger())
@@ -93,13 +88,8 @@ def __init__(self,
9388
self.timeout_interval = timedelta(seconds=timeout_interval) \
9489
if self._validate_intantiation_props(timeout_interval, 'timeout_interval') \
9590
else self._DEFAULT_TIMEOUT_INTERVAL
96-
self.notification_center = notification_center
9791
self._current_batch = list()
9892

99-
if not validator.is_notification_center_valid(self.notification_center):
100-
self.logger.error(enums.Errors.INVALID_INPUT.format('notification_center'))
101-
self.notification_center = _notification_center.NotificationCenter()
102-
10393
if start_on_init is True:
10494
self.start()
10595

@@ -205,12 +195,6 @@ def _flush_queue(self):
205195

206196
log_event = EventFactory.create_log_event(to_process_batch, self.logger)
207197

208-
if self.notification_center is not None:
209-
self.notification_center.send_notifications(
210-
enums.NotificationTypes.LOG_EVENT,
211-
log_event
212-
)
213-
214198
try:
215199
self.event_dispatcher.dispatch_event(log_event)
216200
except Exception as e:

optimizely/helpers/enums.py

-4
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,8 @@ class NotificationTypes(object):
121121
122122
TRACK notification listener has the following parameters:
123123
str event_key, str user_id, dict attributes (can be None), event_tags (can be None), Event event
124-
125-
LOG_EVENT notification listener has the following parameter(s):
126-
LogEvent log_event
127124
"""
128125
ACTIVATE = 'ACTIVATE:experiment, user_id, attributes, variation, event'
129126
DECISION = 'DECISION:type, user_id, attributes, decision_info'
130127
OPTIMIZELY_CONFIG_UPDATE = 'OPTIMIZELY_CONFIG_UPDATE'
131128
TRACK = 'TRACK:event_key, user_id, attributes, event_tags, event'
132-
LOG_EVENT = 'LOG_EVENT:log_event'

tests/test_event_processor.py

+3-33
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717
from six.moves import queue
1818

1919
from . import base
20+
from optimizely.logger import SimpleLogger
2021
from optimizely.event.payload import Decision, Visitor
21-
from optimizely.event.event_processor import BatchEventProcessor
22-
from optimizely.event.log_event import LogEvent
2322
from optimizely.event.user_event_factory import UserEventFactory
24-
from optimizely.helpers import enums
25-
from optimizely.logger import SimpleLogger
23+
from optimizely.event.event_processor import BatchEventProcessor
2624

2725

2826
class CanonicalEvent(object):
@@ -112,7 +110,6 @@ def setUp(self, *args, **kwargs):
112110
self.event_name = 'test_event'
113111
self.event_queue = queue.Queue(maxsize=self.DEFAULT_QUEUE_CAPACITY)
114112
self.optimizely.logger = SimpleLogger()
115-
self.notification_center = self.optimizely.notification_center
116113

117114
def tearDown(self):
118115
self._event_processor.stop()
@@ -128,8 +125,7 @@ def _set_event_processor(self, event_dispatcher, logger):
128125
self.event_queue,
129126
self.MAX_BATCH_SIZE,
130127
self.MAX_DURATION_SEC,
131-
self.MAX_TIMEOUT_INTERVAL_SEC,
132-
self.optimizely.notification_center
128+
self.MAX_TIMEOUT_INTERVAL_SEC
133129
)
134130

135131
def test_drain_on_stop(self):
@@ -375,29 +371,3 @@ def test_init__NaN_timeout_interval(self):
375371
# default timeout interval is 5s.
376372
self.assertEqual(self._event_processor.timeout_interval, timedelta(seconds=5))
377373
mock_config_logging.info.assert_called_with('Using default value for timeout_interval.')
378-
379-
def test_notification_center__on_log_event(self):
380-
381-
mock_event_dispatcher = mock.Mock()
382-
callback_hit = [False]
383-
384-
def on_log_event(log_event):
385-
self.assertStrictTrue(isinstance(log_event, LogEvent))
386-
callback_hit[0] = True
387-
388-
self.optimizely.notification_center.add_notification_listener(
389-
enums.NotificationTypes.LOG_EVENT, on_log_event
390-
)
391-
392-
with mock.patch.object(self.optimizely, 'logger') as mock_config_logging:
393-
self._set_event_processor(mock_event_dispatcher, mock_config_logging)
394-
395-
user_event = self._build_conversion_event(self.event_name, self.project_config)
396-
self._event_processor.process(user_event)
397-
398-
self._event_processor.stop()
399-
400-
self.assertEqual(True, callback_hit[0])
401-
self.assertEqual(1, len(self.optimizely.notification_center.notification_listeners[
402-
enums.NotificationTypes.LOG_EVENT
403-
]))

tests/test_notification_center.py

-16
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ def on_track_listener(*args):
3434
pass
3535

3636

37-
def on_log_event_listener(*args):
38-
pass
39-
40-
4137
class NotificationCenterTest(unittest.TestCase):
4238

4339
def test_add_notification_listener__valid_type(self):
@@ -63,11 +59,6 @@ def test_add_notification_listener__valid_type(self):
6359
4, test_notification_center.add_notification_listener(enums.NotificationTypes.TRACK, on_track_listener)
6460
)
6561

66-
self.assertEqual(
67-
5, test_notification_center.add_notification_listener(enums.NotificationTypes.LOG_EVENT,
68-
on_log_event_listener)
69-
)
70-
7162
def test_add_notification_listener__multiple_listeners(self):
7263
""" Test that multiple listeners of the same type can be successfully added. """
7364

@@ -147,7 +138,6 @@ def another_on_activate_listener(*args):
147138
self.assertEqual(2, len(test_notification_center.notification_listeners[enums.NotificationTypes.ACTIVATE]))
148139
self.assertEqual(1, len(test_notification_center.notification_listeners[enums.NotificationTypes.DECISION]))
149140
self.assertEqual(0, len(test_notification_center.notification_listeners[enums.NotificationTypes.TRACK]))
150-
self.assertEqual(0, len(test_notification_center.notification_listeners[enums.NotificationTypes.LOG_EVENT]))
151141

152142
# Remove one of the activate listeners and assert.
153143
self.assertTrue(test_notification_center.remove_notification_listener(3))
@@ -174,10 +164,6 @@ def another_on_activate_listener(*args):
174164
3, test_notification_center.add_notification_listener(enums.NotificationTypes.ACTIVATE,
175165
another_on_activate_listener)
176166
)
177-
self.assertEqual(
178-
4, test_notification_center.add_notification_listener(enums.NotificationTypes.LOG_EVENT,
179-
on_log_event_listener)
180-
)
181167

182168
# Try removing a listener which does not exist.
183169
self.assertFalse(test_notification_center.remove_notification_listener(42))
@@ -194,7 +180,6 @@ def test_clear_notification_listeners(self):
194180
on_config_update_listener)
195181
test_notification_center.add_notification_listener(enums.NotificationTypes.DECISION, on_decision_listener)
196182
test_notification_center.add_notification_listener(enums.NotificationTypes.TRACK, on_track_listener)
197-
test_notification_center.add_notification_listener(enums.NotificationTypes.LOG_EVENT, on_log_event_listener)
198183

199184
# Assert all listeners are there:
200185
for notification_type in notification_center.NOTIFICATION_TYPES:
@@ -225,7 +210,6 @@ def test_clear_all_notification_listeners(self):
225210
on_config_update_listener)
226211
test_notification_center.add_notification_listener(enums.NotificationTypes.DECISION, on_decision_listener)
227212
test_notification_center.add_notification_listener(enums.NotificationTypes.TRACK, on_track_listener)
228-
test_notification_center.add_notification_listener(enums.NotificationTypes.LOG_EVENT, on_log_event_listener)
229213

230214
# Assert all listeners are there:
231215
for notification_type in notification_center.NOTIFICATION_TYPES:

0 commit comments

Comments
 (0)