ExposureEvent
Rasuvaeff\Yii3AbTesting\ExposureEvent
Class · rasuvaeff/yii3-ab-testing · Source
A subject was shown a variant. This is the analytics event contract v2 — everything a report needs, and nothing storage-specific.
occurredAt is the moment the exposure was tracked, never the moment a worker later delivered it: deduplication and time partitioning both depend on it staying stable across retries. It is normalised to UTC on construction so every serializer produces the same bytes for the same event.
Constructor
php
new ExposureEvent(
string $eventId,
DateTimeImmutable $occurredAt,
string $experiment,
string $variant,
string $subjectId,
DecisionReason $reason,
AssignmentSource $source,
?string $experimentRevision = null,
string $environment = '',
array $dimensions = [],
)$environment— Empty string means "no context", which is a legitimate value rather than a missing one.$dimensions— Already filtered by an {@see AnalyticsContextPolicy}; the event does not filter again.
Properties
| Property | Type | Readonly | Description |
|---|---|---|---|
eventId | string | yes | |
occurredAt | DateTimeImmutable | yes | |
experiment | string | yes | |
variant | string | yes | |
subjectId | string | yes | |
experimentRevision | ?string | yes | |
dimensions | array | yes | |
reason | DecisionReason | yes | |
source | AssignmentSource | yes | |
environment | string | yes |
Methods
isAnalyzable()
php
isAnalyzable(): boolWhether this exposure counts as experiment participation. Forced and fallback traffic is excluded from analysis regardless of its source.
receipt()
php
receipt(): AssignmentReceiptReceipt for attributing a conversion that happens in a later request.