@@ -452,6 +452,14 @@ def get_variant_for_identifier(
452
452
) -> Optional [str ]:
453
453
"""Return a bucketing variant, if any, with auto-exposure for a given :code:`identifier`.
454
454
455
+ Note: If the experiment's :code:`bucket_val` (e.g. "user_id", "device_id", "canonical_url")
456
+ does not match the :code:`identifier_type` param,
457
+ the :code:`identifier` will be ignored and not used to bucket (:code:`{identifier_type: identifier}` is
458
+ added to internal :code:`DeciderContext` instance, but doesn't act like a bucketing override).
459
+
460
+ If the :code:`bucket_val` field exists on the :code:`DeciderContext` instance,
461
+ that field will be used to bucket, since it corresponds to the experiment's config.
462
+
455
463
Since calling :code:`get_variant_for_identifier()` will fire an exposure event, it
456
464
is best to call it when you are sure the user will be exposed to the experiment.
457
465
@@ -460,8 +468,11 @@ def get_variant_for_identifier(
460
468
:param identifier: an arbitary string used to bucket the experiment by
461
469
being set on :code:`DeciderContext`'s :code:`identifier_type` field.
462
470
463
- :param identifier_type: Sets :code:`{identifier_type: identifier}` on DeciderContext and
464
- should match an experiment's :code:`bucket_val` to get a variant.
471
+ :param identifier_type: Sets :code:`{identifier_type: identifier}` on :code:`DeciderContext`.
472
+ The experiment's :code:`bucket_val` will be looked up in :code:`DeciderContext` and be used to bucket.
473
+ If the experiment's :code:`bucket_val` field does not match :code:`identifier_type` param,
474
+ :code:`identifier` will be ignored, and the field corresponding :code:`bucket_val` will be looked up
475
+ from :code:`DeciderContext` for bucketing.
465
476
466
477
:param exposure_kwargs: Additional arguments that will be passed
467
478
to :code:`events_logger` (keys must be part of v2 event schema,
@@ -508,6 +519,14 @@ def get_variant_for_identifier_without_expose(
508
519
) -> Optional [str ]:
509
520
"""Return a bucketing variant, if any, without emitting exposure event for a given :code:`identifier`.
510
521
522
+ Note: If the experiment's :code:`bucket_val` (e.g. "user_id", "device_id", "canonical_url")
523
+ does not match the :code:`identifier_type` param,
524
+ the :code:`identifier` will be ignored and not used to bucket (:code:`{identifier_type: identifier}` is
525
+ added to internal :code:`DeciderContext` instance, but doesn't act like a bucketing override).
526
+
527
+ If the :code:`bucket_val` field exists on the :code:`DeciderContext` instance,
528
+ that field will be used to bucket, since it corresponds to the experiment's config.
529
+
511
530
The :code:`expose()` function is available to be manually called afterward to emit
512
531
exposure event.
513
532
@@ -522,8 +541,11 @@ def get_variant_for_identifier_without_expose(
522
541
:param identifier: an arbitary string used to bucket the experiment by
523
542
being set on :code:`DeciderContext`'s :code:`identifier_type` field.
524
543
525
- :param identifier_type: Sets :code:`{identifier_type: identifier}` on DeciderContext and
526
- should match an experiment's :code:`bucket_val` to get a variant.
544
+ :param identifier_type: Sets :code:`{identifier_type: identifier}` on :code:`DeciderContext`.
545
+ The experiment's :code:`bucket_val` will be looked up in :code:`DeciderContext` and be used to bucket.
546
+ If the experiment's :code:`bucket_val` field does not match :code:`identifier_type` param,
547
+ :code:`identifier` will be ignored and the field corresponding :code:`bucket_val` will be looked up
548
+ from :code:`DeciderContext` for bucketing.
527
549
528
550
:return: Variant name if a variant is assigned, None otherwise.
529
551
"""
@@ -631,7 +653,8 @@ def get_all_variants_without_expose(self) -> List[Dict[str, Union[str, int]]]:
631
653
def get_all_variants_for_identifier_without_expose (
632
654
self , identifier : str , identifier_type : Literal ["user_id" , "device_id" , "canonical_url" ]
633
655
) -> List [Dict [str , Union [str , int ]]]:
634
- """Return a list of experiment dicts for a given :code:`identifier` in this format:
656
+ """Return a list of experiment dicts for experiments having :code:`bucket_val` match
657
+ :code:`identifier_type`, for a given :code:`identifier`, in this format:
635
658
636
659
.. code-block:: json
637
660
@@ -658,7 +681,7 @@ def get_all_variants_for_identifier_without_expose(
658
681
being set on :code:`DeciderContext`'s :code:`identifier_type` field.
659
682
660
683
:param identifier_type: Sets :code:`{identifier_type: identifier}` on DeciderContext and
661
- should match an experiment's :code:`bucket_val` to get a variant .
684
+ buckets all experiment with matching :code:`bucket_val`.
662
685
663
686
:return: list of experiment dicts with non-:code:`None` variants.
664
687
"""
0 commit comments