born05 / craft-sentry

Pushes Craft CMS errors to Sentry.
MIT License
10 stars 11 forks source link

sentry-sdk.php config is ignored in latest version(s)? #7

Closed boboldehampsink closed 4 years ago

boboldehampsink commented 4 years ago

Seeing these errors in dev environment:

2020-01-16 11:38:35 [-][-][-][error][sentry-sdk] Failed to report exception due to missing client key (DSN)

While my config disabled sentry for dev environment:

<?php

return [
    '*' => [
        'enabled' => false,
        'excludedCodes' => ['400', '404', '429'],
    ],
    'production' => [
        'enabled' => true,
        'clientDsn' => getenv('SENTRY_DSN'),
    ],
];
roelvanhintum commented 4 years ago

@boboldehampsink are you using the 1.0.5 version of the plugin? I just tested this without problems on: PHP 7.2.24 Craft Pro 3.3.20.1 Sentry SDK plugin 1.0.5

boboldehampsink commented 4 years ago

Yes this occurs on 1.0.5 and on 1.0.4 - it shows up in the logs

roelvanhintum commented 4 years ago

Can you provide a dump (without dsn or other personal info) of the born05\sentry\Plugin line 41 $settings variable? Just to check the obvious, but is the CRAFT_ENVIRONMENT variable not equal to production?

boboldehampsink commented 4 years ago

Nope

Screen Shot 2020-01-16 at 13 56 22

(Screenshot from phpinfo)

roelvanhintum commented 4 years ago

I double checked, but i really cannot reproduce this. Are you sure sentry-sdk.php is inside craft's config folder? Dumping the settings variable from the plugin would verify if it's loaded.

boboldehampsink commented 4 years ago

Here's some more info I found. It only happens when I install a new site with an existing project config. These are the logs:

...
web_1         |     > installing sentry-sdk ... born05\sentry\models\Settings#1
web_1         | (
web_1         |     [enabled] => true
web_1         |     [anonymous] => false
web_1         |     [clientDsn] => null
web_1         |     [excludedCodes] => [
web_1         |         0 => '404'
web_1         |     ]
web_1         |     [release] => null
web_1         |     [yii\base\Model:_errors] => null
web_1         |     [yii\base\Model:_validators] => null
web_1         |     [yii\base\Model:_scenario] => 'default'
web_1         |     [yii\base\Component:_events] => []
web_1         |     [yii\base\Component:_eventWildcards] => []
web_1         |     [yii\base\Component:_behaviors] => []
web_1         | )done
web_1         |     > applying existing project config ... done
web_1         |     > saving the first user ... done
web_1         | *** installed Craft successfully (time: 6.758s)
web_1         |
web_1         | 2020-01-17 06:49:21 [-][-][-][error][sentry-sdk] Failed to report exception due to missing client key (DSN)
web_1         | 2020-01-17 06:49:22 [-][-][-][error][sentry-sdk] Failed to report exception due to missing client key (DSN)
web_1         | born05\sentry\models\Settings#1
web_1         | (
web_1         |     [enabled] => false
web_1         |     [anonymous] => false
web_1         |     [clientDsn] => null
web_1         |     [excludedCodes] => [
web_1         |         0 => '400'
web_1         |         1 => '404'
web_1         |         2 => '429'
web_1         |     ]
web_1         |     [release] => null
web_1         |     [yii\base\Model:_errors] => null
web_1         |     [yii\base\Model:_validators] => null
web_1         |     [yii\base\Model:_scenario] => 'default'
web_1         |     [yii\base\Component:_events] => []
web_1         |     [yii\base\Component:_eventWildcards] => []
web_1         |     [yii\base\Component:_behaviors] => []
web_1         | )

You can see that after installing Craft, it picks up the correct config. I think it needs to check whether the plugin or Craft itself is actually installed yet?

roelvanhintum commented 4 years ago

Thanks! That helps alot! Fixed it in 1.0.6. Can you verify this?

boboldehampsink commented 4 years ago

That did the trick, thanks!