diff --git a/app/code/community/MM/Ignition/Helper/Data.php b/app/code/community/MM/Ignition/Helper/Data.php index 7bb4472..e28f511 100644 --- a/app/code/community/MM/Ignition/Helper/Data.php +++ b/app/code/community/MM/Ignition/Helper/Data.php @@ -7,6 +7,9 @@ class MM_Ignition_Helper_Data extends Mage_Core_Helper_Abstract const XML_PATH_OVERRIDE_CONFIG = 'dev/mm_ignition/override_config'; const XML_PATH_OPENAI_ENABLED = 'dev/mm_ignition/enable_openai'; const XML_PATH_OPENAI_KEY = 'dev/mm_ignition/openai_api_key'; + const XML_PATH_FLARE_ENABLED = 'dev/mm_ignition/enable_flare'; + const XML_PATH_FLARE_API_KEY = 'dev/mm_ignition/flare_api_key'; + const XML_PATH_FLARE_ANONYMIZE_IP = 'dev/mm_ignition/flare_anonymize_ip'; /** * Allowed keys for settings @@ -154,4 +157,31 @@ public function getOpenAiKey() return Mage::getStoreConfig(self::XML_PATH_OPENAI_KEY); } + /** + * Check if Flare is enabled + * @return bool + */ + public function isFlareEnabled() + { + return Mage::getStoreConfigFlag(self::XML_PATH_FLARE_ENABLED); + } + + /** + * Check if Flare should anonymize IP + * @return bool + */ + public function shouldAnonymizeIp() + { + return Mage::getStoreConfigFlag(self::XML_PATH_FLARE_ANONYMIZE_IP); + } + + /** + * Get Flare API key + * @return string + */ + public function getFlareApiKey() + { + return Mage::getStoreConfig(self::XML_PATH_FLARE_API_KEY); + } + } \ No newline at end of file diff --git a/app/code/community/MM/Ignition/Model/Observer.php b/app/code/community/MM/Ignition/Model/Observer.php index 9d838c2..6668ef4 100644 --- a/app/code/community/MM/Ignition/Model/Observer.php +++ b/app/code/community/MM/Ignition/Model/Observer.php @@ -3,6 +3,7 @@ use Spatie\Ignition\Config\IgnitionConfig; use Spatie\Ignition\Ignition; use Spatie\Ignition\Solutions\OpenAi\OpenAiSolutionProvider; +use Spatie\FlareClient\Flare; class MM_Ignition_Model_Observer extends Mage_Core_Model_Observer { @@ -14,7 +15,7 @@ class MM_Ignition_Model_Observer extends Mage_Core_Model_Observer */ public function handleIgnitionRegister(Varien_Event_Observer $observer) { - if (!$this->getHelper()->shouldPrintIgnition()) { + if (!$this->getHelper()->shouldPrintIgnition() && !$this->getHelper()->isFlareEnabled()) { return; } @@ -30,14 +31,16 @@ public function handleIgnitionRegister(Varien_Event_Observer $observer) */ public function handleIgnitionException(Varien_Event_Observer $observer) { - if (!$this->getHelper()->shouldPrintIgnition()) { + if (!$this->getHelper()->shouldPrintIgnition() && !$this->getHelper()->isFlareEnabled()) { return; } $e = $observer->getEvent()->getException(); $this->getIgnitionInstance()->handleException($e); - die(); + if ($this->getHelper()->shouldPrintIgnition()) { + die(); + } } /** @@ -48,6 +51,7 @@ public function handleIgnitionException(Varien_Event_Observer $observer) protected function getIgnitionInstance() { $_ignition = Ignition::make() + ->runningInProductionEnvironment(!Mage::getIsDeveloperMode()) ->setConfig($this->getIgnitionConfig()) ->applicationPath(Mage::getBaseDir()); @@ -61,6 +65,15 @@ protected function getIgnitionInstance() ]); } + if ($this->getHelper()->isFlareEnabled() && !empty($this->getHelper()->getFlareApiKey())) { + $_ignition->sendToFlare($this->getHelper()->getFlareApiKey()); + if ($this->getHelper()->shouldAnonymizeIp()) { + $_ignition->configureFlare(function(Flare $flare) { + $flare->anonymizeIp(); + }); + } + } + return $_ignition; } diff --git a/app/code/community/MM/Ignition/etc/config.xml b/app/code/community/MM/Ignition/etc/config.xml index 948a0d5..ed24f20 100644 --- a/app/code/community/MM/Ignition/etc/config.xml +++ b/app/code/community/MM/Ignition/etc/config.xml @@ -2,7 +2,7 @@ - 1.3.0 + 1.4.0 diff --git a/app/code/community/MM/Ignition/etc/system.xml b/app/code/community/MM/Ignition/etc/system.xml index 67db9cb..5babfd5 100644 --- a/app/code/community/MM/Ignition/etc/system.xml +++ b/app/code/community/MM/Ignition/etc/system.xml @@ -70,6 +70,41 @@ 1 + + + Enable Flare Error Tracking + select + adminhtml/system_config_source_yesno + 50 + 1 + 1 + 1 + + + + API key for Flare provided when you created a new project + password + 70 + 1 + 1 + 1 + + 1 + + + + + Enable to anonymize IP addresses sent to Flare + select + adminhtml/system_config_source_yesno + 80 + 1 + 1 + 1 + + 1 + +