Magento 2 module to log to Sentry

Overview

Magento 2 Sentry Logger

This Magento 2 module integrates the Sentry sdk into magento 2. Depending on the log level configured in the backend of magento 2, notifications and errors can be send to sentry.

Installation

  • composer require justbetter/magento2-sentry
  • bin/magento module:enable JustBetter_Sentry
  • bin/magento setup:upgrade
  • bin/magento setup:di:compile
  • bin/magento setup:static-content:deploy

Configuration

This module uses the Magento Deployment Configuration for most it's configuration. This means that you need to add this array to your app/etc/env.php:

'sentry' => [
    'dsn' => 'example.com',
    'logrocket_key' => 'example/example',
    'environment' => null,
    'log_level' => \Monolog\Logger::WARNING,
    'errorexception_reporting' => E_ALL,
    'ignore_exceptions' => [],
    'mage_mode_development' => false,
]

Next to that there are some configuration options under Stores > Configuration > JustBetter > Sentry.

Configuration values

  • dsn: Please enter here the DSN you got from Sentry for your project. You can find the DSN in the project settings under "Client Key (DSN)"
  • environment: Here you can specify the environment under which the deployed version is running. Common used environments are production, staging, and development. With this option you can differentiate between errors which happen on the staging and i.e. on the production system
  • log_level: With this configuration you can specify from which logging level on Sentry should get the messages
  • errorexception_reporting: If the Exception being thrown is an instance of ErrorException send the error to sentry if it matches the error reporting. This uses the same syntax as Error Reporting eg. E_ERROR | E_WARNING to only log Errors and Warnings.
  • ignore_exceptions: If the class being thrown matches any in this list do not send it to Sentry e.g. [\Magento\Framework\Exception\NoSuchEntityException::class]
  • mage_mode_development: If this option is set to true you will receive issues in Sentry even if you're Magento is running in develop mode.

Optional error page configuration

  • Optional you can configure custom error pages in pub/errors. You can use the sentry feedback form and insert here the sentry log ID. The Sentry Log Id is captured in de customer session and can be retrieved in processor.php.

Compatibility

The module is tested on Magento version 2.3.x & 2.4.x with sentry sdk version 2.x. Magento 2.1.x is not supported by us anymore, feel free to fork this project or make a pull request.

Ideas, bugs or suggestions?

Please create a issue or a pull request.

About us

We’re a innovative development agency from The Netherlands building awesome websites, webshops and web applications with Laravel and Magento. Check out our website justbetter.nl and our open source projects.

License

MIT


JustBetter logo

