growthbook 1.4.4__py2.py3-none-any.whl → 1.4.5__py2.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.
- growthbook/__init__.py +1 -1
- growthbook/common_types.py +1 -0
- growthbook/growthbook.py +15 -5
- growthbook/growthbook_client.py +28 -2
- {growthbook-1.4.4.dist-info → growthbook-1.4.5.dist-info}/METADATA +1 -1
- growthbook-1.4.5.dist-info/RECORD +15 -0
- growthbook-1.4.4.dist-info/RECORD +0 -15
- {growthbook-1.4.4.dist-info → growthbook-1.4.5.dist-info}/WHEEL +0 -0
- {growthbook-1.4.4.dist-info → growthbook-1.4.5.dist-info}/licenses/LICENSE +0 -0
- {growthbook-1.4.4.dist-info → growthbook-1.4.5.dist-info}/top_level.txt +0 -0
growthbook/__init__.py
CHANGED
growthbook/common_types.py
CHANGED
|
@@ -426,6 +426,7 @@ class Options:
|
|
|
426
426
|
sticky_bucket_service: Optional[AbstractStickyBucketService] = None
|
|
427
427
|
sticky_bucket_identifier_attributes: Optional[List[str]] = None
|
|
428
428
|
on_experiment_viewed: Optional[Callable[[Experiment, Result, Optional[UserContext]], None]] = None
|
|
429
|
+
on_feature_usage: Optional[Callable[[str, 'FeatureResult'], None]] = None
|
|
429
430
|
tracking_plugins: Optional[List[Any]] = None
|
|
430
431
|
|
|
431
432
|
|
growthbook/growthbook.py
CHANGED
|
@@ -565,6 +565,7 @@ class GrowthBook(object):
|
|
|
565
565
|
features: dict = {},
|
|
566
566
|
qa_mode: bool = False,
|
|
567
567
|
on_experiment_viewed=None,
|
|
568
|
+
on_feature_usage=None,
|
|
568
569
|
api_host: str = "",
|
|
569
570
|
client_key: str = "",
|
|
570
571
|
decryption_key: str = "",
|
|
@@ -603,6 +604,7 @@ class GrowthBook(object):
|
|
|
603
604
|
|
|
604
605
|
self._qaMode = qa_mode or qaMode
|
|
605
606
|
self._trackingCallback = on_experiment_viewed or trackingCallback
|
|
607
|
+
self._featureUsageCallback = on_feature_usage
|
|
606
608
|
|
|
607
609
|
self._streaming = streaming
|
|
608
610
|
self._streaming_timeout = streaming_connection_timeout
|
|
@@ -823,6 +825,7 @@ class GrowthBook(object):
|
|
|
823
825
|
self._tracked.clear()
|
|
824
826
|
self._assigned.clear()
|
|
825
827
|
self._trackingCallback = None
|
|
828
|
+
self._featureUsageCallback = None
|
|
826
829
|
self._forcedVariations.clear()
|
|
827
830
|
self._overrides.clear()
|
|
828
831
|
self._groups.clear()
|
|
@@ -886,11 +889,18 @@ class GrowthBook(object):
|
|
|
886
889
|
)
|
|
887
890
|
|
|
888
891
|
def eval_feature(self, key: str) -> FeatureResult:
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
892
|
+
result = core_eval_feature(key=key,
|
|
893
|
+
evalContext=self._get_eval_context(),
|
|
894
|
+
callback_subscription=self._fireSubscriptions,
|
|
895
|
+
tracking_cb=self._track
|
|
896
|
+
)
|
|
897
|
+
# Call feature usage callback if provided
|
|
898
|
+
if self._featureUsageCallback:
|
|
899
|
+
try:
|
|
900
|
+
self._featureUsageCallback(key, result)
|
|
901
|
+
except Exception:
|
|
902
|
+
pass
|
|
903
|
+
return result
|
|
894
904
|
|
|
895
905
|
# @deprecated, use get_all_results
|
|
896
906
|
def getAllResults(self):
|
growthbook/growthbook_client.py
CHANGED
|
@@ -500,24 +500,50 @@ class GrowthBookClient:
|
|
|
500
500
|
async with self._context_lock:
|
|
501
501
|
context = await self.create_evaluation_context(user_context)
|
|
502
502
|
result = core_eval_feature(key=key, evalContext=context, tracking_cb=self._track)
|
|
503
|
+
# Call feature usage callback if provided
|
|
504
|
+
if self.options.on_feature_usage:
|
|
505
|
+
try:
|
|
506
|
+
self.options.on_feature_usage(key, result)
|
|
507
|
+
except Exception:
|
|
508
|
+
logger.exception("Error in feature usage callback")
|
|
503
509
|
return result
|
|
504
510
|
|
|
505
511
|
async def is_on(self, key: str, user_context: UserContext) -> bool:
|
|
506
512
|
"""Check if a feature is enabled with proper async context management"""
|
|
507
513
|
async with self._context_lock:
|
|
508
514
|
context = await self.create_evaluation_context(user_context)
|
|
509
|
-
|
|
515
|
+
result = core_eval_feature(key=key, evalContext=context, tracking_cb=self._track)
|
|
516
|
+
# Call feature usage callback if provided
|
|
517
|
+
if self.options.on_feature_usage:
|
|
518
|
+
try:
|
|
519
|
+
self.options.on_feature_usage(key, result)
|
|
520
|
+
except Exception:
|
|
521
|
+
logger.exception("Error in feature usage callback")
|
|
522
|
+
return result.on
|
|
510
523
|
|
|
511
524
|
async def is_off(self, key: str, user_context: UserContext) -> bool:
|
|
512
525
|
"""Check if a feature is set to off with proper async context management"""
|
|
513
526
|
async with self._context_lock:
|
|
514
527
|
context = await self.create_evaluation_context(user_context)
|
|
515
|
-
|
|
528
|
+
result = core_eval_feature(key=key, evalContext=context, tracking_cb=self._track)
|
|
529
|
+
# Call feature usage callback if provided
|
|
530
|
+
if self.options.on_feature_usage:
|
|
531
|
+
try:
|
|
532
|
+
self.options.on_feature_usage(key, result)
|
|
533
|
+
except Exception:
|
|
534
|
+
logger.exception("Error in feature usage callback")
|
|
535
|
+
return result.off
|
|
516
536
|
|
|
517
537
|
async def get_feature_value(self, key: str, fallback: Any, user_context: UserContext) -> Any:
|
|
518
538
|
async with self._context_lock:
|
|
519
539
|
context = await self.create_evaluation_context(user_context)
|
|
520
540
|
result = core_eval_feature(key=key, evalContext=context, tracking_cb=self._track)
|
|
541
|
+
# Call feature usage callback if provided
|
|
542
|
+
if self.options.on_feature_usage:
|
|
543
|
+
try:
|
|
544
|
+
self.options.on_feature_usage(key, result)
|
|
545
|
+
except Exception:
|
|
546
|
+
logger.exception("Error in feature usage callback")
|
|
521
547
|
return result.value if result.value is not None else fallback
|
|
522
548
|
|
|
523
549
|
async def run(self, experiment: Experiment, user_context: UserContext) -> Result:
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
growthbook/__init__.py,sha256=JLdue4592q3iH1ck1qG9Fbv-p8i07SJo-tUJhGCf60s,444
|
|
2
|
+
growthbook/common_types.py,sha256=KYA9rmWRMde2JnsUjygsiaJ1q-KZakDdzPAtUOnrKyY,14959
|
|
3
|
+
growthbook/core.py,sha256=n9nwna26iZTY48LIvQqu5N_RrE35X0wlRBhq0-Qdb-s,35241
|
|
4
|
+
growthbook/growthbook.py,sha256=xjuX-q8oPsLqP0kWBZqy7LpoTkrgjMZCOWjtpUsQR1o,39793
|
|
5
|
+
growthbook/growthbook_client.py,sha256=kfdc2NGhdmsXxaVIm0CBlNCMkwicfPpbDZ10nZSPd7w,24576
|
|
6
|
+
growthbook/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
growthbook/plugins/__init__.py,sha256=y2eAV1sA041XWcftBVTDH0t-ggy9r2C5oKRYRF6XR6s,602
|
|
8
|
+
growthbook/plugins/base.py,sha256=PWBXUBj62hi25Y5Eif9WmEWagWdkwGXHi2dMtn44bo8,3637
|
|
9
|
+
growthbook/plugins/growthbook_tracking.py,sha256=FvPFOuKF_xKjmTX8x_hzMlHrrL-68Y2ZPw1Hfl2_ilQ,11333
|
|
10
|
+
growthbook/plugins/request_context.py,sha256=O5FJDrjJR5u0rx3ENGO9cOsKMHd9e0l0Nvdb1PHfmm8,12951
|
|
11
|
+
growthbook-1.4.5.dist-info/licenses/LICENSE,sha256=D-TcBckB0dTPUlNJ8jBiTIJIj1ekHLB1CY7HJtJKhMY,1069
|
|
12
|
+
growthbook-1.4.5.dist-info/METADATA,sha256=8KBWZ908qYYku0GqZCeZ1KNS5YLPxs7FXZVl6wesLWM,22074
|
|
13
|
+
growthbook-1.4.5.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
|
|
14
|
+
growthbook-1.4.5.dist-info/top_level.txt,sha256=dzfRQFGYejCIUstRSrrRVTMlxf7pBqASTI5S8gGRlXw,11
|
|
15
|
+
growthbook-1.4.5.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
growthbook/__init__.py,sha256=sEc27BZrhkkInXWijTKKmrZ4kfeyR3z8V7SFG7ykvM0,444
|
|
2
|
-
growthbook/common_types.py,sha256=OUGkqoUuYetWz1cyA1eWz5DM3awYw_ExcNAjFqJuGAc,14881
|
|
3
|
-
growthbook/core.py,sha256=n9nwna26iZTY48LIvQqu5N_RrE35X0wlRBhq0-Qdb-s,35241
|
|
4
|
-
growthbook/growthbook.py,sha256=E4CrSOtrbnYKfuC-_7NAsZwqtRnRy7h8j9MsRestXMI,39417
|
|
5
|
-
growthbook/growthbook_client.py,sha256=1bDIuJoxlKUR_bKe_gD6V7JlUPt53uGgix9DhgSkPPc,23360
|
|
6
|
-
growthbook/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
growthbook/plugins/__init__.py,sha256=y2eAV1sA041XWcftBVTDH0t-ggy9r2C5oKRYRF6XR6s,602
|
|
8
|
-
growthbook/plugins/base.py,sha256=PWBXUBj62hi25Y5Eif9WmEWagWdkwGXHi2dMtn44bo8,3637
|
|
9
|
-
growthbook/plugins/growthbook_tracking.py,sha256=FvPFOuKF_xKjmTX8x_hzMlHrrL-68Y2ZPw1Hfl2_ilQ,11333
|
|
10
|
-
growthbook/plugins/request_context.py,sha256=O5FJDrjJR5u0rx3ENGO9cOsKMHd9e0l0Nvdb1PHfmm8,12951
|
|
11
|
-
growthbook-1.4.4.dist-info/licenses/LICENSE,sha256=D-TcBckB0dTPUlNJ8jBiTIJIj1ekHLB1CY7HJtJKhMY,1069
|
|
12
|
-
growthbook-1.4.4.dist-info/METADATA,sha256=961Hf5woy1DJDd1hKGl7maQLAGUv_A2pvEM32l1GKZs,22074
|
|
13
|
-
growthbook-1.4.4.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
|
|
14
|
-
growthbook-1.4.4.dist-info/top_level.txt,sha256=dzfRQFGYejCIUstRSrrRVTMlxf7pBqASTI5S8gGRlXw,11
|
|
15
|
-
growthbook-1.4.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|