Added Sentry error logging on the server side.

This commit is contained in:
flash 2023-09-10 20:46:58 +00:00
parent 5554c5c28d
commit 17e0d1f591
4 changed files with 1467 additions and 8 deletions

View file

@ -7,7 +7,8 @@
"erusev/parsedown": "~1.6",
"chillerlan/php-qrcode": "^4.3",
"symfony/mailer": "^6.0",
"matomo/device-detector": "^6.1"
"matomo/device-detector": "^6.1",
"sentry/sdk": "^3.5"
},
"autoload": {
"classmap": [
@ -27,7 +28,8 @@
"preferred-install": "dist",
"allow-plugins": {
"composer/installers": true,
"wikimedia/composer-merge-plugin": false
"wikimedia/composer-merge-plugin": false,
"php-http/discovery": true
}
},
"require-dev": {

1450
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -22,14 +22,21 @@ Environment::setDebug(MSZ_DEBUG);
mb_internal_encoding('utf-8');
date_default_timezone_set('utc');
$dbConfig = parse_ini_file(MSZ_CONFIG . '/config.ini', true, INI_SCANNER_TYPED);
$cfg = parse_ini_file(MSZ_CONFIG . '/config.ini', true, INI_SCANNER_TYPED);
if(empty($dbConfig)) {
echo 'Database config is missing.';
exit;
if(!empty($cfg['sentry-dsn'])) {
\Sentry\init([
'dsn' => $cfg['sentry-dsn'],
'traces_sample_rate' => $cfg['sentry-traces-rate'] ?? 0.2,
'profiles_sample_rate' => $cfg['sentry-profiles-rate'] ?? 0.2,
]);
set_exception_handler(function(\Throwable $ex) {
\Sentry\captureException($ex);
});
}
$db = DbTools::create($dbConfig['dsn']);
$db = DbTools::create($cfg['dsn'] ?? 'null:');
$db->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';');
$cfg = new DbConfig($db);

View file

@ -10,6 +10,8 @@ use Sasae\SasaeEnvironment;
require_once __DIR__ . '/../misuzu.php';
set_exception_handler(function(\Throwable $ex) {
\Sentry\captureException($ex);
http_response_code(500);
ob_clean();