yii3-ab-testing — deterministic, stateless A/B testing for Yii3 with explicit exposure tracking
$ composer require rasuvaeff/yii3-ab-testing
$assignment = $ab->assign(experiment: 'checkout-button', subjectId: (string) $userId); if ($assignment->isVariant('green')) { // Show green button.} // assign() does NOT auto-track. Call explicitly:$exposure = $ab->trackExposure($assignment);$ab->trackConversion($assignment, goal: 'purchase', exposure: $exposure);
Deterministic, stateless A/B testing for Yii3 with explicit exposure tracking.
Re-resolving an assignment later can return a different variant than the visitor saw. This package gives stable hash-based assignment, decision reasons, and receipts for later conversions.
subjectId always give the same variant (WeightedHashAssignmentStrategy).Assignment carries a reason (assigned, forced, fallback_*) and a source (computed, store).assign() is pure. trackExposure() and trackConversion() are explicit and return events.AssignmentReceipt links a conversion to the original exposure in a later request.AssignmentStore; ConfigurationAwareAssignmentStore drops stale pins when weights change.Attributes a later conversion to the variant the visitor actually saw, using an assignment receipt.
$receipt = $exposure->receipt();$_SESSION['ab_receipt'] = $receipt->toArray(); // or a signed cookie // … a later request … $receipt = AssignmentReceipt::fromArray($_SESSION['ab_receipt']);$ab->trackConversionForReceipt($receipt, goal: 'purchase', context: $context);
Allow-lists which context attributes reach analytics, with renaming and redaction.
new AllowListAnalyticsContextPolicy( allowedAttributes: ['country', 'plan', 'user'], renamedAttributes: ['country' => 'geo'],stored column name redactedAttributes: ['user'],kept as a column, value masked);
Wraps a tracker so the same exposure is emitted at most once per request.
$tracker = new DeduplicatingExposureTracker(tracker: $realExposureTracker);$tracker->trackExposure($exposureEvent);$tracker->trackExposure($exposureEvent);suppressed in this request
| Package | Role |
|---|---|
| yii3-ab-testing-db(3) | DB provider and sticky store |
| yii3-ab-testing-web(3) | Cookie sticky store, SubjectIdMiddleware |
| yii3-ab-testing-outbox(3) | Durable delivery of events |
| yii3-ab-testing-clickhouse(3) | ClickHouse analytics schema and migrations |
Changing weights or the variant set shifts bucket boundaries and reshuffles some subjects. Only a new salt freezes a cohort. Needs 64-bit PHP.
required by: yii3-ab-testing-clickhouse(3), yii3-ab-testing-db(3), yii3-ab-testing-outbox(3), yii3-ab-testing-web(3)
First released as v1.0.0 on 2026-06-10; 14 releases in all.
| v2.1.1 | 2026-09-02 |
| v2.1.0 | 2026-08-23 |
| v2.0.0 | 2026-08-01 |
| v1.6.0 | 2026-07-31 |
| v1.5.2 | 2026-07-29 |
| v1.5.1 | 2026-07-25 |
| v1.5.0 | 2026-07-24 |
| v1.4.2 | 2026-06-30 |
| v1.4.1 | 2026-06-27 |
| v1.4.0 | 2026-06-20 |
… and 4 earlier. All releases
/ search · n N next, previous · g G top, bottom · q back to the index