Skip to content

DefaultAbTestingOutboxMessageFactory ​

Rasuvaeff\Yii3AbTestingOutbox\DefaultAbTestingOutboxMessageFactory

Class · rasuvaeff/yii3-ab-testing-outbox · Source · implements AbTestingOutboxMessageFactoryInterface

Serializes a core event into an outbox message.

The payload is the canonical schema v2 row, produced by the core's own serializer rather than assembled here. In v1 this class built its own array, which is precisely how the two delivery paths drifted: the direct sink and the outbox dropped different fields, and nothing noticed.

event_id is written into the payload and handed to Outbox::record(id: …) by the trackers, so the message id and the payload field always agree. That matters because the ClickHouse exporter may fill the event-id column from either, and a mismatch would split one event into two rows that never deduplicate.

Constants ​

PAYLOAD_VERSION ​

php
PAYLOAD_VERSION = 2

Kept as a class constant because consumers branch on it during the migration window; it mirrors CanonicalEventSerializer::SCHEMA_VERSION.

Constructor ​

php
new DefaultAbTestingOutboxMessageFactory(
    AggregateIdStrategyInterface $aggregateIdStrategy,
    EventSerializer $serializer = new CanonicalEventSerializer(),
)

Methods ​

exposure() ​

php
exposure(ExposureEvent $event): AbTestingOutboxPayload

conversion() ​

php
conversion(ConversionEvent $event): AbTestingOutboxPayload