Skip to content

Commit 2afed95

Browse files
committed
MAGE-787 Fixed issue with cookies not cleared when customer logs out
1 parent 584c0ed commit 2afed95

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Observer/Insights/CustomerLogout.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Observer\Insights;
4+
5+
use Algolia\AlgoliaSearch\Helper\InsightsHelper;
6+
use Magento\Customer\Model\Customer;
7+
use Magento\Framework\Event\Observer;
8+
use Magento\Framework\Event\ObserverInterface;
9+
10+
class CustomerLogout implements ObserverInterface
11+
{
12+
13+
/** @var InsightsHelper */
14+
protected $insightsHelper;
15+
16+
/**
17+
* @param InsightsHelper $insightsHelper
18+
*/
19+
public function __construct(
20+
InsightsHelper $insightsHelper
21+
)
22+
{
23+
$this->insightsHelper = $insightsHelper;
24+
}
25+
26+
/**
27+
* @param Observer $observer
28+
* ['customer' => $customer]
29+
*/
30+
public function execute(Observer $observer)
31+
{
32+
/** @var Customer $customer */
33+
$customer = $observer->getEvent()->getCustomer();
34+
35+
if ($this->insightsHelper->getConfigHelper()->isClickConversionAnalyticsEnabled($customer->getStoreId()) || $this->insightsHelper->getPersonalizationHelper()->isPersoEnabled($customer->getStoreId())) {
36+
$this->insightsHelper->unsetUserToken($customer);
37+
}
38+
}
39+
}

etc/frontend/events.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@
2323
<event name="checkout_onepage_controller_success_action">
2424
<observer name="algoliasearch_insights_place_order_event" instance="Algolia\AlgoliaSearch\Observer\Insights\CheckoutOnepageControllerSuccessAction" />
2525
</event>
26+
<event name="customer_logout">
27+
<observer name="algoliasearch_personalization_unset_user_token" instance="Algolia\AlgoliaSearch\Observer\Insights\CustomerLogout" />
28+
</event>
2629
</config>

0 commit comments

Comments
 (0)