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,295 @@
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
+ import json
16
+ import math
17
+ import re
18
+ from typing import Any, Dict, Optional, Tuple
19
+
20
+ from ....models.user.context_model import ContextModel
21
+ from ....utils.data_type_util import (
22
+ get_type,
23
+ is_array,
24
+ is_boolean,
25
+ is_defined,
26
+ is_null,
27
+ is_number,
28
+ is_object,
29
+ is_string,
30
+ )
31
+ from ...logger.core.log_manager import LogManager
32
+ from ....enums.api_enum import ApiEnum
33
+ from ..enums.segment_operator_value_enum import SegmentOperatorValueEnum
34
+
35
+ _WEB_TESTING_JSON_STRING_KEY_REGEX = re.compile(r'"([^"\\]*)"\s*:')
36
+
37
+ def coerce_campaign_variation_operand_to_str(operand: Any) -> Optional[str]:
38
+ """
39
+ Coerces a campaignVariation operand to a string when the value is a valid string or finite number.
40
+
41
+ :param operand: Raw campaignVariation operand from the segmentation DSL.
42
+ :return: Coerced operand string, or None if the type cannot be coerced.
43
+ """
44
+ if is_null(operand):
45
+ return None
46
+ if is_boolean(operand):
47
+ return None
48
+ if is_string(operand):
49
+ return operand
50
+ if is_number(operand):
51
+ # bool excluded above; avoids treating True as 1 via int subclassing.
52
+ if type(operand) is float:
53
+ if not math.isfinite(operand):
54
+ return None
55
+ if operand.is_integer():
56
+ return str(int(operand))
57
+ return str(operand)
58
+ return str(operand)
59
+ if is_array(operand) or is_object(operand):
60
+ return None
61
+ return None
62
+
63
+
64
+ def normalize_web_testing_campaigns_map(web_testing_source: Dict) -> Dict[str, str]:
65
+ """
66
+ Normalizes a web_testing_campaigns map so campaign and variation IDs are non-empty string keys and values.
67
+
68
+ :param web_testing_source: Campaign ID to variation ID map from context or parsed JSON.
69
+ :return: Map with string campaign keys and string variation values.
70
+ """
71
+ normalized_campaigns_map: Dict[str, str] = {}
72
+ # iterate over the web testing source and normalize the campaign ids and variation ids
73
+ for campaign_key in web_testing_source:
74
+ variation_raw = web_testing_source[campaign_key]
75
+ # convert the campaign key to a string
76
+ campaign_key_as_str = str(campaign_key)
77
+ # if the variation raw is not None and the campaign key as string is not empty, then add the campaign key and variation to the normalized campaigns map
78
+ if is_defined(variation_raw) and len(campaign_key_as_str) > 0:
79
+ normalized_campaigns_map[campaign_key_as_str] = str(variation_raw)
80
+ return normalized_campaigns_map
81
+
82
+
83
+ def _log_first_duplicate_json_object_key_scan(
84
+ web_testing_campaigns_json: str,
85
+ context: ContextModel,
86
+ ) -> None:
87
+ """
88
+ Scans a web_testing_campaigns JSON string for duplicate object keys and logs the first duplicate found.
89
+
90
+ :param web_testing_campaigns_json: Trimmed JSON string of web_testing_campaigns.
91
+ :param context: User context used for debug metadata in the error log.
92
+ :return: None; parsing continues after logging (last duplicate value wins).
93
+ """
94
+ # set to track the keys seen so far
95
+ keys_seen_so_far = set()
96
+ # iterate over the web testing campaigns json and log the first duplicate json object key
97
+ for key_regex_match in _WEB_TESTING_JSON_STRING_KEY_REGEX.finditer(
98
+ web_testing_campaigns_json
99
+ ):
100
+ object_key_name = key_regex_match.group(1)
101
+ # if the object key name is already in the keys seen so far, then log an error
102
+ if object_key_name in keys_seen_so_far:
103
+ LogManager.get_instance().error_log(
104
+ "INVALID_WEB_TESTING_CAMPAIGNS_DUPLICATE_KEY",
105
+ {"duplicateKey": object_key_name},
106
+ {
107
+ "an": ApiEnum.GET_FLAG.value,
108
+ "uuid": context.get_vwo_uuid(),
109
+ "sId": context.get_session_id(),
110
+ },
111
+ )
112
+ return
113
+ # add the object key name to the keys seen so far
114
+ keys_seen_so_far.add(object_key_name)
115
+
116
+ def is_web_testing_campaigns_absent_or_null(context: ContextModel) -> bool:
117
+ """
118
+ Returns whether platform_variables.web_testing_campaigns is missing or explicitly null.
119
+
120
+ :param context: User context that may carry platform_variables.
121
+ :return: True if web_testing_campaigns is absent or null; otherwise False.
122
+ """
123
+ # get the platform variables
124
+ platform_variables = context.get_platform_variables()
125
+ # if the platform variables are not present, then return True
126
+ if is_null(platform_variables) or not platform_variables:
127
+ return True
128
+ if not is_object(platform_variables):
129
+ return True
130
+ if "web_testing_campaigns" not in platform_variables:
131
+ return True
132
+ # get the web testing campaigns input
133
+ web_testing_campaigns_input = platform_variables.get("web_testing_campaigns")
134
+ # if the web testing campaigns input is None, then return True
135
+ if is_null(web_testing_campaigns_input):
136
+ return True
137
+ return False
138
+
139
+ def dsl_contains_campaign_variation_node(segmentation_dsl: Any) -> bool:
140
+ """
141
+ Recursively checks whether a segmentation DSL tree contains a campaignVariation operator node.
142
+
143
+ :param segmentation_dsl: Segmentation DSL object to walk (and/or/not/campaignVariation nodes).
144
+ :return: True if any campaignVariation node exists in the tree; otherwise False.
145
+ """
146
+ # if the segmentation dsl is None or not a dictionary, then return False
147
+ if is_null(segmentation_dsl) or not is_object(segmentation_dsl):
148
+ return False
149
+
150
+ # iterate over the segmentation dsl and check if it contains a campaign variation node
151
+ for dsl_property_name in segmentation_dsl:
152
+ # if the dsl property name is the campaign variation node, then return True
153
+ if dsl_property_name == SegmentOperatorValueEnum.WEB_CAMPAIGN_VARIATION.value:
154
+ return True
155
+
156
+ nested_value = segmentation_dsl[dsl_property_name]
157
+ if is_array(nested_value):
158
+ for list_item in nested_value:
159
+ if dsl_contains_campaign_variation_node(list_item):
160
+ return True
161
+ elif is_object(nested_value):
162
+ if dsl_contains_campaign_variation_node(nested_value):
163
+ return True
164
+
165
+ return False
166
+
167
+
168
+ def parse_web_testing_campaigns_from_context(
169
+ context: ContextModel,
170
+ ) -> Optional[Dict[str, str]]:
171
+ """
172
+ Parses context.platform_variables.web_testing_campaigns from a dict or JSON string into a normalized map.
173
+
174
+ :param context: User context containing platform_variables.web_testing_campaigns.
175
+ :return: Normalized campaign-to-variation map, or None if missing, invalid, or unparseable.
176
+ """
177
+ platform_variables = context.get_platform_variables()
178
+ if is_null(platform_variables) or not platform_variables:
179
+ return None
180
+ if not is_object(platform_variables):
181
+ return None
182
+
183
+ web_testing_campaigns_raw = platform_variables.get("web_testing_campaigns")
184
+ if is_null(web_testing_campaigns_raw):
185
+ return None
186
+
187
+ # if the web testing campaigns raw is an object map, normalize it.
188
+ if is_object(web_testing_campaigns_raw):
189
+ return normalize_web_testing_campaigns_map(web_testing_campaigns_raw)
190
+
191
+ # if the web testing campaigns raw is a string, then parse the web testing campaigns
192
+ if is_string(web_testing_campaigns_raw):
193
+ trimmed_json_input = web_testing_campaigns_raw.strip()
194
+ if trimmed_json_input == "":
195
+ return None
196
+ _log_first_duplicate_json_object_key_scan(trimmed_json_input, context)
197
+ try:
198
+ # parse the web testing campaigns as a json object
199
+ parsed_json_object = json.loads(trimmed_json_input)
200
+ # if the parsed json object is an object map, normalize it
201
+ if is_object(parsed_json_object):
202
+ return normalize_web_testing_campaigns_map(parsed_json_object)
203
+ # if the parsed json object is not an object map, then log an error
204
+ LogManager.get_instance().error_log(
205
+ "INVALID_WEB_TESTING_CAMPAIGNS_JSON",
206
+ {},
207
+ {
208
+ "an": ApiEnum.GET_FLAG.value,
209
+ "uuid": context.get_vwo_uuid(),
210
+ "sId": context.get_session_id(),
211
+ },
212
+ )
213
+ except json.JSONDecodeError:
214
+ # if the json decode error is raised, then log an error
215
+ LogManager.get_instance().error_log(
216
+ "INVALID_WEB_TESTING_CAMPAIGNS_JSON",
217
+ {},
218
+ {
219
+ "an": ApiEnum.GET_FLAG.value,
220
+ "uuid": context.get_vwo_uuid(),
221
+ "sId": context.get_session_id(),
222
+ },
223
+ )
224
+ return None
225
+
226
+ # if the web testing campaigns raw is not an object or a string, then log an error
227
+ value_kind_label = get_type(web_testing_campaigns_raw)
228
+ LogManager.get_instance().error_log(
229
+ "INVALID_WEB_TESTING_CAMPAIGNS_TYPE",
230
+ {"kind": value_kind_label},
231
+ {
232
+ "an": ApiEnum.GET_FLAG.value,
233
+ "uuid": context.get_vwo_uuid(),
234
+ "sId": context.get_session_id(),
235
+ },
236
+ )
237
+ return None
238
+
239
+ def evaluate_web_testing_campaign_variation(
240
+ operand_encoding: str,
241
+ campaigns_map: Optional[Dict[str, str]],
242
+ ) -> Tuple[bool, bool]:
243
+ """
244
+ Evaluates a campaignVariation operand encoding against the user's web testing campaign assignments.
245
+
246
+ :param operand_encoding: Encoded operand (e.g. "123", "123_2", "123_!2", "!123").
247
+ :param campaigns_map: Normalized map of campaign ID to assigned variation ID, or None.
248
+ :return: Tuple of (segment matched, operand encoding invalid).
249
+ """
250
+ if not is_string(operand_encoding):
251
+ return (False, True)
252
+
253
+ assignments_by_campaign_id = (
254
+ campaigns_map if is_defined(campaigns_map) else {}
255
+ )
256
+
257
+ # e.g. "!123" — not in campaign 123 (no assignment for that campaign id).
258
+ not_in_campaign_regex_match = re.match(r"^!(\d+)$", operand_encoding)
259
+ if not_in_campaign_regex_match:
260
+ campaign_id_digits = not_in_campaign_regex_match.group(1)
261
+ exists_in_assignments_map = campaign_id_digits in assignments_by_campaign_id
262
+ return (not exists_in_assignments_map, False)
263
+
264
+ # e.g. "123_!3" — in campaign 123 but assigned variation is not 3.
265
+ in_campaign_but_not_variation_regex_match = re.match(r"^(\d+)_!(\d+)$", operand_encoding)
266
+ # if the operand encoding is a campaign and variation id, then check if the user is in the campaign but not the variation
267
+ if in_campaign_but_not_variation_regex_match:
268
+ campaign_id_digits = in_campaign_but_not_variation_regex_match.group(1)
269
+ variation_id_digits = in_campaign_but_not_variation_regex_match.group(2)
270
+ # if the campaign id is not in the assignments by campaign id, then return False and False
271
+ if campaign_id_digits not in assignments_by_campaign_id:
272
+ return (False, False)
273
+ assigned_variation_id = assignments_by_campaign_id[campaign_id_digits]
274
+ return (assigned_variation_id != variation_id_digits, False)
275
+
276
+ # e.g. "123_3" — in campaign 123 with variation exactly 3.
277
+ campaign_and_variation_regex_match = re.match(r"^(\d+)_(\d+)$", operand_encoding)
278
+ if campaign_and_variation_regex_match:
279
+ # if the campaign id is not in the assignments by campaign id, then return False
280
+ campaign_id_digits = campaign_and_variation_regex_match.group(1)
281
+ # get the variation id digits
282
+ variation_id_digits = campaign_and_variation_regex_match.group(2)
283
+ if campaign_id_digits not in assignments_by_campaign_id:
284
+ return (False, False)
285
+ assigned_variation_id = assignments_by_campaign_id[campaign_id_digits]
286
+ return (assigned_variation_id == variation_id_digits, False)
287
+
288
+ # e.g. "123" — in campaign 123 (any assigned variation counts).
289
+ campaign_id_only_regex_match = re.match(r"^(\d+)$", operand_encoding)
290
+ if campaign_id_only_regex_match:
291
+ campaign_id_digits = campaign_id_only_regex_match.group(1)
292
+ user_in_campaign = campaign_id_digits in assignments_by_campaign_id
293
+ return (user_in_campaign, False)
294
+
295
+ return (False, True)
@@ -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,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 typing import Any, Dict, Optional
17
+
18
+
19
+ class StorageConnector:
20
+
21
+ def get(self, key: str, user_id: str) -> Optional[Dict[str, Any]]:
22
+ pass
23
+
24
+ def set(self, value: Dict[str, Any]) -> None:
25
+ pass
@@ -0,0 +1,39 @@
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 typing import Any, Dict, Union
17
+ from .connector import StorageConnector
18
+
19
+
20
+ class Storage:
21
+ _instance = None
22
+
23
+ def __init__(self):
24
+ self.connector = None
25
+
26
+ @classmethod
27
+ def get_instance(cls):
28
+ if cls._instance is None:
29
+ cls._instance = cls()
30
+ return cls._instance
31
+
32
+ def attach_connector(self, connector: StorageConnector) -> None:
33
+ """
34
+ Attaches a connector to the storage.
35
+ """
36
+ self.connector = connector
37
+
38
+ def get_connector(self) -> Any:
39
+ return self.connector
@@ -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,21 @@
1
+ {
2
+ "API_CALLED": "API - {apiName} called",
3
+ "SERVICE_INITIALIZED": "{brand} {service} initialized while creating an instance of SDK",
4
+ "USING_POLL_INTERVAL_FROM_SETTINGS": "key: poll_interval not found or invalid. Using poll_interval from {source} ({pollInterval})",
5
+
6
+ "EXPERIMENTS_EVALUATION_WHEN_ROLLOUT_PASSED": "Rollout rule got passed for user {userId}. Hence, evaluating experiments",
7
+ "EXPERIMENTS_EVALUATION_WHEN_NO_ROLLOUT_PRESENT": "No Rollout rules present for the feature. Hence, checking experiment rules",
8
+
9
+ "USER_BUCKET_TO_VARIATION": "User ID:{userId} for experiment:{campaignKey} having percent traffic:{percentTraffic} got bucket-value:{bucketValue} and hash-value:{hashValue}",
10
+
11
+ "IMPRESSION_FOR_TRACK_USER": "Impression built for vwo_variationShown({brand} standard event for tracking user) event haivng Account ID:{accountId}, User ID:{userId}, and experiment ID:{campaignId}",
12
+ "IMPRESSION_FOR_TRACK_GOAL": "Impression built for event:{eventName} event having Account ID:{accountId}, and user ID:{userId}",
13
+ "IMPRESSION_FOR_SYNC_VISITOR_PROP": "Impression built for {eventName}({brand} internal event) event for Account ID:{accountId}, and user ID:{userId}",
14
+ "BATCHING_INITIALIZED": "BATCHING_INITIALIZED",
15
+ "WEB_UUID_FOUND": "{brand} Web Testing identified UUID {uuid} as the Context ID for API {apiName}",
16
+ "HOLDOUT_SEGMENTATION_FAIL": "User ID: {userId} does not qualify segmentation for Holdout: {holdoutGroupName}",
17
+ "HOLDOUT_SHOULD_NOT_EXCLUDE_USER": "User ID: {userId} is not part of Holdout: {holdoutGroupName} for feature: {featureKey}",
18
+ "PART_OF_HOLDOUT_IN_MEG": "MEG: User ID:{userId} is part of holdout: {holdoutId} for feature: {featureKey}",
19
+ "HOLDOUT_SKIP_EVALUATION": "Skip holdout reevaluation for holdout ID: {holdoutId} because {reason}",
20
+ "IMPRESSION_FOR_TRACK_USAGE": "Impression built for vwo_feTrackUsage({brand} standard event for tracking usage) event having Account ID:{accountId}, User ID:{userId}, and feature key:{featureKey}"
21
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "INVALID_OPTIONS": "Options should be of type object",
3
+ "INVALID_SDK_KEY_IN_OPTIONS": "SDK Key is required in the options and should be of type:string",
4
+ "INVALID_ACCOUNT_ID_IN_OPTIONS": "Account ID is required in the options and should be of type:string|number",
5
+
6
+ "INVALID_POLLING_CONFIGURATION": "Invalid key:{key} passed in options. Should be of type:{correctType} and greater than equal to 1000",
7
+
8
+ "ERROR_FETCHING_SETTINGS": "Settings could not be fetched. Error:{err}",
9
+ "INVALID_SETTINGS_SCHEMA": "Settings are not valid. Failed schema validation",
10
+
11
+ "ERROR_FETCHING_SETTINGS_WITH_POLLING": "Settings could not be fetched with polling. Error:{err}",
12
+ "UPDATING_CLIENT_INSTANCE_FAILED_WHEN_WEBHOOK_TRIGGERED": "Failed to fetch settings. {brand} client instance couldn't be updated. API:{apiName} called having isViaWebhook:{isViaWebhook}. Error: {err}",
13
+
14
+ "EXECUTION_FAILED": "API - {apiName} failed to execute. Error:{err}",
15
+ "INTEGRATIONS_CALLBACK_FAILED": "Error while executing integrations_callback: Error: {err}",
16
+ "INVALID_PARAM": "Key:{key} passed to API:{apiName} is not of valid type. Got type:{type}, should be:{correctType}",
17
+ "INVALID_CONTEXT_PASSED": "Context should be of type:object and must contain a mandatory key: id, which is User ID",
18
+ "INVALID_CONTEXT_USER_ID": "user_id under context must be a string value",
19
+ "INVALID_BUCKETING_SEED": "Invalid bucketingSeed passed, since it can only be a valid string. Removing it from context so that userId is used for decisioning.",
20
+
21
+ "FEATURE_NOT_FOUND": "Feature not found for the key:{featureKey}",
22
+ "FEATURE_NOT_FOUND_WITH_ID": "Feature not found for the id:{featureId}",
23
+ "EVENT_NOT_FOUND": "Event:{eventName} not found in any of the features' metrics, please ensure event API name is being used correctly",
24
+
25
+ "ERROR_READING_STORED_DATA_IN_STORAGE": "Error reading data from storage. Error:{err}",
26
+ "ERROR_STORING_DATA_IN_STORAGE": "Key:{featureKey} is not valid. Unable to store data into storage",
27
+
28
+ "INVALID_GATEWAY_URL": "Invalid URL for {brand} Gateway Service while initializing the SDK",
29
+
30
+ "NETWORK_CALL_FAILED": "Error occurred while sending {method} request. Error:{err}",
31
+ "BATCH_FLUSH_FAILED": "Failed to send batch events. Retrying next time.",
32
+ "ERROR_FLUSHING_BATCH_EVENTS": "Error occurred while sending batch events. Error:{error}",
33
+
34
+ "ERROR_SETTING_SEGMENTATION_CONTEXT": "Error in setting contextual data for segmentation. Error: {err}",
35
+ "USER_AGENT_VALIDATION_ERROR": "Failed to validate user agent. Error: {err}",
36
+ "INVALID_IP_ADDRESS_IN_CONTEXT_FOR_PRE_SEGMENTATION": "ipAddress is required in context to evaluate location pre-segmentation",
37
+ "INVALID_USER_AGENT_IN_CONTEXT_FOR_PRE_SEGMENTATION": "userAgent is required in context to evaluate user-agent pre-segmentation",
38
+ "INVALID_ATTRIBUTE_LIST_FORMAT": "Invalid inList operand format",
39
+ "ERROR_FETCHING_DATA_FROM_GATEWAY": "Error while fetching data from gateway. Error: {err}",
40
+ "ERROR_SENDING_DATA_TO_GATEWAY": "Error while sending data to gateway. Error: {err}",
41
+ "MISSING_GATEWAY_TO_SEND_STANDARD_ATTRIBUTES": "To pass user agent related details as standard attributes, please set gateway as well in init method",
42
+
43
+ "NETWORK_CALL_FAILURE_AFTER_MAX_RETRIES": "Network call for {extraData} failed after {attempts} retry attempt(s). Got Error: {err}",
44
+
45
+ "ATTEMPTING_RETRY_FOR_FAILED_NETWORK_CALL": "Request failed for {endPoint}, Error: {err}. Retrying in {delay} seconds, attempt {attempt} of {maxRetries}",
46
+ "NETWORK_CALL_RETRY_FAILED": "Max retries reached. Request failed for {endPoint}, Error: {err}",
47
+
48
+ "INVALID_BATCH_EVENTS_CONFIG": "Invalid batch events config. Should be an object - events_per_request and request_time_interval should be of type:number and > 0",
49
+
50
+ "SDK_INIT_EVENT_FAILED": "Error occurred while sending SDK init event. Error:{err}",
51
+
52
+ "ERROR_SENDING_DEBUG_EVENT": "Error occurred while sending debugger event. Error:{err}",
53
+ "ERROR_SETTING_ALIAS": "Error while setting alias on gateway service. Error: {err}",
54
+ "ERROR_GETTING_ALIAS": "Error while getting alias from gateway service. Error: {err}",
55
+
56
+ "INVALID_WEB_TESTING_CAMPAIGNS_JSON": "webTestingCampaigns must be a JSON object (not an array)",
57
+ "INVALID_WEB_TESTING_CAMPAIGNS_DUPLICATE_KEY": "webTestingCampaigns JSON string contains duplicate object key: {duplicateKey}, only last occurrence is considered",
58
+ "INVALID_WEB_TESTING_CAMPAIGNS_TYPE": "webTestingCampaigns has invalid type: {kind}",
59
+ "INVALID_WEB_TESTING_CAMPAIGN_VARIATION_OPERAND_TYPE": "campaignVariation operand must be a string or finite number, got type: {type}",
60
+ "INVALID_WEB_TESTING_CAMPAIGN_VARIATION_OPERAND_EMPTY": "campaignVariation operand is empty",
61
+ "INVALID_WEB_TESTING_CAMPAIGN_VARIATION_OPERAND_FORMAT": "Invalid campaignVariation operand encoding: {operandEncoding}"
62
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "ON_INIT_ALREADY_RESOLVED": "[INFO]: {log_prefix} {date} {apiName} already resolved",
3
+ "ON_INIT_SETTINGS_FAILED": "[INFO]: {log_prefix} {date} {brand} settings could not be fetched",
4
+
5
+ "POLLING_SET_SETTINGS": "There's a change in settings from the last settings fetched. Hence, instantiating a new {brand} client internally",
6
+ "POLLING_NO_CHANGE_IN_SETTINGS": "No change in settings with the last settings fetched. Hence, not instantiating new {brand} client",
7
+
8
+ "SETTINGS_FETCH_SUCCESS": "Settings fetched successfully",
9
+
10
+ "CLIENT_INITIALIZED": "{brand} Client initialized",
11
+
12
+ "STORED_VARIATION_FOUND": "Variation {variationKey} found in storage for the user {userId} for the {experimentType} experiment:{experimentKey}",
13
+
14
+ "USER_PART_OF_CAMPAIGN": "User ID:{userId} is {notPart} part of experiment:{campaignKey}",
15
+ "SEGMENTATION_SKIP": "For userId:{userId} of experiment:{campaignKey}, segments was missing. Hence, skipping segmentation",
16
+ "SEGMENTATION_STATUS": "Segmentation {status} for userId:{userId} of experiment:{campaignKey}",
17
+
18
+ "USER_CAMPAIGN_BUCKET_INFO": "User ID:{userId} for experiment:{campaignKey} {status}",
19
+
20
+ "WHITELISTING_SKIP": "Whitelisting is not used for {ruleType}:{campaignKey}, hence skipping evaluating whitelisting {variation} for User ID:{userId}",
21
+ "WHITELISTING_STATUS": "User ID:{userId} for {ruleType}:{campaignKey} {status} whitelisting {variationString}",
22
+ "WHITELISTING_FORCED_OFF": "User ID:{userId} for {ruleType}:{campaignKey} is forced off and excluded from the rule",
23
+
24
+ "VARIATION_RANGE_ALLOCATION": "Variation:{variationKey} of experiment:{campaignKey} having weight:{variationWeight} got bucketing range: ({startRange} - {endRange})",
25
+
26
+ "IMPACT_ANALYSIS": "Tracking feature:{featureKey} being {status} for Impact Analysis Campaign for the user {userId}",
27
+
28
+ "MEG_SKIP_ROLLOUT_EVALUATE_EXPERIMENTS": "No rollout rule found for feature:{featureKey}. Hence, evaluating experiments",
29
+ "MEG_CAMPAIGN_FOUND_IN_STORAGE": "Campaign {campaignKey} found in storage for user ID:{userId}",
30
+ "MEG_CAMPAIGN_ELIGIBLE": "Campaign {campaignKey} is eligible for user ID:{userId}",
31
+ "MEG_WINNER_CAMPAIGN": "MEG: Campaign {campaignKey} is the winner for group {groupId} for user ID:{userId} {algo}",
32
+ "BATCH_FLUSH_SUCCESS": "Batch flush successful. Sent {eventCount} events.",
33
+ "BATCH_FLUSH_STARTED": "Batch flush started. Sending {eventCount} events.",
34
+ "BATCH_FLUSH_MANUAL": "Manual flush triggered.",
35
+ "BATCH_QUEUE_SIZE": "Current batch queue size: {size}",
36
+ "ERROR_FLUSHING_BATCH_EVENTS": "Error occurred while sending batch events. Error:{error}",
37
+ "NETWORK_CALL_SUCCESS": "Impression for {event} - {endPoint} was successfully received by {brand} having Account ID:{accountId}, User ID:{userId} and UUID: {uuid}",
38
+
39
+ "NETWORK_CALL_SUCCESS_WITH_RETRIES": "Network call for {extraData} succeeded after {attempts} retry attempt(s). Previous attempts failed with error: {err}",
40
+ "PROXY_AND_GATEWAY_SERVICE_PROVIDED": "Both proxy URL and gateway service are provided. Gateway service will be used and proxy URL will be ignored",
41
+ "SETTINGS_UPDATED": "Settings fetched and updated successfully on the current {brand} client instance when API: {apiName} got called having isViaWebhook param as {isViaWebhook}",
42
+ "STORED_HOLDOUT_DECISION_FOUND": "User: {userId} already part of holdout with ID:{holdoutId} for feature: {featureKey}",
43
+ "HOLDOUT_SHOULD_EXCLUDE_USER": "User: {userId} ({bucketValue}%) is in Holdout: {holdoutGroupName} with targeted traffic percent: {percentTraffic}% for feature : {featureKey}",
44
+ "USER_IN_HOLDOUT_GROUP": "User: {userId} is in holdout group: {holdoutGroupName} for feature {featureKey}. Feature not evaluated",
45
+ "USER_NOT_EXCLUDED_DUE_TO_HOLDOUT": "User ID:{userId} is not excluded from feature:{featureKey} due to any holdout groups",
46
+ "HOLDOUT_SEGMENTATION_SKIP": "No segments found for holdout: {holdoutId} and user ID: {userId}. Hence skipping segmentation"
47
+ }
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ {}
@@ -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.