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,1415 @@
1
+ Metadata-Version: 2.4
2
+ Name: wingify-fme-python-sdk
3
+ Version: 1.70.0
4
+ Summary: Wingify Feature Management and Experimentation SDK for Python
5
+ Home-page: https://github.com/wingify/vwo-fme-python-sdk
6
+ Author: Wingify
7
+ Author-email: dev@wingify.com
8
+ License: Apache License 2.0
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3.6
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Programming Language :: Python :: 3.15
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ License-File: NOTICE
28
+ Requires-Dist: murmurhash==1.0.10; python_version < "3.9"
29
+ Requires-Dist: murmurhash<1.1,>=1.0.10; python_version >= "3.9"
30
+ Requires-Dist: requests>=2.27.1
31
+ Requires-Dist: jsonschema>=3.2.0
32
+ Dynamic: author
33
+ Dynamic: author-email
34
+ Dynamic: classifier
35
+ Dynamic: description
36
+ Dynamic: description-content-type
37
+ Dynamic: home-page
38
+ Dynamic: license
39
+ Dynamic: license-file
40
+ Dynamic: requires-dist
41
+ Dynamic: summary
42
+
43
+ ## VWO Feature Management and Experimentation SDK for Python
44
+
45
+ [![PyPI version](https://badge.fury.io/py/vwo-fme-python-sdk.svg)](https://pypi.org/project/vwo-fme-python-sdk)
46
+ [![CI](https://github.com/wingify/vwo-fme-python-sdk/workflows/CI/badge.svg?branch=master)](https://github.com/wingify/vwo-fme-python-sdk/actions?query=workflow%3ACI)
47
+ [![codecov](https://codecov.io/gh/wingify/vwo-fme-python-sdk/branch/master/graph/badge.svg?token=)](https://codecov.io/gh/wingify/vwo-fme-python-sdk)
48
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
49
+
50
+ ## Overview
51
+
52
+ The **VWO Feature Management and Experimentation SDK** (VWO FME Python SDK) enables python developers to integrate feature flagging and experimentation into their applications. This SDK provides full control over feature rollout, A/B testing, and event tracking, allowing teams to manage features dynamically and gain insights into user behavior.
53
+
54
+ ## Requirements
55
+
56
+ * Works with Python: 3.6 onwards.
57
+
58
+ ## Installation
59
+
60
+ It's recommended you use [virtualenv](https://virtualenv.pypa.io/en/latest/) to create isolated Python environments.
61
+
62
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
63
+
64
+ <details>
65
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
66
+
67
+ ```bash
68
+ pip install vwo-fme-python-sdk
69
+ ```
70
+
71
+ </details>
72
+
73
+ <details>
74
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
75
+
76
+ ```bash
77
+ pip install wingify-fme-python-sdk
78
+ ```
79
+
80
+ </details>
81
+
82
+ ## Basic Usage Example
83
+
84
+ The following example demonstrates initializing the SDK with a VWO account ID and SDK key, setting a user context, checking if a feature flag is enabled, and tracking a custom event.
85
+
86
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
87
+
88
+ <details>
89
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
90
+
91
+ ```python
92
+ from vwo import init
93
+
94
+ options = {
95
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
96
+ 'account_id': '123456' # VWO Account ID
97
+ }
98
+
99
+ vwo_client = init(options)
100
+
101
+ # set user context
102
+ user_context = {'id': 'unique_user_id'}
103
+ # returns a flag object
104
+ get_flag = vwo_client.get_flag('feature_key', user_context)
105
+ # check if flag is enabled
106
+ is_enabled = get_flag.is_enabled()
107
+ # get varible
108
+ int_var = get_flag.get_variable('int_variable_key', 'default_value')
109
+
110
+ # track event
111
+ vwo_client.track_event('event_name', user_context, event_properties)
112
+
113
+ # set attribute
114
+ vwo_client.set_attribute('attribute_key', 'attribute_value', user_context)
115
+ ```
116
+
117
+ </details>
118
+
119
+ <details>
120
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
121
+
122
+ ```python
123
+ from wingify import init
124
+
125
+ options = {
126
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
127
+ 'account_id': '123456' # Wingify Account ID
128
+ }
129
+
130
+ wingify_client = init(options)
131
+
132
+ # set user context
133
+ user_context = {'id': 'unique_user_id'}
134
+ # returns a flag object
135
+ get_flag = wingify_client.get_flag('feature_key', user_context)
136
+ # check if flag is enabled
137
+ is_enabled = get_flag.is_enabled()
138
+ # get varible
139
+ int_var = get_flag.get_variable('int_variable_key', 'default_value')
140
+
141
+ # track event
142
+ wingify_client.track_event('event_name', user_context, event_properties)
143
+
144
+ # set attribute
145
+ wingify_client.set_attribute('attribute_key', 'attribute_value', user_context)
146
+ ```
147
+
148
+ </details>
149
+
150
+ ## Utility Functions
151
+
152
+ ### getUUID
153
+
154
+ The `getUUID` function generates a deterministic UUID for a given user and account combination. This utility function can be used without initializing the SDK, making it useful for generating consistent UUIDs across different parts of your application.
155
+
156
+ #### Function Signature
157
+
158
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
159
+
160
+ <details>
161
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
162
+
163
+ ```python
164
+ vwo.getUUID(user_id: str, account_id: str) -> Optional[str]
165
+ ```
166
+
167
+ </details>
168
+
169
+ <details>
170
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
171
+
172
+ ```python
173
+ wingify.getUUID(user_id: str, account_id: str) -> Optional[str]
174
+ ```
175
+
176
+ </details>
177
+
178
+ #### Parameters
179
+
180
+ | **Parameter** | **Description** | **Required** | **Type** |
181
+ | ------------- | -------------------------------------------------- | ------------ | -------- |
182
+ | `user_id` | The user's unique identifier. | Yes | str |
183
+ | `account_id` | The VWO account ID associated with the user. | Yes | str |
184
+
185
+ #### Return Value
186
+
187
+ - Returns a UUID string without dashes in uppercase format (e.g., `"A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6"`)
188
+ - Returns `None` if either parameter is not a valid non-empty string
189
+
190
+ #### Example
191
+
192
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
193
+
194
+ <details>
195
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
196
+
197
+ ```python
198
+ import vwo
199
+
200
+ # Generate UUID for a user
201
+ userId = 'user-123'
202
+ accountId = '123456'
203
+
204
+ uuid = vwo.getUUID(userId, accountId)
205
+
206
+ print('Generated UUID:', uuid)
207
+ # Output: Generated UUID: CC25A368ADA0542699EAD62489811105
208
+ ```
209
+
210
+ </details>
211
+
212
+ <details>
213
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
214
+
215
+ ```python
216
+ import wingify
217
+
218
+ # Generate UUID for a user
219
+ userId = 'user-123'
220
+ accountId = '123456'
221
+
222
+ uuid = wingify.getUUID(userId, accountId)
223
+
224
+ print('Generated UUID:', uuid)
225
+ # Output: Generated UUID: CC25A368ADA0542699EAD62489811105
226
+ ```
227
+
228
+ </details>
229
+
230
+ #### Use Cases
231
+
232
+ - Generate consistent UUIDs for users across different services
233
+ - Create deterministic identifiers for analytics and tracking
234
+ - Generate UUIDs without requiring SDK initialization
235
+
236
+ ## Advanced Configuration Options
237
+
238
+ To customize the SDK further, additional parameters can be passed to the `init()` API. Here's a table describing each option:
239
+
240
+ | **Parameter** | **Description** | **Required** | **Type** | **Example** |
241
+ | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | -------- | ------------------------------- |
242
+ | `account_id` | VWO Account ID for authentication. | Yes | str | `'123456'` |
243
+ | `sdk_key` | SDK key corresponding to the specific environment to initialize the VWO SDK Client. You can get this key from VWO Application. | Yes | str | `'32-alpha-numeric-sdk-key'` |
244
+ | `poll_interval` | Time interval for fetching updates from VWO servers (in milliseconds). | No | int | `60_000` |
245
+ | `gateway_service` | Configuration for integrating VWO Gateway Service. Service. | No | Dictionary | see [Gateway](#gateway) section |
246
+ | `proxy_url` | Custom proxy URL for redirecting all SDK network requests through a proxy server. | No | str | see [Proxy Url](#proxy-url) section |
247
+ | `storage` | Custom storage connector for persisting user decisions and campaign data. data. | No | Dictionary | See [Storage](#storage) section |
248
+ | `logger` | Toggle log levels for more insights or for debugging purposes. You can also customize your own transport in order to have better control over log messages. | No | Dictionary | See [Logger](#logger) section |
249
+ | `integrations` | Callback function for integrating with third-party analytics services. | No | Function | See [Integrations](#integrations) section |
250
+ | `batch_event_data` | Configuration for batch event processing to optimize network requests | No | Dictionary | See [Batch Events](#batch-events) section |
251
+ | `threading` | Toggle threading for better (enabled by default) performance. | No | Dictionary | See [Threading](#threading) section |
252
+ | `is_aliasing_enabled` | Enable user aliasing functionality. Requires gateway service to be configured. | No | Boolean | see [UserAliasing](#user-aliasing) section |
253
+
254
+ ### User Context
255
+
256
+ The `context` uniquely identifies users and is crucial for consistent feature rollouts. A typical `context` is a dictionary that includes an `id` key for identifying the user. It can also include other attributes that can be used for targeting and segmentation, such as `custom_variables`, `user_agent`, and `ip_address`.
257
+
258
+ #### Parameters Table
259
+
260
+ The following table explains all the parameters in the `context` dictionary:
261
+
262
+ | **Parameter** | **Description** | **Required** | **Type** |
263
+ | ----------------- | -------------------------------------------------------------------------- | ------------ | -------- |
264
+ | `id` | Unique identifier for the user. | Yes | str |
265
+ | `custom_variables` | Custom attributes for targeting. | No | Dict |
266
+ | `user_agent` | User agent string for identifying the user's browser and operating system. | No | str |
267
+ | `ip_address` | IP address of the user. | No | str |
268
+ | `session_id` | Session ID for connecting server-side decisions with client-side sessions. | No | int |
269
+
270
+ #### Example
271
+
272
+ ```python
273
+ context = {
274
+ 'id': 'unique_user_id',
275
+ 'custom_variables': {
276
+ 'age': 25,
277
+ 'location': 'US'
278
+ },
279
+ 'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
280
+ 'ip_address': '1.1.1.1',
281
+ 'session_id': 1697123456, # Optional: Custom session ID for web client integration
282
+ 'platformVariables': {
283
+ # Reference example only:.
284
+ # In production, fetch campaign assignments using script run in frontend and pass that object to backend as webTestingCampaigns.
285
+ 'webTestingCampaigns': '{"122":"1","130":"2"}'
286
+ }
287
+ }
288
+ ```
289
+
290
+ ## Web testing pre-segmentation
291
+
292
+ Server-side flag decisions can align with **Web Testing** (browser) experiments. **Campaign assignments are typically read on the frontend** (for example, VWO cookies) and sent to your server; pass them in `platformVariables.webTestingCampaigns` as a map of **campaign ID -> variation ID** (strings), or as a **JSON string** of that object.
293
+
294
+ Pre-segment rules in the VWO dashboard can use the **`campaignVariation`** operator:
295
+
296
+ | Operand pattern | Meaning |
297
+ | --------------- | ------- |
298
+ | `C` | User is in campaign `C` (any variation). |
299
+ | `!C` | User is **not** in campaign `C`. |
300
+ | `C_V` | User is in campaign `C` with variation `V`. |
301
+ | `C_!V` | User is in campaign `C` and assigned variation is **not** `V`. |
302
+
303
+ Rollout rules evaluate pre-segments from the **first variation** only; AB/testing rules use **campaign-level** segments.
304
+
305
+ ## Session Management
306
+
307
+ The SDK provides automatic session management capabilities to enable seamless integration with VWO's web client testing campaigns. Session IDs are automatically generated and managed to connect server-side feature flag decisions with client-side user sessions.
308
+
309
+ ### Automatic Session ID Generation
310
+
311
+ Session IDs are automatically generated using Unix timestamps when not explicitly provided in the context. This ensures consistent session tracking across all feature flag evaluations and event tracking.
312
+
313
+ ### Session ID Access
314
+
315
+ You can access and manage session IDs through the following methods:
316
+
317
+ - **Get Session ID from Flag**: Use `get_flag.get_session_id()` to retrieve the session ID used for a specific feature flag evaluation
318
+ - **Set Custom Session ID**: Set `session_id` in your context dictionary to use a custom session ID (useful for matching web client sessions)
319
+
320
+ ### Example Usage
321
+
322
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
323
+
324
+ <details>
325
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
326
+
327
+ ```python
328
+ from vwo import init
329
+
330
+ options = {
331
+ 'sdk_key': '32-alpha-numeric-sdk-key',
332
+ 'account_id': '123456'
333
+ }
334
+
335
+ vwo_client = init(options)
336
+
337
+ # Session ID is automatically generated if not provided
338
+ context = {'id': 'user-123'}
339
+ flag = vwo_client.get_flag('feature-key', context)
340
+
341
+ # Access the session ID to pass to web client for session recording
342
+ session_id = flag.get_session_id()
343
+ print(f"Session ID for web client: {session_id}")
344
+ ```
345
+
346
+ </details>
347
+
348
+ <details>
349
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
350
+
351
+ ```python
352
+ from wingify import init
353
+
354
+ options = {
355
+ 'sdk_key': '32-alpha-numeric-sdk-key',
356
+ 'account_id': '123456'
357
+ }
358
+
359
+ wingify_client = init(options)
360
+
361
+ # Session ID is automatically generated if not provided
362
+ context = {'id': 'user-123'}
363
+ flag = wingify_client.get_flag('feature-key', context)
364
+
365
+ # Access the session ID to pass to web client for session recording
366
+ session_id = flag.get_session_id()
367
+ print(f"Session ID for web client: {session_id}")
368
+ ```
369
+
370
+ </details>
371
+
372
+ You can also explicitly set a session ID to match a web client session:
373
+
374
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
375
+
376
+ <details>
377
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
378
+
379
+ ```python
380
+ from vwo import init
381
+
382
+ vwo_client = init(options)
383
+
384
+ context_with_session = {
385
+ 'id': 'user-123',
386
+ 'session_id': 1697123456 # Custom session ID matching web client
387
+ }
388
+
389
+ flag = vwo_client.get_flag('feature-key', context_with_session)
390
+ ```
391
+
392
+ </details>
393
+
394
+ <details>
395
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
396
+
397
+ ```python
398
+ from wingify import init
399
+
400
+ wingify_client = init(options)
401
+
402
+ context_with_session = {
403
+ 'id': 'user-123',
404
+ 'session_id': 1697123456 # Custom session ID matching web client
405
+ }
406
+
407
+ flag = wingify_client.get_flag('feature-key', context_with_session)
408
+ ```
409
+
410
+ </details>
411
+
412
+ This enhancement enables seamless integration between server-side feature flag decisions and client-side session recording, allowing for comprehensive user behavior analysis across both server and client environments.
413
+
414
+ ### Basic Feature Flagging
415
+
416
+ Feature Flags serve as the foundation for all testing, personalization, and rollout rules within FME.
417
+ To implement a feature flag, first use the `get_flag()` method to retrieve the flag configuration.
418
+ The `get_flag()` method provides a simple way to check if a feature is enabled for a specific user and access its variables. It returns a `GetFlag` object that contains methods like `is_enabled()` for checking the feature's status and `get_variable()` for retrieving any associated variables.
419
+
420
+ | Parameter | Description | Required | Type |
421
+ | ------------ | ---------------------------------------------------------------- | -------- | ----------- |
422
+ | `feature_key` | Unique identifier of the feature flag | Yes | str |
423
+ | `context` | Dictionary containing user identification and contextual information | Yes | Dict |
424
+
425
+ Example usage:
426
+
427
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
428
+
429
+ <details>
430
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
431
+
432
+ ```python
433
+ feature_flag = vwo_client.get_flag("feature_key", context)
434
+ is_enabled = feature_flag.is_enabled()
435
+
436
+ if is_enabled:
437
+ print("Feature is enabled!")
438
+
439
+ # Get and use feature variable with type safety
440
+ variable_value = feature_flag.get_variable('feature_variable', 'default_value')
441
+ print("Variable value: " + variable_value)
442
+ else:
443
+ print("Feature is not enabled!")
444
+ ```
445
+
446
+ </details>
447
+
448
+ <details>
449
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
450
+
451
+ ```python
452
+ feature_flag = wingify_client.get_flag("feature_key", context)
453
+ is_enabled = feature_flag.is_enabled()
454
+
455
+ if is_enabled:
456
+ print("Feature is enabled!")
457
+
458
+ # Get and use feature variable with type safety
459
+ variable_value = feature_flag.get_variable('feature_variable', 'default_value')
460
+ print("Variable value: " + variable_value)
461
+ else:
462
+ print("Feature is not enabled!")
463
+ ```
464
+
465
+ </details>
466
+
467
+ ### Custom Event Tracking
468
+
469
+ Feature flags can be enhanced with connected metrics to track key performance indicators (KPIs) for your features. These metrics help measure the effectiveness of your testing rules by comparing control versus variation performance, and evaluate the impact of personalization and rollout campaigns. Use the `track_event()` method to track custom events like conversions, user interactions, and other important metrics:
470
+
471
+ | Parameter | Description | Required | Type |
472
+ | ----------------- | ---------------------------------------------------------------------- | -------- | ----------- |
473
+ | `event_name` | Name of the event you want to track | Yes | str |
474
+ | `context` | Dictionary containing user identification and contextual information | Yes | Dict |
475
+ | `event_properties` | Additional properties/metadata associated with the event | No | Dict |
476
+
477
+ Example usage:
478
+
479
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
480
+
481
+ <details>
482
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
483
+
484
+ ```python
485
+ vwo_client.track_event('event_name', context, event_properties)
486
+ ```
487
+
488
+ </details>
489
+
490
+ <details>
491
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
492
+
493
+ ```python
494
+ wingify_client.track_event('event_name', context, event_properties)
495
+ ```
496
+
497
+ </details>
498
+
499
+ ### Pushing Attributes
500
+
501
+ User attributes provide rich contextual information about users, enabling powerful personalization. The `set_attribute()` method in VWOClient provides a simple way to associate these attributes with users in VWO for advanced segmentation. The method accepts an attribute key, value, and dictionary containing the user information. Here's what you need to know about the method parameters:
502
+
503
+ | Parameter | Description | Required | Type |
504
+ | ---------------- | ---------------------------------------------------------------------- | -------- | ----------- |
505
+ | `attribute_key` | The unique identifier/name of the attribute you want to set | Yes | str |
506
+ | `attribute_value` | The value to be assigned to the attribute | Yes | Any |
507
+ | `context` | Dictionary containing user identification and other contextual information | Yes | Dict |
508
+
509
+ Example usage:
510
+
511
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
512
+
513
+ <details>
514
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
515
+
516
+ ```python
517
+ vwo_client.set_attribute('attribute_key', 'attribute_value', context)
518
+ ```
519
+
520
+ </details>
521
+
522
+ <details>
523
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
524
+
525
+ ```python
526
+ wingify_client.set_attribute('attribute_key', 'attribute_value', context)
527
+ ```
528
+
529
+ </details>
530
+
531
+ ### Polling Interval Adjustment
532
+
533
+ The `poll_interval` is an optional parameter that allows the SDK to automatically fetch and update settings from the VWO server at specified intervals. The polling interval can be configured in three ways:
534
+
535
+ 1. Set via SDK options: If `poll_interval` is specified in the initialization options (must be >= 1000 milliseconds), that interval will be used
536
+ 2. VWO Application Settings: If configured in your VWO application settings, that interval will be used
537
+ 3. Default Fallback: If neither of the above is set, a 10 minute (600,000 milliseconds) polling interval is used
538
+
539
+ Setting this parameter ensures your application always uses the latest configuration by periodically checking for and applying any updates.
540
+
541
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
542
+
543
+ <details>
544
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
545
+
546
+ ```python
547
+ options = {
548
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
549
+ 'account_id': '123456', # VWO Account ID
550
+ 'poll_interval': 60000 # Set the poll interval to 60 seconds
551
+ }
552
+
553
+ vwo_client = init(options)
554
+ ```
555
+
556
+ </details>
557
+
558
+ <details>
559
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
560
+
561
+ ```python
562
+ options = {
563
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
564
+ 'account_id': '123456', # Wingify Account ID
565
+ 'poll_interval': 60000 # Set the poll interval to 60 seconds
566
+ }
567
+
568
+ wingify_client = init(options)
569
+ ```
570
+
571
+ </details>
572
+
573
+ ### Gateway
574
+
575
+ The VWO FME Gateway Service is an optional but powerful component that enhances VWO's Feature Management and Experimentation (FME) SDKs. It acts as a critical intermediary for pre-segmentation capabilities based on user location and user agent (UA). By deploying this service within your infrastructure, you benefit from minimal latency and strengthened security for all FME operations.
576
+
577
+ #### Why Use a Gateway?
578
+
579
+ The Gateway Service is required in the following scenarios:
580
+
581
+ - When using pre-segmentation features based on user location or user agent.
582
+ - For applications requiring advanced targeting capabilities.
583
+ - It's mandatory when using any thin-client SDK (e.g., Go).
584
+
585
+ #### How to Use the Gateway
586
+
587
+ The gateway can be customized by passing the `gateway_service` parameter in the `init` configuration.
588
+
589
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
590
+
591
+ <details>
592
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
593
+
594
+ ```python
595
+ options = {
596
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
597
+ 'account_id': '123456', # VWO Account ID
598
+ 'gateway_service': {
599
+ 'url': 'http://custom.gateway.com'
600
+ }
601
+ }
602
+ vwo_client = init(options)
603
+ ```
604
+
605
+ </details>
606
+
607
+ <details>
608
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
609
+
610
+ ```python
611
+ options = {
612
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
613
+ 'account_id': '123456', # Wingify Account ID
614
+ 'gateway_service': {
615
+ 'url': 'http://custom.gateway.com'
616
+ }
617
+ }
618
+ wingify_client = init(options)
619
+ ```
620
+
621
+ </details>
622
+
623
+ ### User Aliasing
624
+
625
+ User aliasing allows you to create consistent user experiences across different user identifiers. This is useful when users can be identified by multiple IDs (e.g., anonymous ID, authenticated ID, email), and you want to maintain consistent feature flag decisions across these identifiers.
626
+
627
+ #### Prerequisites
628
+
629
+ User aliasing requires:
630
+
631
+ 1. **Gateway Service**: Must be configured and running. See [Gateway](#gateway) section for more details.
632
+ 2. **Aliasing Enabled**: Must be set to `True` in initialization options.
633
+
634
+ #### Configuration
635
+
636
+ To enable user aliasing, configure both the gateway service and the aliasing flag:
637
+
638
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
639
+
640
+ <details>
641
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
642
+
643
+ ```python
644
+ from vwo import init
645
+
646
+ options = {
647
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
648
+ 'account_id': '123456', # VWO Account ID
649
+ # set gateway service
650
+ 'gateway_service': {
651
+ 'url': 'http://custom.gateway.com'
652
+ },
653
+ # enable aliasing
654
+ 'is_aliasing_enabled': True,
655
+ }
656
+
657
+ vwo_client = init(options)
658
+ ```
659
+
660
+ </details>
661
+
662
+ <details>
663
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
664
+
665
+ ```python
666
+ from wingify import init
667
+
668
+ options = {
669
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
670
+ 'account_id': '123456', # Wingify Account ID
671
+ # set gateway service
672
+ 'gateway_service': {
673
+ 'url': 'http://custom.gateway.com'
674
+ },
675
+ # enable aliasing
676
+ 'is_aliasing_enabled': True,
677
+ }
678
+
679
+ wingify_client = init(options)
680
+ ```
681
+
682
+ </details>
683
+
684
+ #### Setting User Alias
685
+
686
+ Use the `set_alias()` method to create an alias relationship between a user ID and an alias ID:
687
+
688
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
689
+
690
+ <details>
691
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
692
+
693
+ ```python
694
+ # Method 1: Using user ID and alias ID directly
695
+ is_alias_set = vwo_client.set_alias('user-123', 'alias-456')
696
+
697
+ # Method 2: Using context dict and alias ID
698
+ context = {'id': 'user-123'}
699
+ is_alias_set = vwo_client.set_alias(context, 'alias-456')
700
+ ```
701
+
702
+ </details>
703
+
704
+ <details>
705
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
706
+
707
+ ```python
708
+ # Method 1: Using user ID and alias ID directly
709
+ is_alias_set = wingify_client.set_alias('user-123', 'alias-456')
710
+
711
+ # Method 2: Using context dict and alias ID
712
+ context = {'id': 'user-123'}
713
+ is_alias_set = wingify_client.set_alias(context, 'alias-456')
714
+ ```
715
+
716
+ </details>
717
+
718
+ ### Proxy URL
719
+
720
+ The `proxy_url` parameter allows you to redirect all SDK network calls through a custom proxy server. This feature enables you to route all SDK network requests (settings, tracking, etc.) through your own proxy server, providing better control over network traffic and security.
721
+
722
+ #### How to Use Proxy URL
723
+
724
+ The proxy URL can be configured by passing the `proxy_url` parameter in the `init` configuration.
725
+
726
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
727
+
728
+ <details>
729
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
730
+
731
+ ```python
732
+ options = {
733
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
734
+ 'account_id': '123456', # VWO Account ID
735
+ 'proxy_url': 'http://custom.proxy.com'
736
+ }
737
+
738
+ vwo_client = init(options)
739
+ ```
740
+
741
+ </details>
742
+
743
+ <details>
744
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
745
+
746
+ ```python
747
+ options = {
748
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
749
+ 'account_id': '123456', # Wingify Account ID
750
+ 'proxy_url': 'http://custom.proxy.com'
751
+ }
752
+
753
+ wingify_client = init(options)
754
+ ```
755
+
756
+ </details>
757
+
758
+ **Note:** If both `gateway_service` and `proxy_url` are provided, the SDK will give preference to the `gateway_service` for all network requests.
759
+
760
+ ### Storage
761
+
762
+ The SDK operates in a stateless mode by default, meaning each `get_flag` call triggers a fresh evaluation of the flag against the current user context.
763
+
764
+ To optimize performance and maintain consistency, you can implement a custom storage mechanism by passing a `storage` parameter during initialization. This allows you to persist feature flag decisions in your preferred database system (like Redis, MongoDB, or any other data store).
765
+
766
+ Key benefits of implementing storage:
767
+
768
+ - Improved performance by caching decisions
769
+ - Consistent user experience across sessions
770
+ - Reduced load on your application
771
+
772
+ The storage mechanism ensures that once a decision is made for a user, it remains consistent even if campaign settings are modified in the VWO Application. This is particularly useful for maintaining a stable user experience during A/B tests and feature rollouts.
773
+
774
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
775
+
776
+ <details>
777
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
778
+
779
+ ```python
780
+ from vwo import StorageConnector
781
+ class UserStorage(StorageConnector):
782
+ def get(self, key: str, user_id: str):
783
+ return client_db.get(f"{key}_{user_id}")
784
+
785
+ def set(self, value: dict):
786
+ key = f"{value.get('featureKey')}_{value.get('userId')}"
787
+ client_db[key] = {
788
+ 'rolloutKey': value.get('rolloutKey'),
789
+ 'rolloutVariationId': value.get('rolloutVariationId'),
790
+ 'rolloutId': value.get('rolloutId'),
791
+ 'experimentKey': value.get('experimentKey'),
792
+ 'experimentVariationId': value.get('experimentVariationId'),
793
+ 'experimentId': value.get('experimentId'),
794
+ }
795
+ return True
796
+
797
+ options = {
798
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
799
+ 'account_id': '123456', # VWO Account ID
800
+ 'storage': UserStorage()
801
+ }
802
+
803
+ vwo_client = init(options)
804
+ ```
805
+
806
+ </details>
807
+
808
+ <details>
809
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
810
+
811
+ ```python
812
+ from wingify import StorageConnector
813
+ class UserStorage(StorageConnector):
814
+ def get(self, key: str, user_id: str):
815
+ return client_db.get(f"{key}_{user_id}")
816
+
817
+ def set(self, value: dict):
818
+ key = f"{value.get('featureKey')}_{value.get('userId')}"
819
+ client_db[key] = {
820
+ 'rolloutKey': value.get('rolloutKey'),
821
+ 'rolloutVariationId': value.get('rolloutVariationId'),
822
+ 'rolloutId': value.get('rolloutId'),
823
+ 'experimentKey': value.get('experimentKey'),
824
+ 'experimentVariationId': value.get('experimentVariationId'),
825
+ 'experimentId': value.get('experimentId'),
826
+ }
827
+ return True
828
+
829
+ options = {
830
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
831
+ 'account_id': '123456', # Wingify Account ID
832
+ 'storage': UserStorage()
833
+ }
834
+
835
+ wingify_client = init(options)
836
+ ```
837
+
838
+ </details>
839
+
840
+ ### Integrations
841
+ VWO FME SDKs provide seamless integration with third-party tools like analytics platforms, monitoring services, customer data platforms (CDPs), and messaging systems. This is achieved through a simple yet powerful callback mechanism that receives VWO-specific properties and can forward them to any third-party tool of your choice.
842
+
843
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
844
+
845
+ <details>
846
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
847
+
848
+ ```python
849
+ def callback(properties):
850
+ # properties will contain all the required VWO specific information
851
+ print(properties)
852
+
853
+ options = {
854
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
855
+ 'account_id': '12345', # VWO Account ID
856
+ 'integrations': {
857
+ 'callback': callback
858
+ }
859
+ }
860
+ vwo_client = init(options)
861
+ ```
862
+
863
+ </details>
864
+
865
+ <details>
866
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
867
+
868
+ ```python
869
+ def callback(properties):
870
+ # properties will contain all the required Wingify specific information
871
+ print(properties)
872
+
873
+ options = {
874
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
875
+ 'account_id': '12345', # Wingify Account ID
876
+ 'integrations': {
877
+ 'callback': callback
878
+ }
879
+ }
880
+ wingify_client = init(options)
881
+ ```
882
+
883
+ </details>
884
+
885
+ ### Logger
886
+
887
+ VWO by default logs all `ERROR` level messages to your server console.
888
+ To gain more control over VWO's logging behaviour, you can use the `logger` parameter in the `init` configuration.
889
+
890
+ | **Parameter** | **Description** | **Required** | **Type** | **Default Value** |
891
+ | ------------- | -------------------------------------- | ------------ | -------- | ----------------- |
892
+ | `level` | Log level to control verbosity of logs | Yes | str | `ERROR` |
893
+ | `prefix` | Custom prefix for log messages | No | str | `VWO-SDK` |
894
+ | `transport` | Custom logger implementation | No | object | See example below |
895
+
896
+ #### Example 1: Set log level to control verbosity of logs
897
+
898
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
899
+
900
+ <details>
901
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
902
+
903
+ ```python
904
+ options = {
905
+ 'account_id': '123456', # VWO Account ID
906
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
907
+ 'logger': {
908
+ 'level': 'DEBUG'
909
+ }
910
+ }
911
+ vwo_client = init(options)
912
+ ```
913
+
914
+ </details>
915
+
916
+ <details>
917
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
918
+
919
+ ```python
920
+ options = {
921
+ 'account_id': '123456', # Wingify Account ID
922
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
923
+ 'logger': {
924
+ 'level': 'DEBUG'
925
+ }
926
+ }
927
+ wingify_client = init(options)
928
+ ```
929
+
930
+ </details>
931
+
932
+ #### Example 2: Add custom prefix to log messages for easier identification
933
+
934
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
935
+
936
+ <details>
937
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
938
+
939
+ ```python
940
+ options = {
941
+ 'account_id': '123456', # VWO Account ID
942
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
943
+ 'logger': {
944
+ 'level': 'DEBUG',
945
+ 'prefix': 'CUSTOM LOG PREFIX'
946
+ }
947
+ }
948
+ vwo_client = init(options)
949
+ ```
950
+
951
+ </details>
952
+
953
+ <details>
954
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
955
+
956
+ ```python
957
+ options = {
958
+ 'account_id': '123456', # Wingify Account ID
959
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
960
+ 'logger': {
961
+ 'level': 'DEBUG',
962
+ 'prefix': 'CUSTOM LOG PREFIX'
963
+ }
964
+ }
965
+ wingify_client = init(options)
966
+ ```
967
+
968
+ </details>
969
+
970
+ #### Example 3: Implement custom transport to handle logs your way
971
+
972
+ The `transport` parameter allows you to implement custom logging behavior by providing your own logging functions. You can define handlers for different log levels (`debug`, `info`, `warn`, `error`, `trace`) to process log messages according to your needs.
973
+
974
+ For example, you could:
975
+
976
+ - Send logs to a third-party logging service
977
+ - Write logs to a file
978
+ - Format log messages differently
979
+ - Filter or transform log messages
980
+ - Route different log levels to different destinations
981
+
982
+ The transport object should implement handlers for the log levels you want to customize. Each handler receives the log message as a parameter.
983
+
984
+ For single transport you can use the `transport` parameter. For example:
985
+
986
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
987
+
988
+ <details>
989
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
990
+
991
+ ```python
992
+ from vwo import init
993
+
994
+ class CustomTransport:
995
+ def __init__(self, config):
996
+ self.level = config.get('level', "ERROR")
997
+ self.config = config
998
+
999
+ def log(self, level, message):
1000
+ # your custom implementation here
1001
+
1002
+ options = {
1003
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1004
+ 'account_id': '123456', # VWO Account ID
1005
+ 'logger': {
1006
+ 'transport': CustomTransport({'level': 'INFO'})
1007
+ }
1008
+ }
1009
+
1010
+ vwo_client = init(options)
1011
+ ```
1012
+
1013
+ </details>
1014
+
1015
+ <details>
1016
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
1017
+
1018
+ ```python
1019
+ from wingify import init
1020
+
1021
+ class CustomTransport:
1022
+ def __init__(self, config):
1023
+ self.level = config.get('level', "ERROR")
1024
+ self.config = config
1025
+
1026
+ def log(self, level, message):
1027
+ # your custom implementation here
1028
+
1029
+ options = {
1030
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1031
+ 'account_id': '123456', # Wingify Account ID
1032
+ 'logger': {
1033
+ 'transport': CustomTransport({'level': 'INFO'})
1034
+ }
1035
+ }
1036
+
1037
+ wingify_client = init(options)
1038
+ ```
1039
+
1040
+ </details>
1041
+
1042
+ For multiple transports you can use the `transports` parameter. For example:
1043
+
1044
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
1045
+
1046
+ <details>
1047
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
1048
+
1049
+ ```python
1050
+ from vwo import init
1051
+
1052
+ class CustomTransportForInfo:
1053
+ def __init__(self, config):
1054
+ self.level = config.get('level', "INFO")
1055
+ self.config = config
1056
+
1057
+ def log(self, level, message):
1058
+ # your custom implementation here
1059
+
1060
+ class CustomTransportForError:
1061
+ def __init__(self, config):
1062
+ self.level = config.get('level', "ERROR")
1063
+ self.config = config
1064
+
1065
+ def log(self, level, message):
1066
+ # your custom implementation here
1067
+
1068
+ options = {
1069
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1070
+ 'account_id': '123456', # VWO Account ID
1071
+ 'logger': {
1072
+ 'transports': [
1073
+ CustomTransportForInfo({'level': 'INFO'}),
1074
+ CustomTransportForError({'level': 'ERROR'})
1075
+ ]
1076
+ }
1077
+ }
1078
+
1079
+ vwo_client = init(options)
1080
+ ```
1081
+
1082
+ </details>
1083
+
1084
+ <details>
1085
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
1086
+
1087
+ ```python
1088
+ from wingify import init
1089
+
1090
+ class CustomTransportForInfo:
1091
+ def __init__(self, config):
1092
+ self.level = config.get('level', "INFO")
1093
+ self.config = config
1094
+
1095
+ def log(self, level, message):
1096
+ # your custom implementation here
1097
+
1098
+ class CustomTransportForError:
1099
+ def __init__(self, config):
1100
+ self.level = config.get('level', "ERROR")
1101
+ self.config = config
1102
+
1103
+ def log(self, level, message):
1104
+ # your custom implementation here
1105
+
1106
+ options = {
1107
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1108
+ 'account_id': '123456', # Wingify Account ID
1109
+ 'logger': {
1110
+ 'transports': [
1111
+ CustomTransportForInfo({'level': 'INFO'}),
1112
+ CustomTransportForError({'level': 'ERROR'})
1113
+ ]
1114
+ }
1115
+ }
1116
+
1117
+ wingify_client = init(options)
1118
+ ```
1119
+
1120
+ </details>
1121
+
1122
+ ### Threading
1123
+
1124
+ The SDK leverages threading to efficiently manage concurrent operations. Threading is enabled by default, but can be disabled by configuring the `threading` parameter during initialization. This gives you control over the SDK's concurrency behavior based on your application's needs.
1125
+
1126
+ | Parameter | Description | Required | Type | Default |
1127
+ | --------- | ----------- | -------- | ---- | ------- |
1128
+ | `enabled` | Enable or disable threading. | No | Boolean | `true` |
1129
+ | `max_workers` | Maximum number of threads to use. | No | Integer | `5` |
1130
+
1131
+ #### Disable Threading
1132
+
1133
+ When threading is disabled, all tracking calls will block the main execution thread until they complete. This means your application will wait for each VWO operation before continuing.
1134
+
1135
+ Example showing blocking behavior:
1136
+
1137
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
1138
+
1139
+ <details>
1140
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
1141
+
1142
+ ```python
1143
+ # By disabling threading, the SDK will wait for the response from the server for each tracking call.
1144
+ from vwo import init
1145
+
1146
+ options = {
1147
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1148
+ 'account_id': '123456', # VWO Account ID
1149
+ 'threading': {
1150
+ 'enabled': False
1151
+ }
1152
+ }
1153
+
1154
+ vwo_client = init(options)
1155
+ ```
1156
+
1157
+ </details>
1158
+
1159
+ <details>
1160
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
1161
+
1162
+ ```python
1163
+ # By disabling threading, the SDK will wait for the response from the server for each tracking call.
1164
+ from wingify import init
1165
+
1166
+ options = {
1167
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1168
+ 'account_id': '123456', # Wingify Account ID
1169
+ 'threading': {
1170
+ 'enabled': False
1171
+ }
1172
+ }
1173
+
1174
+ wingify_client = init(options)
1175
+ ```
1176
+
1177
+ </details>
1178
+
1179
+ #### Enable Threading (Default)
1180
+
1181
+ Threading in the VWO SDK provides several important benefits:
1182
+
1183
+ 1. **Asynchronous Event Tracking**: When enabled, all tracking calls are processed asynchronously in the background. This prevents these network calls from blocking your application's main execution flow.
1184
+
1185
+ 2. **Improved Performance**: By processing tracking and network operations in separate threads, your application remains responsive and can continue serving user requests without waiting for VWO operations to complete.
1186
+
1187
+ Example of how threading improves performance:
1188
+ - Without threading: Each tracking call blocks until the server responds
1189
+ - With threading: Tracking calls return immediately while processing happens in background
1190
+
1191
+ The SDK uses a thread pool to manage these concurrent operations efficiently. The default pool size of 5 threads is suitable for most applications, but you can adjust it based on your needs:
1192
+
1193
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
1194
+
1195
+ <details>
1196
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
1197
+
1198
+ ```python
1199
+ # By default, threading is enabled and the max_workers is set to 5.
1200
+ # you can customize the max_workers by passing the max_workers parameter in the threading configuration.
1201
+ from vwo import init
1202
+
1203
+ options = {
1204
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1205
+ 'account_id': '123456', # VWO Account ID
1206
+ 'threading': {
1207
+ 'enabled': True,
1208
+ 'max_workers': 10
1209
+ }
1210
+ }
1211
+
1212
+ vwo_client = init(options)
1213
+ ```
1214
+
1215
+ </details>
1216
+
1217
+ <details>
1218
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
1219
+
1220
+ ```python
1221
+ # By default, threading is enabled and the max_workers is set to 5.
1222
+ # you can customize the max_workers by passing the max_workers parameter in the threading configuration.
1223
+ from wingify import init
1224
+
1225
+ options = {
1226
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1227
+ 'account_id': '123456', # Wingify Account ID
1228
+ 'threading': {
1229
+ 'enabled': True,
1230
+ 'max_workers': 10
1231
+ }
1232
+ }
1233
+
1234
+ wingify_client = init(options)
1235
+ ```
1236
+
1237
+ </details>
1238
+
1239
+ ### Batch Events
1240
+
1241
+ The `batch_event_data` configuration allows you to optimize network requests by batching multiple events together. This is particularly useful for high-traffic applications where you want to reduce the number of API calls.
1242
+
1243
+ | **Parameter** | **Description** | **Required** | **Type** | **Default** |
1244
+ | --------------------- | ----------------------------------------------------------------------- | ------------ | -------- | ----------- |
1245
+ | `request_time_interval` | Time interval (in seconds) after which events are flushed to the server | No | Number | `600` |
1246
+ | `events_per_request` | Maximum number of events to batch together before sending to the server | No | Number | `100` |
1247
+ | `flush_callback` | Callback function to be executed after events are flushed | No | Function | See example |
1248
+
1249
+ Example usage:
1250
+
1251
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
1252
+
1253
+ <details>
1254
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
1255
+
1256
+ ```python
1257
+ from vwo import init
1258
+
1259
+ def event_flush_callback(error, payload):
1260
+ # your implementation here
1261
+
1262
+ options = {
1263
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1264
+ 'account_id': '123456', # VWO Account ID
1265
+ 'batch_event_data': {
1266
+ 'events_per_request': 100, # Send up to 100 events per request
1267
+ 'request_time_interval': 60, # Flush events every 60 seconds
1268
+ 'flush_callback': event_flush_callback
1269
+ }
1270
+ }
1271
+
1272
+ vwo_client = init(options)
1273
+ ```
1274
+
1275
+ </details>
1276
+
1277
+ <details>
1278
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
1279
+
1280
+ ```python
1281
+ from wingify import init
1282
+
1283
+ def event_flush_callback(error, payload):
1284
+ # your implementation here
1285
+
1286
+ options = {
1287
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1288
+ 'account_id': '123456', # Wingify Account ID
1289
+ 'batch_event_data': {
1290
+ 'events_per_request': 100, # Send up to 100 events per request
1291
+ 'request_time_interval': 60, # Flush events every 60 seconds
1292
+ 'flush_callback': event_flush_callback
1293
+ }
1294
+ }
1295
+
1296
+ wingify_client = init(options)
1297
+ ```
1298
+
1299
+ </details>
1300
+
1301
+ You can also manually flush events using the `flush_events()` method:
1302
+
1303
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
1304
+
1305
+ <details>
1306
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
1307
+
1308
+ ```python
1309
+ vwo_client.flush_events()
1310
+ ```
1311
+
1312
+ </details>
1313
+
1314
+ <details>
1315
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
1316
+
1317
+ ```python
1318
+ wingify_client.flush_events()
1319
+ ```
1320
+
1321
+ </details>
1322
+
1323
+
1324
+ ### Custom Bucketing Seed
1325
+
1326
+ This option allows you to override the default bucketing behavior (which uses `userId`) and specify a custom seed for bucketing users into variations. This is useful when you want to ensure consistent variation assignments across different user IDs (e.g., maintaining the same experience for a group of users).
1327
+
1328
+ To use this feature, provide the `bucketingSeed` in the user context.
1329
+
1330
+ If SDK version less than 1.50.0, use the VWO snippet. If SDK version 1.50.0 or later, we recommend switching to the Wingify snippet
1331
+
1332
+ <details>
1333
+ <summary>VWO (SDK version &lt; 1.50.0)</summary>
1334
+
1335
+ ```python
1336
+ from vwo import init
1337
+
1338
+ options = {
1339
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1340
+ 'account_id': '123456', # VWO Account ID
1341
+ }
1342
+
1343
+ vwo_client = init(options)
1344
+
1345
+ # Pass bucketingSeed in context
1346
+ user_context = {
1347
+ 'id': 'unique_user_id',
1348
+ 'bucketingSeed': 'group_id_123' # This value will be used for bucketing
1349
+ }
1350
+
1351
+ # The user will be bucketed based on 'group_id_123' instead of 'unique_user_id'
1352
+ get_flag = vwo_client.get_flag('feature_key', user_context)
1353
+ ```
1354
+
1355
+ </details>
1356
+
1357
+ <details>
1358
+ <summary>Wingify (SDK version &gt;= 1.50.0) — recommended</summary>
1359
+
1360
+ ```python
1361
+ from wingify import init
1362
+
1363
+ options = {
1364
+ 'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
1365
+ 'account_id': '123456', # Wingify Account ID
1366
+ }
1367
+
1368
+ wingify_client = init(options)
1369
+
1370
+ # Pass bucketingSeed in context
1371
+ user_context = {
1372
+ 'id': 'unique_user_id',
1373
+ 'bucketingSeed': 'group_id_123' # This value will be used for bucketing
1374
+ }
1375
+
1376
+ # The user will be bucketed based on 'group_id_123' instead of 'unique_user_id'
1377
+ get_flag = wingify_client.get_flag('feature_key', user_context)
1378
+ ```
1379
+
1380
+ </details>
1381
+
1382
+ ## Local development
1383
+
1384
+ ```bash
1385
+ python setup.py develop
1386
+ ```
1387
+
1388
+ ## Running Unit Tests
1389
+
1390
+ ```bash
1391
+ python setup.py test
1392
+ ```
1393
+
1394
+ ## Authors
1395
+
1396
+ * [Abhishek Joshi](https://github.com/Abhi591)
1397
+
1398
+ ### Version History
1399
+
1400
+ The version history tracks changes, improvements, and bug fixes in each version. For a full history, see the [CHANGELOG.md](https://github.com/wingify/vwo-fme-python-sdk/blob/master/CHANGELOG.md).
1401
+
1402
+ ## Contributing
1403
+
1404
+ We welcome contributions to improve this SDK! Please read our [contributing guidelines](https://github.com/wingify/vwo-fme-python-sdk/blob/master/CONTRIBUTING.md) before submitting a PR.
1405
+
1406
+
1407
+ ## Code of Conduct
1408
+
1409
+ Our [Code of Conduct](https://github.com/wingify/vwo-fme-python-sdk/blob/master/CODE_OF_CONDUCT.md) outlines expectations for all contributors and maintainers.
1410
+
1411
+ ## License
1412
+
1413
+ [Apache License, Version 2.0](https://github.com/wingify/vwo-fme-python-sdk/blob/master/LICENSE)
1414
+
1415
+ Copyright 2024-2026 Wingify Software Pvt. Ltd.