Skip to content

Commit a0ec811

Browse files
sidakramsoftvar
authored andcommitted
refactor(sdk): remove shouldTrackReturningVisitor option and its usage
1 parent d3475c9 commit a0ec811

15 files changed

+54
-224
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.23.0] - 2021-09-29
8+
9+
### Changed
10+
11+
- Remove `shouldTrackReturningVisitor` option as FullStack campaigns show unique visitors and conversions count. Duplicate visitors/conversions tracking calls would not be made if User Storage Service is used.
12+
713
## [1.22.0] - 2021-09-29
814

915
### Changed

tests/api/test_activate.py

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -200,29 +200,9 @@ def test_activate_against_T_100_W_33_33_33_WS_WW(self):
200200
test["variation"],
201201
)
202202

203-
def test_activate_invalid_should_track_returning_user_value_passed(self):
204-
self.set_up("AB_T_100_W_50_50")
205-
result = []
206-
result.append(self.vwo.activate("AB_T_100_W_50_50", "user", should_track_returning_user="test"))
207-
result.append(self.vwo.activate("AB_T_100_W_50_50", "user", should_track_returning_user=100))
208-
result.append(self.vwo.activate("AB_T_100_W_50_50", "user", should_track_returning_user=[]))
209-
result.append(self.vwo.activate("AB_T_100_W_50_50", "user", should_track_returning_user=()))
210-
result.append(self.vwo.activate("AB_T_100_W_50_50", "user", should_track_returning_user={}))
211-
self.assertListEqual(result, [None, None, None, None, None])
212-
213-
def test_activate_valid_should_track_returning_user_value_passed(self):
214-
self.set_up("AB_T_100_W_50_50")
215-
for test in USER_EXPECTATIONS.get("AB_T_100_W_50_50"):
216-
self.assertEqual(
217-
self.vwo.activate("AB_T_100_W_50_50", test["user"], should_track_returning_user=True), test["variation"]
218-
)
219-
220203
def test_activate_check_dedup_no_user_storage_provided(self):
221204
vwo_instance = vwo.launch(
222-
json.dumps(SETTINGS_FILES.get("AB_T_100_W_50_50")),
223-
is_development_mode=True,
224-
log_level=40,
225-
should_track_returning_user=True,
205+
json.dumps(SETTINGS_FILES.get("AB_T_100_W_50_50")), is_development_mode=True, log_level=40
226206
)
227207

228208
with mock.patch(
@@ -232,19 +212,15 @@ def test_activate_check_dedup_no_user_storage_provided(self):
232212
self.assertIs(mock_event_dispatcher_dispatch.call_count, 1)
233213
vwo_instance.activate("AB_T_100_W_50_50", "user")
234214
self.assertIs(mock_event_dispatcher_dispatch.call_count, 2)
235-
236-
vwo_instance.activate("AB_T_100_W_50_50", "user", should_track_returning_user=False)
215+
vwo_instance.activate("AB_T_100_W_50_50", "user")
237216
self.assertIs(mock_event_dispatcher_dispatch.call_count, 3)
238-
vwo_instance.activate("AB_T_100_W_50_50", "user", should_track_returning_user=False)
239-
self.assertIs(mock_event_dispatcher_dispatch.call_count, 4)
240217
mock_event_dispatcher_dispatch.reset_mock()
241218

242219
def test_activate_check_dedup_user_storage_provided(self):
243220
vwo_instance = vwo.launch(
244221
json.dumps(SETTINGS_FILES.get("AB_T_100_W_50_50")),
245222
is_development_mode=True,
246223
log_level=40,
247-
should_track_returning_user=False,
248224
user_storage=ClientUserStorage(),
249225
)
250226

@@ -255,9 +231,4 @@ def test_activate_check_dedup_user_storage_provided(self):
255231
self.assertIs(mock_event_dispatcher_dispatch.call_count, 1)
256232
vwo_instance.activate("AB_T_100_W_50_50", "user")
257233
self.assertIs(mock_event_dispatcher_dispatch.call_count, 1)
258-
259-
vwo_instance.activate("AB_T_100_W_50_50", "user", should_track_returning_user=True)
260-
self.assertIs(mock_event_dispatcher_dispatch.call_count, 2)
261-
vwo_instance.activate("AB_T_100_W_50_50", "user", should_track_returning_user=True)
262-
self.assertIs(mock_event_dispatcher_dispatch.call_count, 3)
263234
mock_event_dispatcher_dispatch.reset_mock()

tests/api/test_is_feature_enabled.py

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from ..config.config import TEST_LOG_LEVEL
2626

27+
2728
class ClientUserStorage:
2829
def __init__(self):
2930
self.storage = {}
@@ -199,61 +200,37 @@ def test_is_feature_enabled_against_FT_100_W_33_33_33_WS_WW(self):
199200
test["variation"] is not None and test["variation"] not in feature_not_enabled_variations,
200201
)
201202

