You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+100Lines changed: 100 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,8 @@ To customize the SDK further, additional parameters can be passed to the `init()
63
63
|`storage`| Custom storage connector for persisting user decisions and campaign data. data. | No | Dictionary | See [Storage](#storage) section |
64
64
|`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 |
65
65
|`integrations`| Callback function for integrating with third-party analytics services. | No | Function | See [Integrations](#integrations) section |
66
+
|`batch_event_data`| Configuration for batch event processing to optimize network requests | No | Dictionary | See [Batch Events](#batch-events) section |
67
+
|`threading`| Toggle threading for better (enabled by default) performance. | No | Dictionary | See [Threading](#threading) section |
66
68
67
69
### User Context
68
70
@@ -367,6 +369,104 @@ options = {
367
369
vwo_client = init(options)
368
370
```
369
371
372
+
### Threading
373
+
374
+
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.
|`enabled`| Enable or disable threading. | No | Boolean |`true`|
379
+
|`max_workers`| Maximum number of threads to use. | No | Integer |`5`|
380
+
381
+
#### Disable Threading
382
+
383
+
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.
384
+
385
+
Example showing blocking behavior:
386
+
387
+
```python
388
+
# By disabling threading, the SDK will wait for the response from the server for each tracking call.
389
+
from vwo import init
390
+
391
+
options = {
392
+
'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
393
+
'account_id': '123456', # VWO Account ID
394
+
'threading': {
395
+
'enabled': False
396
+
}
397
+
}
398
+
399
+
vwo_client = init(options)
400
+
```
401
+
402
+
#### Enable Threading (Default)
403
+
404
+
Threading in the VWO SDK provides several important benefits:
405
+
406
+
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.
407
+
408
+
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.
409
+
410
+
Example of how threading improves performance:
411
+
- Without threading: Each tracking call blocks until the server responds
412
+
- With threading: Tracking calls return immediately while processing happens in background
413
+
414
+
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:
415
+
416
+
```python
417
+
# By default, threading is enabled and the max_workers is set to 5.
418
+
# you can customize the max_workers by passing the max_workers parameter in the threading configuration.
419
+
from vwo import init
420
+
421
+
options = {
422
+
'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
423
+
'account_id': '123456', # VWO Account ID
424
+
'threading': {
425
+
'enabled': True,
426
+
'max_workers': 10
427
+
}
428
+
}
429
+
430
+
vwo_client = init(options)
431
+
```
432
+
433
+
### Batch Events
434
+
435
+
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.
0 commit comments