Data.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\GoogleAnalytics\Helper;
  7. use Magento\Store\Model\Store;
  8. use Magento\Store\Model\ScopeInterface;
  9. /**
  10. * GoogleAnalytics data helper
  11. *
  12. * @api
  13. * @since 100.0.2
  14. */
  15. class Data extends \Magento\Framework\App\Helper\AbstractHelper
  16. {
  17. /**
  18. * Config paths for using throughout the code
  19. */
  20. const XML_PATH_ACTIVE = 'google/analytics/active';
  21. const XML_PATH_ACCOUNT = 'google/analytics/account';
  22. const XML_PATH_ANONYMIZE = 'google/analytics/anonymize';
  23. /**
  24. * Whether GA is ready to use
  25. *
  26. * @param null|string|bool|int|Store $store
  27. * @return bool
  28. */
  29. public function isGoogleAnalyticsAvailable($store = null)
  30. {
  31. $accountId = $this->scopeConfig->getValue(self::XML_PATH_ACCOUNT, ScopeInterface::SCOPE_STORE, $store);
  32. return $accountId && $this->scopeConfig->isSetFlag(self::XML_PATH_ACTIVE, ScopeInterface::SCOPE_STORE, $store);
  33. }
  34. /**
  35. * Whether anonymized IPs are active
  36. *
  37. * @param null|string|bool|int|Store $store
  38. * @return bool
  39. * @since 100.2.0
  40. */
  41. public function isAnonymizedIpActive($store = null)
  42. {
  43. return $this->scopeConfig->getValue(self::XML_PATH_ANONYMIZE, ScopeInterface::SCOPE_STORE, $store);
  44. }
  45. }