202-
def test_is_feature_enabled_invalid_should_track_returning_user_value_passed(self):
203-
self.set_up("FT_T_100_W_10_20_30_40")
204-
result = []
205-
result.append(self.vwo.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user='test'))
206-
result.append(self.vwo.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user=100))
207-
result.append(self.vwo.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user=[]))
208-
result.append(self.vwo.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user=()))
209-
result.append(self.vwo.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user={}))
210-
self.assertListEqual(result, [False, False, False, False, False])
211-
212-
def test_is_feature_enabled_valid_should_track_returning_user_value_passed(self):
213-
self.set_up("FT_T_100_W_10_20_30_40")
214-
result = self.vwo.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user=True)
215-
self.assertIs(result, True)
216-
217203
def test_is_feature_enabled_check_dedup_no_user_storage_provided(self):
218204
vwo_instance = vwo.launch(
219-
json.dumps(SETTINGS_FILES.get("FT_T_100_W_10_20_30_40")),
220-
is_development_mode=True,
221-
log_level=40,
222-
should_track_returning_user=True
205+
json.dumps(SETTINGS_FILES.get("FT_T_100_W_10_20_30_40")), is_development_mode=True, log_level=40
223206
)
224207

225-
with mock.patch("vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None) as mock_event_dispatcher_dispatch:
208+
with mock.patch(
209+
"vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None
210+
) as mock_event_dispatcher_dispatch:
226211
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user")
227212
self.assertIs(mock_event_dispatcher_dispatch.call_count, 1)
228213
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user")
229214
self.assertIs(mock_event_dispatcher_dispatch.call_count, 2)
230-
231-
# Override global should_track_returning_user True value with False
232-
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user=False)
215+
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user")
233216
self.assertIs(mock_event_dispatcher_dispatch.call_count, 3)
234-
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user=False)
235-
self.assertIs(mock_event_dispatcher_dispatch.call_count, 4)
236217
mock_event_dispatcher_dispatch.reset_mock()
237218

238219
def test_is_feature_enabled_check_dedup_user_storage_provided(self):
239220
vwo_instance = vwo.launch(
240221
json.dumps(SETTINGS_FILES.get("FT_T_100_W_10_20_30_40")),
241222
is_development_mode=True,
242223
log_level=40,
243-
should_track_returning_user=False,
244-
user_storage=ClientUserStorage()
224+
user_storage=ClientUserStorage(),
245225
)
246226

247-
with mock.patch("vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None) as mock_event_dispatcher_dispatch:
227+
with mock.patch(
228+
"vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None
229+
) as mock_event_dispatcher_dispatch:
230+
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user")
231+
self.assertIs(mock_event_dispatcher_dispatch.call_count, 1)
248232
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user")
249233
self.assertIs(mock_event_dispatcher_dispatch.call_count, 1)
250234
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user")
251235
self.assertIs(mock_event_dispatcher_dispatch.call_count, 1)
252-
253-
# Override global should_track_returning_user False value with True
254-
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user=True)
255-
self.assertIs(mock_event_dispatcher_dispatch.call_count, 2)
256-
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user", should_track_returning_user=True)
257-
self.assertIs(mock_event_dispatcher_dispatch.call_count, 3)
258236
mock_event_dispatcher_dispatch.reset_mock()
259-

tests/api/test_launch.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,3 @@ def test_launch_valid_goal_type_to_track_passed(self):
8383
json.dumps(SETTINGS_FILES.get("AB_T_50_W_50_50")), goal_type_to_track=vwo.GOAL_TYPES.ALL
8484
)
8585
self.assertIsInstance(vwo_instance, vwo.vwo.VWO)
86-
87-
def test_launch_invalid_should_track_returning_user_passed(self):
88-
vwo_instance = vwo.launch(json.dumps(SETTINGS_FILES.get("AB_T_50_W_50_50")), should_track_returning_user="abcd")
89-
self.assertIsNone(vwo_instance)
90-
91-
def test_launch_valid_should_track_returning_user_passed(self):
92-
vwo_instance = vwo.launch(json.dumps(SETTINGS_FILES.get("AB_T_50_W_50_50")), should_track_returning_user=True)
93-
self.assertIsInstance(vwo_instance, vwo.vwo.VWO)

tests/api/test_track.py

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -295,27 +295,6 @@ def test_track_against_T_100_W_33_33_33_WS_WW(self):
295295
def track_test(self, expected, actual):
296296
self.assertDictEqual(expected, {self.campaign_key: actual})
297297

