This PR encompasses several improvements for the added to cart event. Namely it enforces the payload size, and doesn't allow for rows with truncated payload to be committed to the database.
Previously, truncated Added to Cart payloads would raise unhandled exceptions when processing in both Cron/EventsTopic.php and Cron/KlSyncs.php, which in turn would prevent the processing of the remaining rows. The unhandled exceptions also prevented the rows that were able to move over to the kl_sync table from being marked as MOVED, leading to repetitive processing and continuous retries. This PR adds exception handling which will log the exception and mark any rows that raise exceptions during processing as FAILED. The cleanup crons have been adjusted to additionally delete FAILED rows from both the kl_events table and the kl_sync table. Previously these rows would remain indefinitely.
These fixes are intended to prevent truncated payloads for future events and clear out failed events from the database. Future improvements will be made to further optimize the Added to Cart event.
Manual Testing Steps
Pre-change, recreated the issue with truncated payloads. Triggered a variety of Added to Cart events, some with truncated payloads, some without.
After changes, verified that an event with a payload exceeding the maximum character count would not be added to the kl_events table and that a log was created.
Verified that the klaviyo_events_topic cron processed all rows - marking those with existing truncated payloads as FAILED and marking all rows with valid payloads as MOVED.
Verified that the klaviyo_webhook/event_sync cron processed all rows - marking those with truncated payloads as failed.
Verified that the 2 cleanup crons removed rows marked as FAILED for both tables, as well as MOVED for kl_events and SYNCED for kl_sync.
Pre-Submission Checklist:
[ ] You've updated the CHANGELOG following the steps here
[ ] Internal Only - If this is a release, have you:
[ ] Updated the links in the CHANGELOG to point towards the new versions
[ ] Incremented the version in the following places: module.xml and composer.json
Description
This PR encompasses several improvements for the added to cart event. Namely it enforces the payload size, and doesn't allow for rows with truncated payload to be committed to the database.
Previously, truncated Added to Cart payloads would raise unhandled exceptions when processing in both
Cron/EventsTopic.php
andCron/KlSyncs.php
, which in turn would prevent the processing of the remaining rows. The unhandled exceptions also prevented the rows that were able to move over to the kl_sync table from being marked as MOVED, leading to repetitive processing and continuous retries. This PR adds exception handling which will log the exception and mark any rows that raise exceptions during processing as FAILED. The cleanup crons have been adjusted to additionally delete FAILED rows from both the kl_events table and the kl_sync table. Previously these rows would remain indefinitely.These fixes are intended to prevent truncated payloads for future events and clear out failed events from the database. Future improvements will be made to further optimize the Added to Cart event.
Manual Testing Steps
klaviyo_events_topic
cron processed all rows - marking those with existing truncated payloads as FAILED and marking all rows with valid payloads as MOVED.klaviyo_webhook/event_sync
cron processed all rows - marking those with truncated payloads as failed.Pre-Submission Checklist: