Skip to content

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 ​

PropertyTypeReadonlyDescription
eventIdstringyes
occurredAtDateTimeImmutableyes
experimentstringyes
variantstringyes
subjectIdstringyes
experimentRevision?stringyes
dimensionsarrayyes
reasonDecisionReasonyes
sourceAssignmentSourceyes
environmentstringyes

Methods ​

isAnalyzable() ​

php
isAnalyzable(): bool

Whether this exposure counts as experiment participation. Forced and fallback traffic is excluded from analysis regardless of its source.

receipt() ​

php
receipt(): AssignmentReceipt

Receipt for attributing a conversion that happens in a later request.