298-
def test_should_track_returning_user_false(self):
299-
self.set_up("AB_T_100_W_33_33_33", user_storage=ClientUserStorage())
300-
for test in USER_EXPECTATIONS[self.campaign_key]:
301-
self.vwo.activate(self.campaign_key, test["user"])
302-
self.track_test(
303-
self.vwo.track(self.campaign_key, test["user"], self.goal_identifier), test["variation"] is not None
304-
)
305-
self.track_test(self.vwo.track(self.campaign_key, test["user"], self.goal_identifier), False)
306-
307-
def test_should_track_returning_user_true(self):
308-
self.set_up("AB_T_100_W_33_33_33", user_storage=ClientUserStorage())
309-
for test in USER_EXPECTATIONS[self.campaign_key]:
310-
self.vwo.activate(self.campaign_key, test["user"])
311-
self.track_test(
312-
self.vwo.track(self.campaign_key, test["user"], self.goal_identifier), test["variation"] is not None
313-
)
314-
self.track_test(
315-
self.vwo.track(self.campaign_key, test["user"], self.goal_identifier, should_track_returning_user=True),
316-
test["variation"] is not None,
317-
)
318-
319298
def test_multi_track_none(self):
320299
vwo_instance = vwo.launch(
321300
json.dumps(SETTINGS_FILES.get("GLOBAL_TRACK_SETTINGS_FILE")),
@@ -553,15 +532,6 @@ def test_invalid_goal_type_passed_should_return_None(self):
553532
result = vwo_instance.track(None, "user", "track2", goal_type_to_track="vwo.GOAL_TYPES.CUSTOM")
554533
self.assertIsNone(result)
555534

556-
def test_invalid_should_track_returning_user_passed_should_return_None(self):
557-
vwo_instance = vwo.launch(
558-
json.dumps(SETTINGS_FILES.get("GLOBAL_TRACK_SETTINGS_FILE")), is_development_mode=True
559-
)
560-
vwo_instance.activate("global_test_1", "user")
561-
vwo_instance.is_feature_enabled("feature_test_1", "user")
562-
result = vwo_instance.track(None, "user", "track2", should_track_returning_user="True")
563-
self.assertIsNone(result)
564-
565535
def test_no_global_goal_found(self):
566536
vwo_instance = vwo.launch(
567537
json.dumps(SETTINGS_FILES.get("GLOBAL_TRACK_SETTINGS_FILE")), is_development_mode=True
@@ -587,25 +557,24 @@ def test_track_should_add_goalIdentifiers_if_variation_is_found_in_user_storage_
587557
vwo_instance.track("AB_T_100_W_50_50", "user", "CUSTOM")
588558
self.assertEquals(user_storage.get("user", "AB_T_100_W_50_50").get("goalIdentifiers"), "CUSTOM")
589559

590-
591560
def test_track_should_work_when_called_before_is_feature_enabled_when_no_user_storage_provided(self):
592-
vwo_instance = vwo.launch(
593-
json.dumps(SETTINGS_FILES.get("FT_T_100_W_10_20_30_40")), is_development_mode=True
594-
)
561+
vwo_instance = vwo.launch(json.dumps(SETTINGS_FILES.get("FT_T_100_W_10_20_30_40")), is_development_mode=True)
595562

596-
with mock.patch("vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None) as mock_event_dispatcher_dispatch:
563+
with mock.patch(
564+
"vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None
565+
) as mock_event_dispatcher_dispatch:
597566
vwo_instance.track("FT_T_100_W_10_20_30_40", "user", "FEATURE_TEST_GOAL")
598567
self.assertEqual(mock_event_dispatcher_dispatch.call_count, 1)
599568
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user")
600569
self.assertEqual(mock_event_dispatcher_dispatch.call_count, 2)
601570
mock_event_dispatcher_dispatch.reset_mock()
602571

603572
def test_track_should_work_when_called_before_activate_when_no_user_storage_provided(self):
604-
vwo_instance = vwo.launch(
605-
json.dumps(SETTINGS_FILES.get("AB_T_100_W_50_50")), is_development_mode=True
606-
)
573+
vwo_instance = vwo.launch(json.dumps(SETTINGS_FILES.get("AB_T_100_W_50_50")), is_development_mode=True)
607574

608-
with mock.patch("vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None) as mock_event_dispatcher_dispatch:
575+
with mock.patch(
576+
"vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None
577+
) as mock_event_dispatcher_dispatch:
609578
vwo_instance.track("AB_T_100_W_50_50", "user", "CUSTOM")
610579
self.assertEqual(mock_event_dispatcher_dispatch.call_count, 1)
611580
vwo_instance.activate("AB_T_100_W_50_50", "user")
@@ -615,10 +584,14 @@ def test_track_should_work_when_called_before_activate_when_no_user_storage_prov
615584
def test_track_should_fail_when_called_before_is_feature_enabled_when_user_storage_provided(self):
616585
user_storage = ClientUserStorage()
617586
vwo_instance = vwo.launch(
618-
json.dumps(SETTINGS_FILES.get("FT_T_100_W_10_20_30_40")), is_development_mode=True, user_storage=user_storage
587+
json.dumps(SETTINGS_FILES.get("FT_T_100_W_10_20_30_40")),
588+
is_development_mode=True,
589+
user_storage=user_storage,
619590
)
620591

621-
with mock.patch("vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None) as mock_event_dispatcher_dispatch:
592+
with mock.patch(
593+
"vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None
594+
) as mock_event_dispatcher_dispatch:
622595
vwo_instance.track("FT_T_100_W_10_20_30_40", "user", "FEATURE_TEST_GOAL")
623596
self.assertEqual(mock_event_dispatcher_dispatch.call_count, 0)
624597
vwo_instance.is_feature_enabled("FT_T_100_W_10_20_30_40", "user")
@@ -631,9 +604,11 @@ def test_track_should_fail_when_called_before_activate_when_user_storage_provide
631604
json.dumps(SETTINGS_FILES.get("AB_T_100_W_50_50")), is_development_mode=True, user_storage=user_storage
632605
)
633606

634-
with mock.patch("vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None) as mock_event_dispatcher_dispatch:
607+
with mock.patch(
608+
"vwo.event.event_dispatcher.EventDispatcher.dispatch", return_value=None
609+
) as mock_event_dispatcher_dispatch:
635610
vwo_instance.track("AB_T_100_W_50_50", "user", "CUSTOM")
636611
self.assertEqual(mock_event_dispatcher_dispatch.call_count, 0)
637612
vwo_instance.activate("AB_T_100_W_50_50", "user")
638613
self.assertEqual(mock_event_dispatcher_dispatch.call_count, 1)
639-
mock_event_dispatcher_dispatch.reset_mock()
614+
mock_event_dispatcher_dispatch.reset_mock()

tests/services/test_hooks_manager.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ def test_hooks_manager_ab_test(self):
105105
json.dumps(SETTINGS_FILES.get("AB_T_100_W_50_50")),
106106
is_development_mode=True,
107107
log_level=40,
108-
should_track_returning_user=False,
109108
integrations=Integrations(),
110109
)
111110

@@ -139,7 +138,6 @@ def test_hooks_manager_feature_test(self):
139138
json.dumps(SETTINGS_FILES.get("FT_T_100_W_10_20_30_40")),
140139
is_development_mode=True,
141140
log_level=40,
142-
should_track_returning_user=False,
143141
integrations=Integrations(),
144142
)
145143

@@ -171,7 +169,6 @@ def test_hooks_manager_feature_rollout(self):
171169
json.dumps(SETTINGS_FILES.get("FR_T_100_W_100")),
172170
is_development_mode=True,
173171
log_level=40,
174-
should_track_returning_user=False,
175172
integrations=Integrations(),
176173
)
177174

@@ -202,7 +199,6 @@ def test_hooks_manager_feature_rollout_user_storage_provided(self):
202199
json.dumps(SETTINGS_FILES.get("FR_T_100_W_100")),
203200
is_development_mode=True,
204201
log_level=40,
205-
should_track_returning_user=False,
206202
user_storage=ClientUserStorage(),
207203
integrations=Integrations(),
208204
)
@@ -239,7 +235,6 @@ def test_hooks_manager_track_goal(self):
239235
json.dumps(SETTINGS_FILES.get("T_100_W_50_50_WS")),
240236
is_development_mode=True,
241237
log_level=40,
242-
should_track_returning_user=False,
243238
integrations=Integrations(),
244239
)
245240

@@ -272,7 +267,6 @@ def test_hooks_manager_user_storage_provided(self):
272267
json.dumps(SETTINGS_FILES.get("FT_T_100_W_10_20_30_40")),
273268
is_development_mode=True,
274269
log_level=40,
275-
should_track_returning_user=False,
276270
user_storage=ClientUserStorage(),
277271
integrations=Integrations(),
278272
)
@@ -310,7 +304,6 @@ def test_hooks_manager_whitelisting_enabled(self):
310304
json.dumps(SETTINGS_FILES.get("FT_100_W_33_33_33_WS_WW")),
311305
is_development_mode=True,
312306
log_level=40,
313-
should_track_returning_user=False,
314307
integrations=Integrations(),
315308
)
316309

@@ -346,7 +339,6 @@ def test_hooks_manager_custom_variables_provided(self):
346339
json.dumps(SETTINGS_FILES.get("T_100_W_50_50_WS")),
347340
is_development_mode=True,
348341
log_level=40,
349-
should_track_returning_user=False,
350342
integrations=Integrations(),
351343
)
352344

0 commit comments

Comments
 (0)