diff --git a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php b/app/code/core/Mage/GoogleAnalytics/Block/Ga.php index 62cc5f09e3e..211a5aee159 100644 --- a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php +++ b/app/code/core/Mage/GoogleAnalytics/Block/Ga.php @@ -21,47 +21,6 @@ */ class Mage_GoogleAnalytics_Block_Ga extends Mage_Core_Block_Template { - /** - * @deprecated after 1.4.1.1 - * @see self::_getOrdersTrackingCode() - * @return string - */ - public function getQuoteOrdersHtml() - { - return ''; - } - - /** - * @deprecated after 1.4.1.1 - * self::_getOrdersTrackingCode() - * @return string - */ - public function getOrderHtml() - { - return ''; - } - - /** - * @deprecated after 1.4.1.1 - * @see _toHtml() - * @return string - */ - public function getAccount() - { - return ''; - } - - /** - * Get a specific page name (may be customized via layout) - * - * @return string - * @deprecated - */ - public function getPageName() - { - return $this->_getData('page_name') ?? ''; - } - /** * Render regular page tracking javascript code * The custom "page name" may be set from layout or somewhere else. It must start from slash. @@ -75,11 +34,9 @@ protected function _getPageTrackingCode($accountId) $helper = $this->helper('googleanalytics'); if ($helper->isUseAnalytics4()) { return $this->_getPageTrackingCodeAnalytics4($accountId); - } elseif ($helper->isUseUniversalAnalytics()) { - return $this->_getPageTrackingCodeUniversal($accountId); - } else { - return $this->_getPageTrackingCodeAnalytics($accountId); } + + return ''; } /** @@ -125,14 +82,11 @@ protected function _getPageTrackingCodeAnalytics4($accountId) * * @param string $accountId * @return string + * @deprecated */ protected function _getPageTrackingCodeUniversal($accountId) { - return " -ga('create', '{$this->jsQuoteEscape($accountId)}', 'auto'); -" . $this->_getAnonymizationCode() . " -ga('send', 'pageview'); -"; + return ''; } /** @@ -143,19 +97,11 @@ protected function _getPageTrackingCodeUniversal($accountId) * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gaq.html * @param string $accountId * @return string + * @deprecated */ protected function _getPageTrackingCodeAnalytics($accountId) { - $pageName = trim($this->getPageName()); - $optPageURL = ''; - if ($pageName && preg_match('/^\/.*/i', $pageName)) { - $optPageURL = ", '{$this->jsQuoteEscape($pageName)}'"; - } - return " -_gaq.push(['_setAccount', '{$this->jsQuoteEscape($accountId)}']); -" . $this->_getAnonymizationCode() . " -_gaq.push(['_trackPageview'{$optPageURL}]); -"; + return ''; } /** @@ -170,65 +116,9 @@ protected function _getOrdersTrackingCode() $helper = $this->helper('googleanalytics'); if ($helper->isUseAnalytics4()) { return $this->_getOrdersTrackingCodeAnalytics4(); - } elseif ($helper->isUseUniversalAnalytics()) { - return $this->_getOrdersTrackingCodeUniversal(); } - return $this->_getOrdersTrackingCodeAnalytics(); - } - - /** - * Render information about specified orders and their items - * - * @return string - * @throws Mage_Core_Model_Store_Exception - */ - protected function _getOrdersTrackingCodeUniversal() - { - $orderIds = $this->getOrderIds(); - if (empty($orderIds) || !is_array($orderIds)) { - return; - } - $collection = Mage::getResourceModel('sales/order_collection') - ->addFieldToFilter('entity_id', ['in' => $orderIds]); - $result = []; - $result[] = "ga('require', 'ecommerce')"; - foreach ($collection as $order) { - $result[] = sprintf( - "ga('ecommerce:addTransaction', { -'id': '%s', -'affiliation': '%s', -'revenue': '%s', -'tax': '%s', -'shipping': '%s' -});", - $order->getIncrementId(), - $this->jsQuoteEscape(Mage::app()->getStore()->getFrontendName()), - $order->getBaseGrandTotal(), - $order->getBaseTaxAmount(), - $order->getBaseShippingAmount() - ); - foreach ($order->getAllVisibleItems() as $item) { - $result[] = sprintf( - "ga('ecommerce:addItem', { -'id': '%s', -'sku': '%s', -'name': '%s', -'category': '%s', -'price': '%s', -'quantity': '%s' -});", - $order->getIncrementId(), - $this->jsQuoteEscape($item->getSku()), - $this->jsQuoteEscape($item->getName()), - null, // there is no "category" defined for the order item - $item->getBasePrice(), - $item->getQtyOrdered() - ); - } - $result[] = "ga('ecommerce:send');"; - } - return implode("\n", $result); + return ''; } /** @@ -501,97 +391,6 @@ protected function _getOrdersTrackingCodeAnalytics4() } /** - * Render information about specified orders and their items - * - * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addTrans - * @return string - * @throws Mage_Core_Model_Store_Exception - */ - protected function _getOrdersTrackingCodeAnalytics() - { - $orderIds = $this->getOrderIds(); - if (empty($orderIds) || !is_array($orderIds)) { - return; - } - $collection = Mage::getResourceModel('sales/order_collection') - ->addFieldToFilter('entity_id', ['in' => $orderIds]); - $result = []; - foreach ($collection as $order) { - if ($order->getIsVirtual()) { - $address = $order->getBillingAddress(); - } else { - $address = $order->getShippingAddress(); - } - $result[] = sprintf( - "_gaq.push(['_addTrans', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s']);", - $order->getIncrementId(), - $this->jsQuoteEscape(Mage::app()->getStore()->getFrontendName()), - $order->getBaseGrandTotal(), - $order->getBaseTaxAmount(), - $order->getBaseShippingAmount(), - $this->jsQuoteEscape(Mage::helper('core')->escapeHtml($address->getCity())), - $this->jsQuoteEscape(Mage::helper('core')->escapeHtml($address->getRegion())), - $this->jsQuoteEscape(Mage::helper('core')->escapeHtml($address->getCountry())) - ); - foreach ($order->getAllVisibleItems() as $item) { - $result[] = sprintf( - "_gaq.push(['_addItem', '%s', '%s', '%s', '%s', '%s', '%s']);", - $order->getIncrementId(), - $this->jsQuoteEscape($item->getSku()), - $this->jsQuoteEscape($item->getName()), - null, // there is no "category" defined for the order item - $item->getBasePrice(), - $item->getQtyOrdered() - ); - } - $result[] = "_gaq.push(['_trackTrans']);"; - } - return implode("\n", $result); - } - - /** - * Render IP anonymization code for page tracking javascript code - * - * @return string - */ - protected function _getAnonymizationCode() - { - if (!Mage::helper('googleanalytics')->isIpAnonymizationEnabled()) { - return ''; - } - - /** @var Mage_GoogleAnalytics_Helper_Data $helper */ - $helper = $this->helper('googleanalytics'); - if ($helper->isUseUniversalAnalytics()) { - return $this->_getAnonymizationCodeUniversal(); - } - - return $this->_getAnonymizationCodeAnalytics(); - } - - /** - * Render IP anonymization code for page tracking javascript universal analytics code - * - * @return string - */ - protected function _getAnonymizationCodeUniversal() - { - return "ga('set', 'anonymizeIp', true);"; - } - - /** - * Render IP anonymization code for page tracking javascript google analytics code - * - * @return string - */ - protected function _getAnonymizationCodeAnalytics() - { - return "_gaq.push (['_gat._anonymizeIp']);"; - } - - /** - * Is ga available - * * @return bool */ protected function _isAvailable() diff --git a/app/code/core/Mage/GoogleAnalytics/Helper/Data.php b/app/code/core/Mage/GoogleAnalytics/Helper/Data.php index 7136ea224ec..759fc2ca5f9 100644 --- a/app/code/core/Mage/GoogleAnalytics/Helper/Data.php +++ b/app/code/core/Mage/GoogleAnalytics/Helper/Data.php @@ -27,7 +27,6 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract public const XML_PATH_ACTIVE = 'google/analytics/active'; public const XML_PATH_TYPE = 'google/analytics/type'; public const XML_PATH_ACCOUNT = 'google/analytics/account'; - public const XML_PATH_ANONYMIZATION = 'google/analytics/anonymization'; public const XML_PATH_DEBUG = 'google/analytics/debug'; public const XML_PATH_USERID = 'google/analytics/user_id'; @@ -37,17 +36,8 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract public const TYPE_ANALYTICS4 = 'analytics4'; /** - * @var string classic google analytics tracking code - * @deprecated + * @var string */ - public const TYPE_ANALYTICS = 'analytics'; - - /** - * @var string google analytics universal tracking code - * @deprecated - */ - public const TYPE_UNIVERSAL = 'universal'; - protected $_moduleName = 'Mage_GoogleAnalytics'; /** @@ -67,10 +57,11 @@ public function isGoogleAnalyticsAvailable($store = null) * * @param null|string|bool|int|Mage_Core_Model_Store $store $store * @return bool + * @deprecated */ public function isIpAnonymizationEnabled($store = null) { - return Mage::getStoreConfigFlag(self::XML_PATH_ANONYMIZATION, $store); + return false; } /** @@ -93,7 +84,7 @@ public function getAccountId($store = null) */ public function isUseUniversalAnalytics($store = null) { - return Mage::getStoreConfig(self::XML_PATH_TYPE, $store) == self::TYPE_UNIVERSAL; + return false; } /** diff --git a/app/code/core/Mage/GoogleAnalytics/Model/Observer.php b/app/code/core/Mage/GoogleAnalytics/Model/Observer.php index 772312819f5..728a0ae2fe6 100644 --- a/app/code/core/Mage/GoogleAnalytics/Model/Observer.php +++ b/app/code/core/Mage/GoogleAnalytics/Model/Observer.php @@ -21,18 +21,6 @@ */ class Mage_GoogleAnalytics_Model_Observer { - /** - * Create Google Analytics block for success page view - * - * @deprecated after 1.3.2.3 Use setGoogleAnalyticsOnOrderSuccessPageView() method instead - * @param Varien_Event_Observer $observer - */ - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps - public function order_success_page_view($observer) - { - $this->setGoogleAnalyticsOnOrderSuccessPageView($observer); - } - /** * Add order information into GA block to render on checkout success pages * diff --git a/app/code/core/Mage/GoogleAnalytics/Model/System/Config/Source/Type.php b/app/code/core/Mage/GoogleAnalytics/Model/System/Config/Source/Type.php index fe55276cc49..d4b76e9511b 100644 --- a/app/code/core/Mage/GoogleAnalytics/Model/System/Config/Source/Type.php +++ b/app/code/core/Mage/GoogleAnalytics/Model/System/Config/Source/Type.php @@ -32,14 +32,6 @@ public function toOptionArray() [ 'value' => Mage_GoogleAnalytics_Helper_Data::TYPE_ANALYTICS4, 'label' => Mage::helper('googleanalytics')->__('Google Analytics 4') - ], - [ - 'value' => Mage_GoogleAnalytics_Helper_Data::TYPE_ANALYTICS, - 'label' => Mage::helper('googleanalytics')->__('Google Analytics') - ], - [ - 'value' => Mage_GoogleAnalytics_Helper_Data::TYPE_UNIVERSAL, - 'label' => Mage::helper('googleanalytics')->__('Universal Analytics') ] ]; } diff --git a/app/code/core/Mage/GoogleAnalytics/sql/googleanalytics_setup/install-1.6.0.0.php b/app/code/core/Mage/GoogleAnalytics/sql/googleanalytics_setup/install-1.6.0.0.php deleted file mode 100644 index fed1755fc03..00000000000 --- a/app/code/core/Mage/GoogleAnalytics/sql/googleanalytics_setup/install-1.6.0.0.php +++ /dev/null @@ -1,25 +0,0 @@ -startSetup(); - -$installer->run("INSERT INTO `{$this->getTable('core/config_data')}` (scope, scope_id, path, value)" - . " SELECT scope, scope_id, 'google/analytics/type', 'analytics'" - . " FROM `{$this->getTable('core/config_data')}`" - . " WHERE path = 'google/analytics/active' AND value = '1'"); - -$installer->endSetup(); diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 90c964c0086..538f183df0d 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -2925,16 +2925,6 @@ parameters: count: 1 path: app/code/core/Mage/GiftMessage/controllers/IndexController.php - - - message: "#^Method Mage_GoogleAnalytics_Block_Ga\\:\\:_getOrdersTrackingCodeAnalytics\\(\\) should return string but empty return statement found\\.$#" - count: 1 - path: app/code/core/Mage/GoogleAnalytics/Block/Ga.php - - - - message: "#^Method Mage_GoogleAnalytics_Block_Ga\\:\\:_getOrdersTrackingCodeUniversal\\(\\) should return string but empty return statement found\\.$#" - count: 1 - path: app/code/core/Mage/GoogleAnalytics/Block/Ga.php - - message: "#^Return type \\(void\\) of method Mage_GoogleCheckout_Model_Payment\\:\\:authorize\\(\\) should be compatible with return type \\(\\$this\\(Mage_Payment_Model_Method_Abstract\\)\\) of method Mage_Payment_Model_Method_Abstract\\:\\:authorize\\(\\)$#" count: 1