Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use config only if enabled otherwise just deployment-config #158

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sanderjongsma
Copy link

@sanderjongsma sanderjongsma commented Jan 22, 2025

Summary
I noticed some weird behavior with the config. When you try to override in the backend by enabling sentry/environment/enabled and then disable it, sentry is just always disabled, like described here: #128 so I fixed it by just checking if it is enabled or not and if it is not it just uses the deployment-config. Also for the additional settings, because the log_level was overridden by the setting, because it is a source model it always has a value when saved. Now the overridden values are only used when sentry/environment/enabled flag is true.

I also saw this PR #144 which is great, but also adds another setting and in my opinion the enabled setting can just be used instead of an extra override setting. So basically this PR also does this, and indeed the try catches are not needed.

I deliberately used a simple if/else to make it more readable, it could be fancier, but I think a readable solution is better here.

Result

Deployment-config is always leading for enabling the service. But when backend config is used settings can be overridden only if sentry/environment/enabled is true, in that case backend config is used over deployment-config. When a setting like DSN is not filled in de backend config, it just falls back to the deployment config

Checklist

  • I've ran composer run codestyle
  • I've ran composer run phpstan

@sanderjongsma sanderjongsma force-pushed the only-use-config-if-enabled-in-config branch from f07ab72 to f636f3f Compare January 22, 2025 11:31
Copy link
Member

@indykoning indykoning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking simpler than the referenced PR 🙂
One thing i'd like to ensure and then i'll be more than happy to merge!

try {
$this->config[$storeId]['enabled'] = $this->scopeConfig->getValue('sentry/environment/enabled', ScopeInterface::SCOPE_STORE)
?? $this->deploymentConfig->get('sentry') !== null;
} catch (TableNotFoundException|FileSystemException|RuntimeException $e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does isSetFlag already handle these exceptions?
Could you test that out using the instructions here: #125 (comment)

So, setting a different nonexistent database connection and running magerun2 db:info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants