Skip to content

Commit

Permalink
Merged PR 60301: Fail rows in campaign sync if we cannot get or creat…
Browse files Browse the repository at this point in the history
…e contact

## What's being changed

Campaign sync. If we cannot get or create a contact, this indicates a problem and we should fail the send.

## Why it's being changed

If we don't fail the send, the same row will be processed on the next sync, and skipped again. Campaign sync can only send to 10 contact ids in one request, so the database query is also limited to 10. This means that pretty quickly, if we don't fail the sends, we're not able to send any campaigns at all because we keep checking the same 10 rows.

## How to review / test this change

- Create a contact in all caps in Dotdigital
- Suppress this contact
- In Magento create an account for this contact (use lowercase now)
- Place an order
- Review the product in your order
- Now set up campaign sends for order reviews
- Run review sync to get a campaign in email_campaign
- Run campaign sync

## Notes
The all-caps / lowercase switch is intended to trigger a (400) ResponseValidationException from the PATCH request. This may not always happen because it relates to a platform bug. The fact remains though, that if we can't get or create a contact, there's a problem, and we can't proceed with the send.

There is an expiry on 'processing' sends but not on 'pending' sends. The Cleaner does clear out campaigns, but by default, only once per month, for records older than 1 month.

Related work items: #279514
  • Loading branch information
sta1r committed Dec 2, 2024
1 parent ce239a5 commit 5582097
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Model/Sync/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@ private function getCampaignsToSend($emailsToSend, $website)
(int) $campaign->getStoreId()
);
} catch (ResponseValidationException $e) {
$campaign->setSendStatus(CampaignModel::FAILED)
->setMessage($e->getMessage());
$this->campaignResourceModel->saveItem($campaign);
$this->logger->error(
sprintf(
'%s: %s',
'Error getting contact in campaign sync',
'Error getting contact %s in campaign sync: %s',
$campaign->getEmail(),
$e->getMessage()
),
[$e->getDetails()]
Expand Down

0 comments on commit 5582097

Please sign in to comment.