justbetter / magento2-sentry

Magento 2 module to log to Sentry
MIT License
165 stars 70 forks source link

What are the equivalent environment variable names for the settings placed in env.php #83

Closed roger10010 closed 7 months ago

roger10010 commented 2 years ago

Hi,

Does anyone know what the names of the environment variables are that will be used to populate the fields normally defined in env.php for this intergration? Sadly I do not know much about Magento and while I have been able to decode the docs well enough to set certain system wide default web values I do not understand things well enough to work out the names that will map to the Sentry settings.

As an example to provide some context. In the database there is a value stored for the "Web Secure Base URL" which provides the URL that a deployment will use when refering to the site. This can be set by using

CONFIG__DEFAULT__WEB__SECURE__BASE_URL

It is a great way to setup CI systems and docker based deployments, but as I have noted the docs are somewhat light on information, I guess developers just go and read the source code, but my background is OPS, not development.

Thanks

indykoning commented 2 years ago

Hi!

This is related to #80 and this will be able to be set by en environment variable like that by the time it is closed

Sadly the Magento Deployment Configuration we use cannot be set using variables by normal means. We have been able to do that by using means such as https://github.com/justbetter/magento2-dotenv (To prevent magento from regenerating and overwriting the env.php) and loading env variables in the config https://github.com/justbetter/magento2-dotenv/blob/master/Example/env.php

However the proper solution will be to add the module configuration to the "core config" part of Magento so it can be set in the same way you describe

rit001 commented 2 years ago

In fact, it is already doable as it is a feature of the Magento config system for I guess non cloud configurations. My question was about what env names to use - while I'm still working on my final configuration I can say that the required env names are

  CONFIG__DEFAULT__SENTRY_DSN
  CONFIG__DEFAULT__SENTRY__ENVIRONMENT
  CONFIG__DEFAULT__SENTRY__LOG_LEVEL
  CONFIG__DEFAULT__SENTRY__MAGE_MODE_DEVELOPMENT
  CONFIG__DEFAULT__SENTRY__ERROREXCEPTION_REPORTING

You still need the section in the env.php file as Magento needs to know that it has to define the placeholders, but any env defined with the above names will overwrite the corresponding value read from the env.php.

As I noted the Magento docs are not that clear - so the section you link to is correct that only env.php and config.php are merged at start-up and no other config file can be added. The use of env variables to override the values read in gets covered (poorly) within the Pipeline Deployment docs

      https://devdocs.magento.com/guides/v2.4/config-guide/deployment/pipeline/example/environment-variables.html

The magic of the config system starts to make sense once you find the following command that dumps all the values you can override/set

     bin/magento config:show

and bin/magento config:show --scope="default"

indykoning commented 7 months ago

See https://github.com/justbetter/magento2-sentry/issues/80 and https://github.com/justbetter/magento2-sentry#configuration-for-adobe-cloud it can now be set with system config 🚀