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