Skip to content

Commit c77224d

Browse files
committed
ADO-313: prevents purchase event from triggering multiple times for same purchase
1 parent 86cd964 commit c77224d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app/code/Meta/Conversion/Model/CapiTracker.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Magento\Customer\Model\Session as CustomerSession;
88
use Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
99
use Magento\Framework\MessageQueue\PublisherInterface;
10+
use Meta\Conversion\Model\Tracker\Purchase;
1011

1112
class CapiTracker
1213
{
@@ -27,6 +28,11 @@ public function __construct(
2728
public function execute(array $payload, string $eventName, string $eventType, bool $useSessionForEventIds = false): void
2829
{
2930
if (isset($payload)) {
31+
// Purchase event is triggered twice sometimes, to prevent that check if event id is already stored for current request
32+
// if it does prevent the message form being added to the message queue.
33+
if ((Purchase::EVENT_TYPE == $eventType) && $this->capiEventIdHandler->getMetaEventId($eventName)) {
34+
return;
35+
}
3036
$eventId = $this->generateEventId($eventName, $useSessionForEventIds);
3137
$payload['event_id'] = $eventId;
3238
$payload['event_type'] = $eventType;

app/code/Meta/Conversion/Model/Tracker/Purchase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
class Purchase implements TrackerInterface
2424
{
25-
private const EVENT_TYPE = "Purchase";
25+
public const EVENT_TYPE = "Purchase";
2626
/**
2727
* @var FBEHelper
2828
*/

0 commit comments

Comments
 (0)