networkteam / sentry_client

TYPO3 Extension for exception logging with sentry, see http://www.getsentry.com
33 stars 35 forks source link

[FEATURE] Allow disabling sentry integration via config #87

Closed baschny closed 1 year ago

baschny commented 1 year ago

Allow switching it off via extension configuration (disableSentry) or environment variable (SENTRY_DISABLE). Default is backwards compatible (enabled).

Either set the environment variable:

SENTRY_DISABLE=1

Or set it in TYPO3 based on some condition, for example in your AdditionalConfiguration.php aka config/system/additional.php:

if (\TYPO3\CMS\Core\Core\Environment::getContext()->isDevelopment()) {
    $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sentry_client']['disableSentry'] = true;
}

Resolves #85

christophlehmann commented 1 year ago

At first, thanks for the PR, but do we really need it?

Currently an empty dsn with $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sentry_client']['dsn'] or an empty env variable SENTRY_DSN="" should deactivate the Sentry client.

Doesn't it work ? See https://github.com/networkteam/sentry_client/blob/master/Classes/Client.php#L40

baschny commented 1 year ago

It deactivates the client, but it does not deactivate the integration, meaning that ProductionExceptionHandler and also the Logwriter configuration is still going to Sentry (instead of a File).

baschny commented 1 year ago

I would be ok that if the "dsn" is not set, the integration (i.e. the hooks registration in ext_localconf.php) does not kick in by default, my change was meant to be as backwards compatible as possible.

christophlehmann commented 1 year ago

Context based configuration is now possible with v5.0.0. Please create a new issue given something is still wrong