Comments
  • Initial v2 commit

    Initial v2 commit

    Summary

    This upgrades Sentry to use v2 of the Sentry SDK. I've been testing this on a almost-production website and am very happy with the results.

    I have releases configured in our build pipeline, and the var/sentry-releaseid.txt is the last step in that process.

    The biggest help of going to v2 is that Sentry has global exception handlers. That makes it much easier for errors to be caught.

    Result

    I built unit tests for GlobalExceptionCatcher. As I have time, I'd like to add more tests.

    opened by JosephMaxwell 23
  • Circular dependency in 2.1.0

    Circular dependency in 2.1.0

    Magento 2.3.3 magento2-sentry 2.1.0

    php bin/magento app:config:dump
    Circular dependency: JustBetter\Sentry\Plugin\MonologPlugin depends on Magento\Framework\App\Helper\Context and vice versa.#0 /data/clientname/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Just
    Better\\Sent...')
    #1 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(160): Magento\Framework\ObjectManager\ObjectManager->get('JustBetter\\Sent...')
    #2 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(246): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Psr\\Log\\LoggerI...', NULL, 'logger', 'Magento\\Framewo...')
    #3 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('Magento\\Framewo...', Array, Array)
    #4 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Framewo...', Array, Array)
    #5 /data/clientname/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
    #6 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(160): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
    #7 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(246): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'context', 'JustBetter\\Sent...')
    #8 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('JustBetter\\Sent...', Array, Array)
    #9 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('JustBetter\\Sent...', Array, Array)
    #10 /data/clientname/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('JustBetter\\Sent...')
    #11 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(160): Magento\Framework\ObjectManager\ObjectManager->get('JustBetter\\Sent...')
    #12 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(246): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'JustBetter\\Sent...', NULL, 'data', 'JustBetter\\Sent...')
    #13 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('JustBetter\\Sent...', Array, Array)
    #14 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('JustBetter\\Sent...', Array, Array)
    #15 /data/clientname/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('JustBetter\\Sent...')
    #16 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(160): Magento\Framework\ObjectManager\ObjectManager->get('JustBetter\\Sent...')
    #17 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(246): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Psr\\Log\\LoggerI...', NULL, 'logger', 'Magento\\Framewo...')
    #18 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('Magento\\Framewo...', Array, Array)
    #19 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Framewo...', Array, Array)
    #20 /data/clientname/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
    #21 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(160): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
    #22 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(246): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'logger', 'Magento\\Framewo...')
    #23 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('Magento\\Framewo...', Array, Array)
    #24 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Framewo...', Array, Array)
    #25 /data/clientname/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...', Array)
    #26 /data/clientname/magento2/vendor/magento/framework/App/Cache/Frontend/Factory.php(197): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Framewo...', Array)
    #27 /data/clientname/magento2/vendor/magento/framework/App/Cache/Frontend/Factory.php(161): Magento\Framework\App\Cache\Frontend\Factory->_applyDecorators(Object(Magento\Framework\Cache\Frontend\Decorator\TagScope))
    #28 /data/clientname/magento2/vendor/magento/framework/App/Cache/Frontend/Pool.php(67): Magento\Framework\App\Cache\Frontend\Factory->create(Array)
    #29 /data/clientname/magento2/vendor/magento/framework/App/Cache/Frontend/Pool.php(146): Magento\Framework\App\Cache\Frontend\Pool->_initialize()
    #30 /data/clientname/magento2/vendor/magento/framework/App/Cache.php(38): Magento\Framework\App\Cache\Frontend\Pool->get('default')
    #31 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(116): Magento\Framework\App\Cache->__construct(Object(Magento\Framework\App\Cache\Frontend\Pool))
    #32 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array)
    #33 /data/clientname/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
    #34 /data/clientname/magento2/vendor/magento/framework/App/Cache/Proxy.php(44): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
    #35 /data/clientname/magento2/vendor/magento/framework/App/Cache/Proxy.php(67): Magento\Framework\App\Cache\Proxy->_getCache()
    #36 /data/clientname/magento2/vendor/magento/framework/App/ProductMetadata.php(80): Magento\Framework\App\Cache\Proxy->load('mage-version')
    #37 /data/clientname/magento2/vendor/magento/framework/Console/Cli.php(92): Magento\Framework\App\ProductMetadata->getVersion()
    #38 /data/clientname/magento2/bin/magento(22): Magento\Framework\Console\Cli->__construct('Magento CLI')
    #39 {main}
    
    
    opened by peterjaap 14
  • Doesn't seem to work with earlier versions of magento2?

    Doesn't seem to work with earlier versions of magento2?

    I'm on magento 2.1.10 and can't build without commenting out the following line from the di.xml

    https://github.com/justbetter/magento2-sentry/blob/master/etc/di.xml#L7

    Is there anything that doesn't work from this being disabled i'm not noticing? It still sends test events and exceptions. I should also mention that it wouldnt even install via composer install because it wanted a newer version of monolog.

    enhancement 
    opened by zack6849 13
  • Update Javascript SDK to latest version

    Update Javascript SDK to latest version

    https://github.com/justbetter/magento2-sentry/blob/master/view/frontend/templates/script/sentry.phtml#L11

    We're now at 4.5.3 while 5.91 is the most recent version. See changelog here; https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md

    opened by peterjaap 12
  • Area code is already set

    Area code is already set

    Issues with Magento 2.2.5.

    installed via composer

    "justbetter/magento2-sentry": "^0.4.1"

    Random errors pop up, for example when generating a sitemap, or cache flushed.

    'Area code is already set'

    stack trace:

    #0 Magento\Framework\App\State->setAreaCode() called at [/var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:62] #1 JustBetter\Sentry\Helper\Data->__construct() called at [/var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:111] #2 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() called at [/var/www/html/vendor/magento/framework/ObjectManager/Factory/Compiled.php:108] #3 Magento\Framework\ObjectManager\Factory\Compiled->create() called at [/var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:70] #4 Magento\Framework\ObjectManager\ObjectManager->get() called at [/var/www/html/generated/code/JustBetter/Sentry/Helper/Data/Proxy.php:84] #5 JustBetter\Sentry\Helper\Data\Proxy->_getSubject() called at [/var/www/html/generated/code/JustBetter/Sentry/Helper/Data/Proxy.php:119] #6 JustBetter\Sentry\Helper\Data\Proxy->isActive() called at [/var/www/html/vendor/justbetter/magento2-sentry/Plugin/MonologPlugin.php:44] #7 JustBetter\Sentry\Plugin\MonologPlugin->addRecord() called at [/var/www/html/vendor/monolog/monolog/src/Monolog/Logger.php:532] #8 Monolog\Logger->debug() called at [/var/www/html/vendor/magento/framework/Cache/InvalidateLogger.php:42] #9 Magento\Framework\Cache\InvalidateLogger->execute() called at [/var/www/html/vendor/magento/framework/Cache/Frontend/Decorator/Logger.php:58] #10 Magento\Framework\Cache\Frontend\Decorator\Logger->log() called at [/var/www/html/vendor/magento/framework/Cache/Frontend/Decorator/Logger.php:48] #11 Magento\Framework\Cache\Frontend\Decorator\Logger->clean() called at [/var/www/html/vendor/magento/module-backend/Controller/Adminhtml/Cache/FlushSystem.php:27] #12 Magento\Backend\Controller\Adminhtml\Cache\FlushSystem->execute() called at [/var/www/html/vendor/magento/framework/App/Action/Action.php:107] #13 Magento\Framework\App\Action\Action->dispatch() called at [/var/www/html/vendor/magento/module-backend/App/AbstractAction.php:229] #14 Magento\Backend\App\AbstractAction->dispatch() called at [/var/www/html/vendor/magento/framework/Interception/Interceptor.php:58] #15 Magento\Backend\Controller\Adminhtml\Cache\FlushSystem\Interceptor->___callParent() called at [/var/www/html/vendor/magento/framework/Interception/Interceptor.php:138] #16 Magento\Backend\Controller\Adminhtml\Cache\FlushSystem\Interceptor->Magento\Framework\Interception{closure}() called at [/var/www/html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143] #17 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [/var/www/html/vendor/magento/framework/Interception/Interceptor.php:135] #18 Magento\Backend\Controller\Adminhtml\Cache\FlushSystem\Interceptor->Magento\Framework\Interception{closure}() called at [/var/www/html/vendor/magento/framework/Interception/Interceptor.php:153] #19 Magento\Backend\Controller\Adminhtml\Cache\FlushSystem\Interceptor->___callPlugins() called at [/var/www/html/generated/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem/Interceptor.php:26] #20 Magento\Backend\Controller\Adminhtml\Cache\FlushSystem\Interceptor->dispatch() called at [/var/www/html/vendor/magento/framework/App/FrontController.php:55] #21 Magento\Framework\App\FrontController->dispatch() called at [/var/www/html/vendor/magento/framework/Interception/Interceptor.php:58] #22 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [/var/www/html/vendor/magento/framework/Interception/Interceptor.php:138] #23 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}() called at [/var/www/html/vendor/magento/framework/Interception/Interceptor.php:153] #24 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [/var/www/html/generated/code/Magento/Framework/App/FrontController/Interceptor.php:26] #25 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [/var/www/html/vendor/magento/framework/App/Http.php:135] #26 Magento\Framework\App\Http->launch() called at [/var/www/html/vendor/magento/framework/App/Bootstrap.php:256] #27 Magento\Framework\App\Bootstrap->run() called at [/var/www/html/index.php:39]

    opened by andrewsurrey 11
  • Ignore static version in issue grouping?

    Ignore static version in issue grouping?

    Everytime we do a new deploy, we suddenly see a spike in frontend errors. When I dove deeper into this, I noticed this is because after a deploy the static version signing URL is changed, and Sentry thinks it is a new issue (because new URL).

    The same problem appears for different storeviews. These URLs are now seen as individual URLs while they should be grouped imho;

    ReferenceError if(version1606832327/frontend/Elgentos/client/en_US/knockoutjs/knockout)
    ReferenceError if(version1606832327/frontend/Elgentos/client/en_GB/knockoutjs/knockout)
    ReferenceError if(version1606832327/frontend/Elgentos/client/nl_NL/knockoutjs/knockout)
    ReferenceError if(version1606832327/frontend/Elgentos/client/de_DE/knockoutjs/knockout)
    
    ReferenceError if(version1606832123/frontend/Elgentos/client/en_US/knockoutjs/knockout)
    ReferenceError if(version1606832123/frontend/Elgentos/client/en_GB/knockoutjs/knockout)
    ReferenceError if(version1606832123/frontend/Elgentos/client/nl_NL/knockoutjs/knockout)
    ReferenceError if(version1606832123/frontend/Elgentos/client/de_DE/knockoutjs/knockout)
    

    Is there a way to make Sentry ignore these parts of the URL when fingerprinting? I've read their docs on fingerprint but can't find anything regarding this. Or maybe we could adjust the extension so it strips out these parts (probably by introducing a new config option that is disabled by default)?

    opened by peterjaap 10
  • Possible bug - php-http/async-client-implementation requirement could not be resolved

    Possible bug - php-http/async-client-implementation requirement could not be resolved

    When I try installing magento2-sentry 2.1.0 on magento 2.3.3, i get a requirements error for php-http/async-client-implementation. I am using the command composer require justbetter/magento2-sentry

    Possible Solution: I think that an implementation of php-http/async-client-implementation should be included in the magento2-sentry composer.json. Similar to how psr/http-message-implementation, nyholm/psr7 has been included. What do you think?

    Below is the complete error


    Your requirements could not be resolved to an installable set of packages.
    Problem 1
      - sentry/sentry 2.2.4 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.2.3 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.2.2 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.2.1 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.2.0 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.1.3 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.1.2 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.1.1 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.1.0 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.0.1 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - sentry/sentry 2.0.0 requires php-http/async-client-implementation ^1.0 -> no matching package found.
      - justbetter/magento2-sentry 2.1.0 requires sentry/sdk ^2.0 -> satisfiable by sentry/sdk[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4].
      - sentry/sdk 2.0.4 requires sentry/sentry ^2.1.3 -> satisfiable by sentry/sentry[2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4].
      - sentry/sdk 2.0.2 requires sentry/sentry ^2.0.1 -> satisfiable by sentry/sentry[2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4].
      - sentry/sdk 2.0.3 requires sentry/sentry ^2.0.1 -> satisfiable by sentry/sentry[2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4].
      - sentry/sdk 2.0.0 requires sentry/sentry ^2.0 -> satisfiable by sentry/sentry[2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4].
      - sentry/sdk 2.0.1 requires sentry/sentry ^2.0 -> satisfiable by sentry/sentry[2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4].
      - Installation request for justbetter/magento2-sentry ^2.1 -> satisfiable by justbetter/magento2-sentry[2.1.0].
    
    Potential causes:
     - A typo in the package name
     - The package is not available in a stable-enough version according to your minimum-stability setting
     see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
     - It's a private package and you forgot to add a custom repository to find it
    
    opened by jupiterhs 7
  • Ability to set Magento modes that send errors to Sentry

    Ability to set Magento modes that send errors to Sentry

    Currently errors are only sent to Sentry if Magento is in production mode. That's great for when the site is running, but not helpful during development. There should be an admin setting to allow for errors to be sent for any/all Magento modes.

    enhancement 
    opened by ctadlock 6
  • Add LogRocket integration

    Add LogRocket integration

    It would be great to have LogRocket integration in the extension, see https://blog.logrocket.com/extending-sentry-with-logrocket-52e2f5b67d5a/

    Two bits of code should be added;

    Right after :

    <script src="https://cdn.lr-ingest.io/LogRocket.min.js" crossorigin="anonymous"></script>
    <script>window.LogRocket && window.LogRocket.init('INITKEY_HERE');</script>
    

    Before :

    LogRocket.getSessionURL(sessionURL => {
      Sentry.configureScope(scope => {
        scope.setExtra("sessionURL", sessionURL);
      });
    });
    

    We'll need to add two configuration opties; Enable/disable LogRocket integration, and an input field for the LogRocket init key (which you'll get when you create a project in LogRocket).

    opened by peterjaap 5
  • Upgrade to Sentry API v2 + exception handling?

    Upgrade to Sentry API v2 + exception handling?

    Feature: What is your use case for such a feature? I am comparing Rollbar vs Sentry and am seeing that Rollbar (while very basic) has good root-level exception handling. This is quite important, and seems to be missing from Sentry (just log publishing).

    However, the v2 of the Sentry API has much better exception handling.

    Are you open to pull requests? Or, are you already working on such an implementation?

    I am using the Magento 2.3.2 with the latest version of this module.

    opened by JosephMaxwell 5
  • Setup by CLI

    Setup by CLI

    Hi

    After updating to the latest version of this module, it seems it is no longer possible to setup using CLI.

    php ~/public_html/bin/magento module:enable JustBetter_Sentry
    php ~/public_html/bin/magento config:set sentry/general/enabled 1
    php ~/public_html/bin/magento config:set sentry/general/dsn https://[email protected]/1234567
    php ~/public_html/bin/magento config:set sentry/general/environment under-development
    

    This was working in previous a previous version but now I get an error saying that the path doesnt exist.

    Have the configuration path been changed? I understand that the settings have been moved, but even with --lock-env it still doesnt work

    I am sure it is just me who missed something obvious, but not sure what it is :)

    opened by mortenbirkelund 4
  • Performance tracking

    Performance tracking

    This adds initial performance tracking by sending (server side) transactions. Could be used to add long-running queries or other events perhaps. Needs to set a sample rate + enable it in the backend. See https://github.com/justbetter/magento2-sentry/issues/60

    (Not very much experience with this, but it does seem to record transactions).

    opened by barryvdh 4
  • Solve error with no suchentity exception which can occur

    Solve error with no suchentity exception which can occur

    Fixes issue when customer is logged in on website en user is deleted. The log wont work anymore and Magento throws error: Could not write error message to log. Please use developer mode to see the message

    This catches all exception so normal logging can continue

    Summary

    Result

    opened by rofokken 1
  • Exceptions in Consumers are not sent to Sentry

    Exceptions in Consumers are not sent to Sentry

    Sentry module bug

    In case exceptions are thrown from the Magento Consumer - they are not logged to Sentry. It might be a big problem for projects that use Queues.

    Bug: What is the current behavior? Exceptions from Consumers just logged to log files, but not sent to Sentry.

    Bug: What is the expected behavior? Exceptions from Consumers should be sent to Sentry.

    Bug: What is the proposed solution?

    Why exceptions from Consumer are not sent so Sentry? Because Sentry initialization happens using around plugin for Application class - \JustBetter\Sentry\Plugin\GlobalExceptionCatcher::aroundLaunch, but this application class doesn't exist when the application is launched from the CLI.

    So we need to initialize Sentry plugin also for the CLI. How to do it?

    • The first thing that I would recommend to do is to replace static method calling (like \Sentry\captureException) in \JustBetter\Sentry\Model\SentryLog::send. As they are static - it's impossible to create a Magento Plugin for those methods calling. Static methods should be replaced by the wrapper, for example by this - \JustBetter\Sentry\Model\SentryInteraction. So let's assume we call \JustBetter\Sentry\Model\SentryInteraction::captureException and \JustBetter\Sentry\Model\SentryInteraction::captureMessage instead of \Sentry\captureException and \Sentry\captureMessage.
    • When SentryInteraction::captureException or SentryInteraction::captureMessage is called - we need to check is Sentry is initialized. Just introduce $isInitialized variable, that will be set to true when SentryInteraction::initialize is called.
    • In case Sentry is not initialized - just initialize it in the same way as it's done in src/justbetter/magento2-sentry/Plugin/GlobalExceptionCatcher.php:75
    • then get rid of initialization in the \JustBetter\Sentry\Plugin\GlobalExceptionCatcher::aroundLaunch, so this method will become more transparent and clean.

    Note: Maybe we don't need to have all exceptions from CLI logged to Sentry. But we 100% need to have all exceptions from Magento Consumer to be logged.

    What is the version of Magento and of Sentry extension you are using? Always use the latest version of the extension one before opening a bug issue.

    • Magento 2.4.4
    • justbetter/magento2-sentry:3.2.0
    opened by VladyslavSikailo 0
  • Spam in debug.log file

    Spam in debug.log file

    I am experiencing a log spam in debug.log - magento 2.4.4 and php8.1:

    [2022-06-13T16:31:04.813915+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:04.839274+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:04.864525+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Stream" for "Phalcon\Http\Message\StreamFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Stream\" for \"Phalcon\\Http\\Message\\StreamFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:04.884219+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Stream" for "Phalcon\Http\Message\StreamFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Stream\" for \"Phalcon\\Http\\Message\\StreamFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:04.892928+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:04.918881+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:04.952301+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Uri" for "Phalcon\Http\Message\UriFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Uri\" for \"Phalcon\\Http\\Message\\UriFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:04.971579+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Uri" for "Phalcon\Http\Message\UriFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Uri\" for \"Phalcon\\Http\\Message\\UriFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:05.018918+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:05.034931+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:05.075022+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    [2022-06-13T16:31:05.089302+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
    

    when i remove the sentry config from the .env then the logs disappear...

    opened by simonmaass 5
  • Add support to filter out events

    Add support to filter out events

    Sometimes we encounter a bug but it takes a while for us to fix it (due to whatever reason).

    We'd like to temporarily filter this event from turning up in Sentry. We could do this by ignoring the event in Sentry, but incoming events will still count towards our quota. Some of these events actually eat up almost all of our quota for a given month, so we want to filter them on the Magento end instead of in Sentry.

    Sentry offers a basic way to filter incoming events but that isn't very granular, thereby sometimes accidentally filtering other events too.

    We could pretty easily filter this inside PHP, see Filtering for PHP.

    The way we do this now is creating a Composer patch that adds a bit of logic to vendor/justbetter/magento2-sentry/Plugin/GlobalExceptionCatcher.php. Like this on line 55 (right before $this->sentryInteraction->initialize($config););

            $config['before_send'] = function (\Sentry\Event $event, ?\Sentry\EventHint $hint): ?\Sentry\Event {
                // Ignore the event when the message includes a certain string
                if ($hint !== null && stripos($hint->exception->getMessage(), 'Illegal string offset \'attribute\'') !== false) {
                    return null;
                }
                // Or ignore the event when it is in a specific file on a specific line
                if (
                    $hint !== null
                    && stripos($hint->exception->getFile(), 'vendor/magento/module-eav/Model/Entity/Collection/AbstractCollection.php') !== false
                    && $hint->exception->getLine() === 373
                ) {
                    return null;
                }
                // Or ignore the event if the original exception is an instance of MyException
                if ($hint !== null && $hint->exception instanceof MyException) {
                    return null;
                }
    
                return $event;
            };
    

    I'd like to introduce a user-friendlier way to achieve this. My suggestion would be to add an event like sentry_config that we could hook into to add something to the $config array (which then should be encapsulated in an object).

    opened by peterjaap 4
Owner
JustBetter
We're an innovative development agency from The Netherlands building awesome websites, webshops and web applications with Laravel and Magento.
JustBetter
A PocketMine-MP plugin for logging Exceptions to a Sentry server

Sentry A PocketMine-MP plugin for logging Exceptions to a Sentry server. Asynchronous logging If you want to log exceptions in a thread-safe way, you

null 4 Apr 9, 2022
Magento 2 Module Experius Page Not Found 404. This module saves all 404 url to a database table

Magento 2 Module Experius Page Not Found 404 This module saves all 404 urls to a database table. Adds an admin grid with 404s It includes a count so y

Experius 28 Dec 9, 2022
Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Strategery 123 Nov 20, 2021
Magento extension which makes it impossible for a customer to log in until the account has been activated by the administrator.

This Magento 1 extension is orphaned, unsupported and no longer maintained. If you use it, you are effectively adopting the code for your own project.

Vinai Kopp 120 Oct 10, 2022
Magento - Attach log correlation ID (aka Trace ID) to requests, monlog entries, and New relic transactions

magento2-log-correlation-id Magento 2 log correlation id for PHP requests/processes and magento logs. This is useful when debugging issues on a produc

Ampersand 13 Dec 15, 2022
A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2

Simple Import / Export tool A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2. Table data

EcomDev B.V. 51 Dec 5, 2022
The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time. All commands are extendable by a module API.

netz98 magerun CLI tools for Magento 2 The n98 magerun cli tools provides some handy tools to work with Magento from command line. Build Status Latest

netz98 758 Dec 28, 2022
Content Fuzzyfyr Module for Magento® 2

Content Fuzzyfyr Module for Magento® 2 The Content Fuzzyfyr module for Magento® 2 fills up empty content fields - and if needed - switches real conten

Hive Commerce 11 Oct 17, 2022
Magento 2 module to quickly acces products, orders and customer from admin menu

Magento 2 module to quickly access product, order or customer views Introduction The Magento 2 backend can be sluggish. Ever wanted to access a produc

null 1 Dec 3, 2021
Extract and evolution of the magento2-currency-precision module from the magento2-jp project from @Magento

Currency Precision Module for Magento 2 This module aims to help merchants to manage easily their currency precision in Magento 2. DISCLAIMER Initiall

OpenGento 3 Dec 17, 2021
A Magento 1.x module which facilitates automatic purging of static assets from HTTP caches such as browser cache, CDN, Varnish, etc using best practices outlined within the HTML5 boilerplate community.

Magento Cachebuster Cachebuster is a Magento module which facilitates automatic purging of static assets from HTTP caches such as browser cache, CDN,

Gordon Knoppe 129 Apr 1, 2022
New Ultimate Module Creator for Magento 1.7 +

Ultimate Module Creator 1.9.6.0 Notice Because of lack of time, motivation and because Magento2 is already a mature platform, I'm deciding to pull the

Marius Strajeru 247 Nov 22, 2022
Magento 2 Message Queue Open Source Module

Magento 2 Message Queue Module Lightweight implementation of message queue for Magento 2 Community Edition. System requirements This extension support

Renato 36 Sep 30, 2021
Magento 2 module for ngrok.io service support

Magento 2 ngrok Magento 2 module for ngrok service support. Automatically updates Magento base url based on domain used in the request. Modifies full-

Dmitry Shkoliar 46 Aug 26, 2022
Module for integrating Fastly CDN with Magento 2 installations

FASTLY CDN FOR MAGENTO2 DOCUMENTATION Thank you for using the "Fastly CDN module for Magento2" (Fastly_Cdn). This package contains everything you need

Fastly 113 Dec 26, 2022
Magento 2 Grid Colors module for colorizing admin grids. Supports saving of states with the help of grid's bookmarks.

Magento 2 Grid Colors Overview The module adds extra coloring features to admin grids at the Sales section. With help of this module, it is possible t

Dmitry Shkoliar 58 Dec 8, 2022