wingify-fme-python-sdk 1.70.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. tests/data/__init__.py +13 -0
  2. tests/data/dummy_test_data_reader.py +63 -0
  3. tests/data/user_storage.py +48 -0
  4. tests/e2e/__init__.py +13 -0
  5. tests/e2e/custom_bucketing_test.py +514 -0
  6. tests/e2e/force_users_test.py +368 -0
  7. tests/e2e/get_flag_test.py +195 -0
  8. tests/unit/__init__.py +13 -0
  9. tests/unit/packages/__init__.py +13 -0
  10. tests/unit/packages/decision_maker/__init__.py +13 -0
  11. tests/unit/packages/decision_maker/decision_maker_test.py +83 -0
  12. tests/unit/packages/segmentation_evaluator/__init__.py +13 -0
  13. tests/unit/packages/segmentation_evaluator/segmentation_evaluator_test.py +284 -0
  14. tests/unit/packages/segmentation_evaluator/segmentation_manager_test.py +215 -0
  15. tests/unit/packages/segmentation_evaluator/web_testing_segment_test.py +216 -0
  16. tests/unit/services/__init__.py +0 -0
  17. tests/unit/services/hooks_manager_test.py +80 -0
  18. tests/unit/services/internal_events_sampling_service_test.py +160 -0
  19. tests/unit/settings/__init__.py +13 -0
  20. tests/unit/settings/settings_schema_validation_test.py +67 -0
  21. tests/unit/utils/__init__.py +0 -0
  22. tests/unit/utils/campaign_util_test.py +248 -0
  23. tests/unit/utils/decision_util_force_users_test.py +790 -0
  24. tests/unit/utils/log_message_test.py +65 -0
  25. tests/unit/vwo_wingify_test.py +175 -0
  26. tests/unit/wingify_client_validation_test.py +72 -0
  27. vwo/__init__.py +35 -0
  28. vwo/models/__init__.py +13 -0
  29. vwo/models/batch_event_data.py +19 -0
  30. vwo/models/user/__init__.py +13 -0
  31. vwo/models/user/context_vwo_model.py +21 -0
  32. vwo/models/user/get_flag.py +19 -0
  33. vwo/models/vwo_options_model.py +21 -0
  34. vwo/packages/__init__.py +13 -0
  35. vwo/packages/logger/__init__.py +13 -0
  36. vwo/packages/logger/enums/__init__.py +13 -0
  37. vwo/packages/logger/enums/log_level_enum.py +19 -0
  38. vwo/packages/storage/__init__.py +13 -0
  39. vwo/packages/storage/connector.py +19 -0
  40. vwo/vwo.py +58 -0
  41. vwo/vwo_builder.py +21 -0
  42. vwo/vwo_client.py +22 -0
  43. wingify/__init__.py +36 -0
  44. wingify/api/__init__.py +13 -0
  45. wingify/api/get_flag_api.py +727 -0
  46. wingify/api/set_attribute_api.py +60 -0
  47. wingify/api/track_api.py +99 -0
  48. wingify/constants/Constants.py +94 -0
  49. wingify/constants/__init__.py +13 -0
  50. wingify/constants/sampled_debug_error_template_keys.py +34 -0
  51. wingify/decorators/__init__.py +13 -0
  52. wingify/decorators/storage_decorator.py +92 -0
  53. wingify/enums/__init__.py +13 -0
  54. wingify/enums/api_enum.py +26 -0
  55. wingify/enums/campaign_type_enum.py +22 -0
  56. wingify/enums/debug_category_enum.py +24 -0
  57. wingify/enums/event_enum.py +26 -0
  58. wingify/enums/headers_enum.py +21 -0
  59. wingify/enums/hooks_enum.py +24 -0
  60. wingify/enums/status_enum.py +21 -0
  61. wingify/enums/storage_enum.py +25 -0
  62. wingify/enums/url_enum.py +29 -0
  63. wingify/models/Alias.py +60 -0
  64. wingify/models/AliasSetResponse.py +43 -0
  65. wingify/models/__init__.py +13 -0
  66. wingify/models/batch_event_data.py +68 -0
  67. wingify/models/campaign/__init__.py +13 -0
  68. wingify/models/campaign/campaign_model.py +140 -0
  69. wingify/models/campaign/feature_model.py +95 -0
  70. wingify/models/campaign/holdout_model.py +94 -0
  71. wingify/models/campaign/impact_campaign_model.py +60 -0
  72. wingify/models/campaign/metric_model.py +42 -0
  73. wingify/models/campaign/rule_model.py +42 -0
  74. wingify/models/campaign/variable_model.py +44 -0
  75. wingify/models/campaign/variation_model.py +109 -0
  76. wingify/models/gateway_service_model.py +48 -0
  77. wingify/models/schemas/__init__.py +13 -0
  78. wingify/models/schemas/campaign_group_schema.py +19 -0
  79. wingify/models/schemas/campaign_metric_schema.py +26 -0
  80. wingify/models/schemas/campaign_schema.py +37 -0
  81. wingify/models/schemas/campaign_variation_schema.py +34 -0
  82. wingify/models/schemas/empty_object_schema.py +15 -0
  83. wingify/models/schemas/feature_schema.py +38 -0
  84. wingify/models/schemas/group_schema.py +37 -0
  85. wingify/models/schemas/holdout_schema.py +29 -0
  86. wingify/models/schemas/rule_schema.py +24 -0
  87. wingify/models/schemas/settings_schema.py +47 -0
  88. wingify/models/schemas/variable_schema.py +24 -0
  89. wingify/models/settings/__init__.py +13 -0
  90. wingify/models/settings/internal_event_sampling_settings_model.py +53 -0
  91. wingify/models/settings/settings_model.py +127 -0
  92. wingify/models/storage/__init__.py +13 -0
  93. wingify/models/storage/storage_model.py +84 -0
  94. wingify/models/user/__init__.py +13 -0
  95. wingify/models/user/context_model.py +113 -0
  96. wingify/models/user/context_vwo_model.py +34 -0
  97. wingify/models/user/get_flag.py +47 -0
  98. wingify/models/vwo_options_model.py +21 -0
  99. wingify/models/wingify_options_model.py +129 -0
  100. wingify/packages/__init__.py +13 -0
  101. wingify/packages/decision_maker/__init__.py +13 -0
  102. wingify/packages/decision_maker/decision_maker.py +89 -0
  103. wingify/packages/logger/__init__.py +13 -0
  104. wingify/packages/logger/core/__init__.py +13 -0
  105. wingify/packages/logger/core/log_manager.py +123 -0
  106. wingify/packages/logger/core/log_transport_manager.py +57 -0
  107. wingify/packages/logger/enums/__init__.py +13 -0
  108. wingify/packages/logger/enums/log_level_enum.py +24 -0
  109. wingify/packages/logger/enums/log_level_number_enum.py +21 -0
  110. wingify/packages/logger/log_message_builder.py +70 -0
  111. wingify/packages/logger/logger.py +38 -0
  112. wingify/packages/logger/transports/__init__.py +13 -0
  113. wingify/packages/logger/transports/console_transport.py +43 -0
  114. wingify/packages/network_layer/__init__.py +13 -0
  115. wingify/packages/network_layer/client/__init__.py +13 -0
  116. wingify/packages/network_layer/client/network_client.py +167 -0
  117. wingify/packages/network_layer/handlers/__init__.py +13 -0
  118. wingify/packages/network_layer/handlers/request_handler.py +40 -0
  119. wingify/packages/network_layer/manager/__init__.py +13 -0
  120. wingify/packages/network_layer/manager/network_manager.py +79 -0
  121. wingify/packages/network_layer/models/__init__.py +13 -0
  122. wingify/packages/network_layer/models/global_request_model.py +70 -0
  123. wingify/packages/network_layer/models/request_model.py +133 -0
  124. wingify/packages/network_layer/models/response_model.py +55 -0
  125. wingify/packages/segmentation_evaluator/__init__.py +13 -0
  126. wingify/packages/segmentation_evaluator/core/__init__.py +13 -0
  127. wingify/packages/segmentation_evaluator/core/segmentation_manager.py +140 -0
  128. wingify/packages/segmentation_evaluator/enums/__init__.py +13 -0
  129. wingify/packages/segmentation_evaluator/enums/segment_operand_regex_enum.py +31 -0
  130. wingify/packages/segmentation_evaluator/enums/segment_operand_value_enum.py +29 -0
  131. wingify/packages/segmentation_evaluator/enums/segment_operator_value_enum.py +37 -0
  132. wingify/packages/segmentation_evaluator/evaluators/__init__.py +13 -0
  133. wingify/packages/segmentation_evaluator/evaluators/segment_evaluator.py +237 -0
  134. wingify/packages/segmentation_evaluator/evaluators/segment_operand_evaluator.py +518 -0
  135. wingify/packages/segmentation_evaluator/utils/__init__.py +13 -0
  136. wingify/packages/segmentation_evaluator/utils/segment_util.py +33 -0
  137. wingify/packages/segmentation_evaluator/utils/web_testing_segment_util.py +295 -0
  138. wingify/packages/storage/__init__.py +13 -0
  139. wingify/packages/storage/connector.py +25 -0
  140. wingify/packages/storage/storage.py +39 -0
  141. wingify/resources/__init__.py +13 -0
  142. wingify/resources/debug-messages.json +21 -0
  143. wingify/resources/error-messages.json +62 -0
  144. wingify/resources/info-message.json +47 -0
  145. wingify/resources/trace-messages.json +1 -0
  146. wingify/resources/warn-messages.json +1 -0
  147. wingify/services/__init__.py +13 -0
  148. wingify/services/batch_event_queue.py +140 -0
  149. wingify/services/campaign_decision_service.py +268 -0
  150. wingify/services/hooks_manager.py +65 -0
  151. wingify/services/internal_events_sampling_service.py +62 -0
  152. wingify/services/settings_manager.py +293 -0
  153. wingify/services/storage_service.py +58 -0
  154. wingify/services/url_service.py +51 -0
  155. wingify/utils/__init__.py +13 -0
  156. wingify/utils/aliasing_util.py +108 -0
  157. wingify/utils/brand_context.py +26 -0
  158. wingify/utils/brand_util.py +37 -0
  159. wingify/utils/campaign_util.py +592 -0
  160. wingify/utils/data_type_util.py +125 -0
  161. wingify/utils/debugger_service_util.py +58 -0
  162. wingify/utils/decision_util.py +589 -0
  163. wingify/utils/event_util.py +85 -0
  164. wingify/utils/function_util.py +188 -0
  165. wingify/utils/gateway_service_util.py +179 -0
  166. wingify/utils/holdout_util.py +264 -0
  167. wingify/utils/impression_util.py +151 -0
  168. wingify/utils/internal_events_sampling_util.py +106 -0
  169. wingify/utils/log_message_util.py +95 -0
  170. wingify/utils/meg_util.py +561 -0
  171. wingify/utils/model_utils.py +136 -0
  172. wingify/utils/network_util.py +706 -0
  173. wingify/utils/rule_evaluation_util.py +102 -0
  174. wingify/utils/settings_util.py +39 -0
  175. wingify/utils/usage_stats_util.py +116 -0
  176. wingify/utils/uuid_util.py +81 -0
  177. wingify/vwo_client.py +21 -0
  178. wingify/wingify.py +159 -0
  179. wingify/wingify_builder.py +282 -0
  180. wingify/wingify_client.py +520 -0
  181. wingify_fme_python_sdk-1.70.0.dist-info/METADATA +1415 -0
  182. wingify_fme_python_sdk-1.70.0.dist-info/RECORD +186 -0
  183. wingify_fme_python_sdk-1.70.0.dist-info/WHEEL +5 -0
  184. wingify_fme_python_sdk-1.70.0.dist-info/licenses/LICENSE +202 -0
  185. wingify_fme_python_sdk-1.70.0.dist-info/licenses/NOTICE +18 -0
  186. wingify_fme_python_sdk-1.70.0.dist-info/top_level.txt +3 -0
@@ -0,0 +1,60 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from ..models.settings.settings_model import SettingsModel
17
+ from ..models.user.context_model import ContextModel
18
+ from ..models.user.context_model import ContextModel
19
+ from typing import Dict, Any
20
+ from ..models.settings.settings_model import SettingsModel
21
+ from ..models.user.context_model import ContextModel
22
+ from ..utils.network_util import (
23
+ get_events_base_properties,
24
+ get_attribute_payload_data,
25
+ send_post_api_request,
26
+ )
27
+ from ..enums.event_enum import EventEnum
28
+
29
+
30
+
31
+ class SetAttributeApi:
32
+ def set_attribute(
33
+ self, settings: SettingsModel, attribute_map: Dict, context: ContextModel
34
+ ):
35
+ self.create_and_send_impression_for_attribute(settings, attribute_map, context)
36
+
37
+ def create_and_send_impression_for_attribute(
38
+ self, settings: SettingsModel, attribute_map: Dict, context: ContextModel
39
+ ):
40
+ properties = get_events_base_properties(
41
+ EventEnum.SYNC_VISITOR_PROP.value,
42
+ visitor_user_agent=context.get_user_agent(),
43
+ ip_address=context.get_ip_address(),
44
+ )
45
+ # Construct payload data for tracking the goal
46
+ payload = get_attribute_payload_data(
47
+ settings, context, EventEnum.SYNC_VISITOR_PROP.value, attribute_map
48
+ )
49
+
50
+ from wingify.wingify_client import WingifyClient as VWOClient
51
+
52
+ vwo_instance = VWOClient.get_instance()
53
+
54
+ # Check if batch events are enabled
55
+ if vwo_instance.batch_event_queue is not None:
56
+ # Enqueue the event to the batch queue
57
+ vwo_instance.batch_event_queue.enqueue(payload)
58
+ else:
59
+ # Send the event immediately if batch events are not enabled
60
+ send_post_api_request(properties, payload, context.get_id())
@@ -0,0 +1,99 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from ..models.settings.settings_model import SettingsModel
17
+ from ..models.user.context_model import ContextModel
18
+ from ..models.user.context_model import ContextModel
19
+ from ..services.hooks_manager import HooksManager
20
+ from ..packages.logger.core.log_manager import LogManager
21
+ from typing import Dict, Any
22
+ from ..utils.function_util import does_event_belong_to_any_feature, does_event_belong_to_any_holdout
23
+ from ..models.settings.settings_model import SettingsModel
24
+ from ..models.user.context_model import ContextModel
25
+ from ..utils.network_util import (
26
+ get_events_base_properties,
27
+ get_track_goal_payload_data,
28
+ send_post_api_request,
29
+ )
30
+ from ..enums.api_enum import ApiEnum
31
+ from ..utils.log_message_util import error_messages
32
+
33
+
34
+ class TrackApi:
35
+ def track(
36
+ self,
37
+ settings: SettingsModel,
38
+ event_name: str,
39
+ context: ContextModel,
40
+ event_properties: Dict[str, Any],
41
+ hook_manager: HooksManager,
42
+ ) -> Dict:
43
+ """
44
+ Tracks an event with given properties and context.
45
+ Checks if the event exists, creates an impression, and executes hooks.
46
+
47
+ :param settings: The settings file containing the account settings.
48
+ :param event_name: The name of the event to track.
49
+ :param event_properties: The properties of the event.
50
+ :param context: The context of the user.
51
+ :param hook_manager: The hook manager to execute hooks.
52
+ """
53
+ if does_event_belong_to_any_feature(event_name, settings) or does_event_belong_to_any_holdout(event_name, settings):
54
+ self.create_and_send_impression_for_track(
55
+ settings, event_name, context, event_properties
56
+ )
57
+ hook_manager.set({"event_name": event_name, "api": ApiEnum.TRACK_EVENT.value})
58
+ hook_manager.execute(hook_manager.get())
59
+ return {event_name: True}
60
+
61
+ LogManager.get_instance().error_log("EVENT_NOT_FOUND", data={"eventName": event_name}, debug_data={"an": ApiEnum.TRACK_EVENT.value, "uuid": context.get_vwo_uuid(), "sId": context.get_session_id()})
62
+ return {event_name: False}
63
+
64
+ def create_and_send_impression_for_track(
65
+ self,
66
+ settings: SettingsModel,
67
+ event_name: str,
68
+ context: ContextModel,
69
+ event_properties: Dict[str, Any],
70
+ ):
71
+ """
72
+ Creates an impression for a track event and sends it via a POST API request.
73
+
74
+ :param settings: The settings file containing the account settings.
75
+ :param event_name: The name of the event to track.
76
+ :param context: The context of the user.
77
+ :param event_properties: The properties of the event.
78
+ """
79
+ properties = get_events_base_properties(
80
+ event_name,
81
+ visitor_user_agent=context.get_user_agent(),
82
+ ip_address=context.get_ip_address(),
83
+ )
84
+ # Construct payload data for tracking the goal
85
+ payload = get_track_goal_payload_data(
86
+ settings, context, event_name, event_properties
87
+ )
88
+
89
+ from wingify.wingify_client import WingifyClient as VWOClient
90
+
91
+ vwo_instance = VWOClient.get_instance()
92
+
93
+ # Check if batch events are enabled
94
+ if vwo_instance.batch_event_queue is not None:
95
+ # Enqueue the event to the batch queue
96
+ vwo_instance.batch_event_queue.enqueue(payload)
97
+ else:
98
+ # Send the event immediately if batch events are not enabled
99
+ send_post_api_request(properties, payload, context.get_id())
@@ -0,0 +1,94 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ class Constants:
17
+ # TODO: read from setup.py
18
+ sdk_meta = {
19
+ "name": "vwo-fme-python-sdk",
20
+ "version": "1.70.0",
21
+ }
22
+
23
+ SDK_VERSION = sdk_meta["version"]
24
+
25
+ # Brand-specific values (runtime selection via is_via_vwo.
26
+ VWO_SDK_NAME = "vwo-fme-python-sdk"
27
+ WINGIFY_SDK_NAME = "wingify-fme-python-sdk"
28
+
29
+ VWO_HOST_NAME = "dev.visualwebsiteoptimizer.com"
30
+ WINGIFY_SETTINGS_HOST_NAME = "edge.wingify.net"
31
+ WINGIFY_COLLECTION_HOST_NAME = "collect.wingify.net"
32
+
33
+ VWO_LOG_PREFIX = "VWO-SDK"
34
+ WINGIFY_LOG_PREFIX = "Wingify-SDK"
35
+
36
+ VWO_BRAND_DISPLAY_NAME = "VWO"
37
+ WINGIFY_BRAND_DISPLAY_NAME = "Wingify"
38
+
39
+ PLATFORM = "server"
40
+
41
+ MAX_TRAFFIC_PERCENT = 100
42
+ MAX_TRAFFIC_VALUE = 10000
43
+ STATUS_RUNNING = "RUNNING"
44
+
45
+ SEED_VALUE = 1
46
+ MAX_EVENTS_PER_REQUEST = 5000
47
+ DEFAULT_REQUEST_TIME_INTERVAL = 600
48
+ DEFAULT_EVENTS_PER_REQUEST = 100
49
+
50
+ AP = "server"
51
+
52
+ SEED_URL = "https://example.com/seed"
53
+ HTTP_PROTOCOL = "http"
54
+ HTTPS_PROTOCOL = "https"
55
+
56
+ SETTINGS = "settings"
57
+ SETTINGS_EXPIRY = 10000000
58
+ SETTINGS_TIMEOUT = 50000
59
+ POLLING_INTERVAL = 600000
60
+
61
+ SETTINGS_ENDPOINT = "/server-side/v2-settings"
62
+ WEBHOOK_SETTINTS_ENDPOINT = "/server-side/v2-pull"
63
+ LOCATION_ENDPOINT = "/getLocation"
64
+
65
+ VWO_FS_ENVIRONMENT = "vwo_fs_environment"
66
+
67
+ RANDOM_ALGO = 1
68
+
69
+ VWO_META_MEG_KEY = "_vwo_meta_meg_"
70
+
71
+ THREAD_POOL_MAX_WORKERS = 5
72
+ SHOULD_USE_THREADING = True
73
+
74
+ MAX_RETRIES = 3
75
+ INITIAL_WAIT_TIME = 2
76
+ PRODUCT_NAME = "fme"
77
+
78
+ V2_SETTINGS = "v2-settings"
79
+ POLLING = "polling"
80
+ FLAG_DECISION_GIVEN = "FLAG_DECISION_GIVEN"
81
+ NETWORK_CALL_FAILURE_AFTER_MAX_RETRIES = "NETWORK_CALL_FAILURE_AFTER_MAX_RETRIES"
82
+ NETWORK_CALL_SUCCESS_WITH_RETRIES = "NETWORK_CALL_SUCCESS_WITH_RETRIES"
83
+ IMPACT_ANALYSIS = "IMPACT_ANALYSIS"
84
+
85
+ KEY_USER_ID = "userId"
86
+ KEY_ALIAS_ID = "aliasId"
87
+
88
+ VARIATION_IS_PART_OF_HOLDOUT = 1
89
+ VARIATION_NOT_PART_OF_HOLDOUT = 2
90
+
91
+ KEY_FORCED_USER_CHECK = "preSegmentationResult"
92
+
93
+ INTERNAL_EVENTS_DEFAULT_SAMPLING_PERCENT_SERVER = 10.0
94
+ INTERNAL_EVENTS_DEFAULT_ALWAYS_APPLY_SAMPLING = False
@@ -0,0 +1,13 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -0,0 +1,34 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ class SampledDebugErrorTemplateKeys:
16
+ """
17
+ Debug error template keys (`msg_t`) that are subject to sampling.
18
+ Keys not listed here always send and bypass sampling.
19
+ """
20
+ SAMPLED_KEYS = {
21
+ "EVENT_NOT_FOUND",
22
+ "FEATURE_NOT_FOUND",
23
+ "FEATURE_NOT_FOUND_WITH_ID"
24
+ }
25
+
26
+ @staticmethod
27
+ def contains(message_template_key: str) -> bool:
28
+ """
29
+ Checks whether a debug error template key should be sampled before sending.
30
+
31
+ :param message_template_key: The `msg_t` value from the debug event
32
+ :return: `True` if the key is in the sampled set; `False` otherwise
33
+ """
34
+ return message_template_key is not None and message_template_key in SampledDebugErrorTemplateKeys.SAMPLED_KEYS
@@ -0,0 +1,13 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -0,0 +1,92 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from ..models.user.context_model import ContextModel
17
+ from ..enums.storage_enum import StorageEnum
18
+ from ..models.campaign.variation_model import VariationModel
19
+ from typing import Any, Dict, Optional
20
+ from ..services.storage_service import StorageService
21
+ from ..packages.logger.core.log_manager import LogManager
22
+ from ..utils.log_message_util import error_messages
23
+ from ..enums.api_enum import ApiEnum
24
+
25
+
26
+ class StorageDecorator:
27
+ def get_feature_from_storage(
28
+ self, feature_key: str, context: ContextModel, storage_service: StorageService
29
+ ) -> Any:
30
+ campaign_map = storage_service.get_data_in_storage(feature_key, context)
31
+
32
+ if campaign_map.get("status") == StorageEnum.STORAGE_UNDEFINED.value:
33
+ return None # No storage defined
34
+ elif campaign_map.get("status") == StorageEnum.NO_DATA_FOUND.value:
35
+ return None # No data found in storage
36
+ elif campaign_map.get("status") == StorageEnum.INCORRECT_DATA.value:
37
+ return StorageEnum.INCORRECT_DATA.value # Incorrect data found
38
+ elif campaign_map.get("status") == StorageEnum.CAMPAIGN_PAUSED.value:
39
+ return None # Campaign is paused
40
+ elif campaign_map.get("status") == StorageEnum.VARIATION_NOT_FOUND.value:
41
+ return StorageEnum.VARIATION_NOT_FOUND.value # No variation found
42
+ elif campaign_map.get("status") == StorageEnum.WHITELISTED_VARIATION.value:
43
+ return None # Whitelisted variation, handle accordingly
44
+ else:
45
+ return campaign_map # Valid data found, return it
46
+
47
+ def set_data_in_storage(
48
+ self, data: Dict[Any, Any], storage_service: StorageService
49
+ ) -> Optional[VariationModel]:
50
+ feature_key = data.get("featureKey")
51
+ context = data.get("context")
52
+
53
+ if not feature_key:
54
+ LogManager.get_instance().error_log("ERROR_STORING_DATA_IN_STORAGE",data={"key": "featureKey"}, debug_data={"an": ApiEnum.GET_FLAG.value, "uuid": context.get_vwo_uuid(), "sId": context.get_session_id()})
55
+ return None # Invalid feature key, return None
56
+
57
+ if not context or not context.get_id():
58
+ LogManager.get_instance().error_log("ERROR_STORING_DATA_IN_STORAGE",data={"key": "Context or Context.id"}, debug_data={"an": ApiEnum.GET_FLAG.value, "uuid": context.get_vwo_uuid(), "sId": context.get_session_id()})
59
+ return None # Invalid user ID, return None
60
+
61
+ if (
62
+ data.get("rolloutKey")
63
+ and not data.get("experimentKey")
64
+ and not data.get("rolloutVariationId")
65
+ ):
66
+ LogManager.get_instance().error_log("ERROR_STORING_DATA_IN_STORAGE",data={"key": "rolloutKey or experimentKey or rolloutVariationId"}, debug_data={"an": ApiEnum.GET_FLAG.value, "uuid": context.get_vwo_uuid(), "sId": context.get_session_id()})
67
+ return None # Invalid rollout variation, return None
68
+
69
+ if data.get("experimentKey") and not data.get("experimentVariationId"):
70
+ LogManager.get_instance().error_log("ERROR_STORING_DATA_IN_STORAGE",data={"key": "Variation:(rolloutKey, experimentKey or rolloutVariationId)"}, debug_data={"an": ApiEnum.GET_FLAG.value, "uuid": context.get_vwo_uuid(), "sId": context.get_session_id()})
71
+ return None # Invalid experiment variation, return None
72
+
73
+ success = storage_service.set_data_in_storage(
74
+ {
75
+ "featureKey": feature_key,
76
+ "userId": context.get_id(),
77
+ "rolloutId": data.get("rolloutId"),
78
+ "rolloutKey": data.get("rolloutKey"),
79
+ "rolloutVariationId": data.get("rolloutVariationId"),
80
+ "experimentId": data.get("experimentId"),
81
+ "experimentKey": data.get("experimentKey"),
82
+ "experimentVariationId": data.get("experimentVariationId"),
83
+ "isInHoldoutId": data.get("isInHoldoutId"),
84
+ "notInHoldoutId": data.get("notInHoldoutId"),
85
+ },
86
+ context
87
+ )
88
+
89
+ if success:
90
+ return True
91
+ else:
92
+ return None
@@ -0,0 +1,13 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -0,0 +1,26 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from enum import Enum
17
+
18
+
19
+ class ApiEnum(Enum):
20
+ INIT = "init"
21
+ GET_FLAG = "getFlag"
22
+ TRACK_EVENT = "trackEvent"
23
+ SET_ATTRIBUTE = "setAttribute"
24
+ UPDATE_SETTINGS = "updateSettings"
25
+ FLUSH_EVENTS = "flushEvents"
26
+ SET_ALIAS = "setAlias"
@@ -0,0 +1,22 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from enum import Enum
17
+
18
+
19
+ class CampaignTypeEnum(Enum):
20
+ ROLLOUT = "FLAG_ROLLOUT"
21
+ AB = "FLAG_TESTING"
22
+ PERSONALIZE = "FLAG_PERSONALIZE"
@@ -0,0 +1,24 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from enum import Enum
17
+
18
+
19
+ class DebugCategoryEnum(Enum):
20
+ NETWORK = "network"
21
+ DECISION = "decision"
22
+ INITIALIZATION = "initialization"
23
+ RETRY = "retry"
24
+ ERROR = "error"
@@ -0,0 +1,26 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from enum import Enum
17
+
18
+
19
+ class EventEnum(Enum):
20
+ VARIATION_SHOWN = "vwo_variationShown"
21
+ SYNC_VISITOR_PROP = "vwo_syncVisitorProp"
22
+ LOG_EVENT = "vwo_log"
23
+ SDK_INIT_EVENT = "vwo_fmeSdkInit"
24
+ USAGE_STATS = "vwo_sdkUsageStats"
25
+ DEBUGGER_EVENT = "vwo_sdkDebug"
26
+ TRACK_USAGE = "vwo_feTrackUsage"
@@ -0,0 +1,21 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from enum import Enum
17
+
18
+
19
+ class HeadersEnum(Enum):
20
+ USER_AGENT = "X-Device-User-Agent"
21
+ IP = "VWO-X-Forwarded-For"
@@ -0,0 +1,24 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from enum import Enum
17
+
18
+
19
+ class DecisionTypes(Enum):
20
+ CAMPAIGN_DECISION = "CAMPAIGN_DECISION"
21
+
22
+
23
+ class HooksEnum:
24
+ DECISION_TYPES = DecisionTypes
@@ -0,0 +1,21 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from enum import Enum
17
+
18
+
19
+ class StatusEnum(Enum):
20
+ PASSED = "passed"
21
+ FAILED = "failed"
@@ -0,0 +1,25 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from enum import Enum
17
+
18
+
19
+ class StorageEnum(Enum):
20
+ STORAGE_UNDEFINED = "Storage is undefined"
21
+ INCORRECT_DATA = "Incorrect data"
22
+ NO_DATA_FOUND = "No data found"
23
+ CAMPAIGN_PAUSED = "Campaign paused"
24
+ VARIATION_NOT_FOUND = "Variation not found"
25
+ WHITELISTED_VARIATION = "Whitelisted variation"
@@ -0,0 +1,29 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from enum import Enum
16
+
17
+ from wingify.constants.Constants import Constants
18
+
19
+
20
+ class UrlEnum(Enum):
21
+ BASE_URL = Constants.WINGIFY_SETTINGS_HOST_NAME
22
+ SETTINGS_URL = "/server-side/settings"
23
+ # WEBHOOK_SETTINGS_URL = '/server-side/pull'
24
+ EVENTS = '/events/t'
25
+ ATTRIBUTE_CHECK = '/check-attribute'
26
+ GET_USER_DATA = '/get-user-details'
27
+ BATCH_EVENTS = '/server-side/batch-events-v2'
28
+ SET_ALIAS = '/user-alias/setUserAlias'
29
+ GET_ALIAS = '/user-alias/getAliasUserId'