Remove Sentry, simplify error handling.

Developer's note: the Sentry team has been very supportive of open-source and is good people! We simply don't use the library enough on our end to justify its dependencies in our codebase.
This commit is contained in:
Buster "Silver Eagle" Neece 2020-07-04 11:08:53 -05:00
parent 2a49145764
commit 62763250ca
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
11 changed files with 6 additions and 997 deletions

View File

@ -110,7 +110,6 @@ We would like to thank the following organizations for their support of AzuraCas
- [DigitalOcean](https://m.do.co/c/21612b90440f) for generously providing the server resources we use for our demonstration instance, our staging and testing environments, and more
- [JetBrains](https://www.jetbrains.com/) for making our development faster, easier and more productive with tools like PhpStorm
- [CrowdIn](https://crowdin.com/) for giving us a simple and powerful tool to help translate our application for users around the world
- [Sentry](https://sentry.io/) for providing a great way to aggregate errors being reported from AzuraCast installations around the web.
- [Netlify](https://www.netlify.com/) for supporting open-source software like ours and for serving as the host of our primary [azuracast.com](https://www.azuracast.com/) web site.
- The creators and maintainers of the many free and open-source tools that AzuraCast is built on, who have done so much to help move FOSS forward

View File

@ -57,12 +57,8 @@
"php-di/php-di": "^6.0",
"php-di/slim-bridge": "^3.0",
"php-http/guzzle6-adapter": "^2.0",
"php-http/httplug": "^2.0",
"php-http/message": "^1.4",
"php-http/socket-client": "^2",
"ramsey/uuid": "^4.0",
"rlanvin/php-ip": "^2.0",
"sentry/sentry": "^2",
"slim/http": "^1.0",
"slim/slim": "^4.2",
"spomky-labs/otphp": "^10.0",

716
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "925aceab5c1165782215531ba732c16f",
"content-hash": "f561a9d43f3f2f6d599c4e7b87c5dd45",
"packages": [
{
"name": "aws/aws-sdk-php",
@ -842,58 +842,6 @@
],
"time": "2020-05-26T01:27:20+00:00"
},
{
"name": "clue/stream-filter",
"version": "v1.4.1",
"source": {
"type": "git",
"url": "https://github.com/clue/php-stream-filter.git",
"reference": "5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/clue/php-stream-filter/zipball/5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71",
"reference": "5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71",
"shasum": ""
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^4.8"
},
"type": "library",
"autoload": {
"psr-4": {
"Clue\\StreamFilter\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christian Lück",
"email": "christian@lueck.tv"
}
],
"description": "A simple and modern approach to stream filtering in PHP",
"homepage": "https://github.com/clue/php-stream-filter",
"keywords": [
"bucket brigade",
"callback",
"filter",
"php_user_filter",
"stream",
"stream_filter_append",
"stream_filter_register"
],
"time": "2019-04-09T12:31:48+00:00"
},
{
"name": "composer/ca-bundle",
"version": "1.2.7",
@ -2810,57 +2758,6 @@
],
"time": "2020-07-01T01:52:46+00:00"
},
{
"name": "jean85/pretty-package-versions",
"version": "1.2",
"source": {
"type": "git",
"url": "https://github.com/Jean85/pretty-package-versions.git",
"reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48",
"reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48",
"shasum": ""
},
"require": {
"ocramius/package-versions": "^1.2.0",
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Jean85\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alessandro Lai",
"email": "alessandro.lai85@gmail.com"
}
],
"description": "A wrapper for ocramius/package-versions to get pretty versions strings",
"keywords": [
"composer",
"package",
"release",
"versions"
],
"time": "2018-06-13T13:22:40+00:00"
},
{
"name": "jhofm/flysystem-iterator",
"version": "v2.2.0",
@ -4199,79 +4096,6 @@
],
"time": "2018-02-13T20:26:39+00:00"
},
{
"name": "nyholm/psr7",
"version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/Nyholm/psr7.git",
"reference": "c17f4f73985f62054a331cbc4ffdf9868c4ef256"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Nyholm/psr7/zipball/c17f4f73985f62054a331cbc4ffdf9868c4ef256",
"reference": "c17f4f73985f62054a331cbc4ffdf9868c4ef256",
"shasum": ""
},
"require": {
"php": "^7.1",
"php-http/message-factory": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
},
"provide": {
"psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"http-interop/http-factory-tests": "dev-master",
"php-http/psr7-integration-tests": "^1.0",
"phpunit/phpunit": "^7.5",
"symfony/error-handler": "^4.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Nyholm\\Psr7\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com"
},
{
"name": "Martijn van der Ven",
"email": "martijn@vanderven.se"
}
],
"description": "A fast PHP7 implementation of PSR-7",
"homepage": "http://tnyholm.se",
"keywords": [
"psr-17",
"psr-7"
],
"funding": [
{
"url": "https://github.com/Zegnat",
"type": "github"
},
{
"url": "https://github.com/nyholm",
"type": "github"
}
],
"time": "2020-05-23T11:29:07+00:00"
},
{
"name": "ocramius/doctrine-batch-utils",
"version": "2.0.0",
@ -4662,51 +4486,6 @@
],
"time": "2019-11-06T19:20:29+00:00"
},
{
"name": "paragonie/random_compat",
"version": "v9.99.99",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
"shasum": ""
},
"require": {
"php": "^7"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*",
"vimeo/psalm": "^1"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
],
"time": "2018-07-02T15:55:56+00:00"
},
{
"name": "php-di/invoker",
"version": "2.0.0",
@ -4896,78 +4675,6 @@
"description": "PHP-DI integration in Slim",
"time": "2020-01-13T19:11:12+00:00"
},
{
"name": "php-http/client-common",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/php-http/client-common.git",
"reference": "f3985360f3d054292605e9ec7c4bc24ebcf249bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/client-common/zipball/f3985360f3d054292605e9ec7c4bc24ebcf249bb",
"reference": "f3985360f3d054292605e9ec7c4bc24ebcf249bb",
"shasum": ""
},
"require": {
"php": "^7.1",
"php-http/httplug": "^2.0",
"php-http/message": "^1.6",
"php-http/message-factory": "^1.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"symfony/options-resolver": "^2.6 || ^3.4.20 || ~4.0.15 || ~4.1.9 || ^4.2.1 || ^5.0",
"symfony/polyfill-php80": "^1.17"
},
"require-dev": {
"doctrine/instantiator": "^1.1",
"guzzlehttp/psr7": "^1.4",
"nyholm/psr7": "^1.2",
"phpspec/phpspec": "^5.1 || ^6.0",
"phpspec/prophecy": "^1.8",
"phpunit/phpunit": "^7.5",
"sebastian/comparator": "^3.0"
},
"suggest": {
"ext-json": "To detect JSON responses with the ContentTypePlugin",
"ext-libxml": "To detect XML responses with the ContentTypePlugin",
"php-http/cache-plugin": "PSR-6 Cache plugin",
"php-http/logger-plugin": "PSR-3 Logger plugin",
"php-http/stopwatch-plugin": "Symfony Stopwatch plugin"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
}
},
"autoload": {
"psr-4": {
"Http\\Client\\Common\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"description": "Common HTTP Client implementations and tools for HTTPlug",
"homepage": "http://httplug.io",
"keywords": [
"client",
"common",
"http",
"httplug"
],
"time": "2020-07-02T06:51:04+00:00"
},
{
"name": "php-http/discovery",
"version": "1.9.0",
@ -5153,128 +4860,6 @@
],
"time": "2019-12-27T10:07:11+00:00"
},
{
"name": "php-http/message",
"version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/php-http/message.git",
"reference": "ce8f43ac1e294b54aabf5808515c3554a19c1e1c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/message/zipball/ce8f43ac1e294b54aabf5808515c3554a19c1e1c",
"reference": "ce8f43ac1e294b54aabf5808515c3554a19c1e1c",
"shasum": ""
},
"require": {
"clue/stream-filter": "^1.4",
"php": "^7.1",
"php-http/message-factory": "^1.0.2",
"psr/http-message": "^1.0"
},
"provide": {
"php-http/message-factory-implementation": "1.0"
},
"require-dev": {
"akeneo/phpspec-skip-example-extension": "^1.0",
"coduo/phpspec-data-provider-extension": "^1.0",
"ext-zlib": "*",
"guzzlehttp/psr7": "^1.0",
"henrikbjorn/phpspec-code-coverage": "^1.0",
"phpspec/phpspec": "^2.4",
"slim/slim": "^3.0",
"zendframework/zend-diactoros": "^1.0"
},
"suggest": {
"ext-zlib": "Used with compressor/decompressor streams",
"guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories",
"slim/slim": "Used with Slim Framework PSR-7 implementation",
"zendframework/zend-diactoros": "Used with Diactoros Factories"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
}
},
"autoload": {
"psr-4": {
"Http\\Message\\": "src/"
},
"files": [
"src/filters.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"description": "HTTP Message related tools",
"homepage": "http://php-http.org",
"keywords": [
"http",
"message",
"psr-7"
],
"time": "2019-08-05T06:55:08+00:00"
},
{
"name": "php-http/message-factory",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-http/message-factory.git",
"reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1",
"reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1",
"shasum": ""
},
"require": {
"php": ">=5.4",
"psr/http-message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"description": "Factory interfaces for PSR-7 HTTP Message",
"homepage": "http://php-http.org",
"keywords": [
"factory",
"http",
"message",
"stream",
"uri"
],
"time": "2015-12-19T14:08:53+00:00"
},
{
"name": "php-http/promise",
"version": "v1.0.0",
@ -5325,61 +4910,6 @@
],
"time": "2016-01-26T13:27:02+00:00"
},
{
"name": "php-http/socket-client",
"version": "2.0.0-beta1",
"source": {
"type": "git",
"url": "https://github.com/php-http/socket-client.git",
"reference": "7770fd30f98f33c97de9632c79266463a69e8fe0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/socket-client/zipball/7770fd30f98f33c97de9632c79266463a69e8fe0",
"reference": "7770fd30f98f33c97de9632c79266463a69e8fe0",
"shasum": ""
},
"require": {
"nyholm/psr7": "^1.0",
"php": "^7.1",
"php-http/httplug": "^2.0",
"psr/http-client": "^1.0",
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0 || ^5.0"
},
"provide": {
"php-http/client-implementation": "1.0"
},
"require-dev": {
"concurrent-php/async-api": "dev-master",
"friendsofphp/php-cs-fixer": "^2.2",
"php-http/client-common": "^2.0",
"php-http/client-integration-tests": "dev-master",
"php-http/message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"Http\\Client\\Socket\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Joel Wurtz",
"email": "jwurtz@jolicode.com"
}
],
"description": "Socket client for PHP-HTTP",
"time": "2019-12-11T16:29:11+00:00"
},
{
"name": "psr/cache",
"version": "1.0.1",
@ -6101,103 +5631,6 @@
],
"time": "2019-09-01T09:37:31+00:00"
},
{
"name": "sentry/sentry",
"version": "2.4.1",
"source": {
"type": "git",
"url": "https://github.com/getsentry/sentry-php.git",
"reference": "407573e22e6cc46b72cff07c117eeb16bf3a17de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/407573e22e6cc46b72cff07c117eeb16bf3a17de",
"reference": "407573e22e6cc46b72cff07c117eeb16bf3a17de",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/promises": "^1.3",
"guzzlehttp/psr7": "^1.6",
"jean85/pretty-package-versions": "^1.2",
"php": "^7.1",
"php-http/async-client-implementation": "^1.0",
"php-http/client-common": "^1.5|^2.0",
"php-http/discovery": "^1.6.1",
"php-http/httplug": "^1.1|^2.0",
"php-http/message": "^1.5",
"psr/http-factory": "^1.0",
"psr/http-message-implementation": "^1.0",
"psr/log": "^1.0",
"symfony/options-resolver": "^2.7|^3.0|^4.0|^5.0",
"symfony/polyfill-uuid": "^1.13.1"
},
"conflict": {
"php-http/client-common": "1.8.0",
"raven/raven": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"monolog/monolog": "^1.3|^2.0",
"php-http/mock-client": "^1.3",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^7.5.18",
"symfony/phpunit-bridge": "^4.3|^5.0",
"vimeo/psalm": "^3.4"
},
"suggest": {
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"files": [
"src/functions.php"
],
"psr-4": {
"Sentry\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sentry",
"email": "accounts@sentry.io"
}
],
"description": "A PHP SDK for Sentry (http://sentry.io)",
"homepage": "http://sentry.io",
"keywords": [
"crash-reporting",
"crash-reports",
"error-handler",
"error-monitoring",
"log",
"logging",
"sentry"
],
"funding": [
{
"url": "https://sentry.io/",
"type": "custom"
},
{
"url": "https://sentry.io/pricing/",
"type": "custom"
}
],
"time": "2020-07-03T09:58:40+00:00"
},
{
"name": "slim/http",
"version": "1.0.0",
@ -7238,76 +6671,6 @@
],
"time": "2020-05-24T08:49:09+00:00"
},
{
"name": "symfony/options-resolver",
"version": "v5.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "663f5dd5e14057d1954fe721f9709d35837f2447"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/663f5dd5e14057d1954fe721f9709d35837f2447",
"reference": "663f5dd5e14057d1954fe721f9709d35837f2447",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-php80": "^1.15"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.1-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\OptionsResolver\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony OptionsResolver Component",
"homepage": "https://symfony.com",
"keywords": [
"config",
"configuration",
"options"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-05-23T13:08:13+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.17.1",
@ -7620,83 +6983,6 @@
],
"time": "2020-06-06T08:46:27+00:00"
},
{
"name": "symfony/polyfill-uuid",
"version": "v1.17.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-uuid.git",
"reference": "5db3e66818f1f768b585220438436ea6c1e0b874"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/5db3e66818f1f768b585220438436ea6c1e0b874",
"reference": "5db3e66818f1f768b585220438436ea6c1e0b874",
"shasum": ""
},
"require": {
"paragonie/random_compat": "~1.0|~2.0|~9.99",
"php": ">=5.3.3"
},
"suggest": {
"ext-uuid": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.17-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Uuid\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Grégoire Pineau",
"email": "lyrixx@lyrixx.info"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for uuid functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"uuid"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-06-06T08:46:27+00:00"
},
{
"name": "symfony/process",
"version": "v5.1.2",

View File

@ -164,18 +164,6 @@ $config = [
],
],
Entity\Settings::SEND_ERROR_REPORTS => [
'toggle',
[
'label' => __('Automatically Send Error Reports to AzuraCast'),
'description' => __('If the web application encounters an error, you can choose to automatically send an anonymized report of the error to the AzuraCast team for faster diagnosis and resolution.') . '<br>' . __('Error reports are powered by <a href="%s" target="_blank">%s</a>.',
'https://sentry.io/', 'Sentry'),
'selected_text' => __('Yes'),
'deselected_text' => __('No'),
'default' => false,
],
],
],
],

View File

@ -39,9 +39,4 @@ return [
'en_US.UTF-8' => 'g:i A',
],
// Sentry error reporting DSN,
'sentry_io' => [
'dsn' => 'https://b07d75fb383743a081308a4e537f6843@sentry.io/1420408',
],
];

View File

@ -16,7 +16,6 @@ class Settings extends AbstractFixture
Entity\Settings::PREFER_BROWSER_URL => 1,
Entity\Settings::SETUP_COMPLETE => time(),
Entity\Settings::USE_RADIO_PROXY => 1,
Entity\Settings::SEND_ERROR_REPORTS => 0,
Entity\Settings::CENTRAL_UPDATES => Entity\Settings::UPDATES_NONE,
Entity\Settings::EXTERNAL_IP => '127.0.0.1',
];

View File

@ -23,7 +23,6 @@ class Settings
public const LISTENER_ANALYTICS = 'analytics';
public const CENTRAL_UPDATES = 'central_updates_channel';
public const SEND_ERROR_REPORTS = 'send_error_reports';
// Custom branding constants.
public const PUBLIC_THEME = 'public_theme';

View File

@ -5,7 +5,6 @@ use App\Entity;
use App\Exception;
use App\Exception\NotLoggedInException;
use App\Exception\PermissionDeniedException;
use App\Service\Sentry;
use App\Session\Flash;
use App\Settings;
use App\View;
@ -17,7 +16,6 @@ use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LogLevel;
use Slim\App;
use Slim\Exception\HttpException;
use stdClass;
use Whoops\Handler\PrettyPageHandler;
use Whoops\Run;
@ -33,8 +31,6 @@ class ErrorHandler extends \Slim\Handlers\ErrorHandler
protected View $view;
protected Sentry $sentry;
protected Settings $settings;
public function __construct(
@ -42,15 +38,13 @@ class ErrorHandler extends \Slim\Handlers\ErrorHandler
Logger $logger,
Router $router,
View $view,
Sentry $sentry,
Settings $settings
) {
parent::__construct($app->getCallableResolver(), $app->getResponseFactory(), $logger);
$this->settings = $settings;
$this->router = $router;
$this->view = $view;
$this->sentry = $sentry;
}
public function __invoke(
@ -68,49 +62,12 @@ class ErrorHandler extends \Slim\Handlers\ErrorHandler
$this->showDetailed = (!$this->settings->isProduction() && !in_array($this->loggerLevel,
[LogLevel::DEBUG, LogLevel::INFO, LogLevel::NOTICE], true));
$this->returnJson = $this->_shouldReturnJson($request);
$this->returnJson = $this->shouldReturnJson($request);
return parent::__invoke($request, $exception, $displayErrorDetails, $logErrors, $logErrorDetails);
}
/**
* @return bool
*/
public function returnJson(): bool
{
return $this->returnJson;
}
/**
* @param bool $returnJson
*/
public function setReturnJson(bool $returnJson): void
{
$this->returnJson = $returnJson;
}
/**
* @return bool
*/
public function showDetailed(): bool
{
return $this->showDetailed;
}
/**
* @param bool $showDetailed
*/
public function setShowDetailed(bool $showDetailed): void
{
$this->showDetailed = $showDetailed;
}
/**
* @param ServerRequestInterface $req
*
* @return bool
*/
protected function _shouldReturnJson(ServerRequestInterface $req): bool
protected function shouldReturnJson(ServerRequestInterface $req): bool
{
$xhr = $req->getHeaderLine('X-Requested-With') === 'XMLHttpRequest';
@ -243,10 +200,6 @@ class ErrorHandler extends \Slim\Handlers\ErrorHandler
return $response->withRedirect((string)$this->router->named('home'));
}
if (!in_array($this->loggerLevel, [LogLevel::INFO, LogLevel::DEBUG, LogLevel::NOTICE], true)) {
$this->sentry->handleException($this->exception);
}
/** @var Response $response */
$response = $this->responseFactory->createResponse(500);
@ -297,27 +250,9 @@ class ErrorHandler extends \Slim\Handlers\ErrorHandler
);
}
/**
* @param int $code
* @param string $message
* @param array $stack_trace
*
* @return stdClass
*/
protected function getErrorApiResponse($code = 500, $message = 'General Error', $stack_trace = []): stdClass
{
$api = new stdClass;
$api->success = false;
$api->code = (int)$code;
$api->message = (string)$message;
$api->stack_trace = (array)$stack_trace;
return $api;
}
protected function withJson(ResponseInterface $response, $data): ResponseInterface
{
$json = (string)json_encode($data);
$json = (string)json_encode($data, JSON_THROW_ON_ERROR);
$response->getBody()->write($json);
return $response->withHeader('Content-Type', 'application/json;charset=utf-8');

View File

@ -97,11 +97,6 @@ final class ServerRequest extends \Slim\Http\ServerRequest
?? null;
}
public function isApiCall(): bool
{
return $this->serverRequest->getAttribute(self::ATTR_IS_API_CALL, false);
}
public function getAcl(): Acl
{
return $this->getAttributeOfClass(self::ATTR_ACL, Acl::class);

View File

@ -26,9 +26,6 @@ class Api
public function __invoke(ServerRequest $request, RequestHandlerInterface $handler): ResponseInterface
{
// Set "is API call" attribute on the request so error handling responds correctly.
$request = $request->withAttribute(ServerRequest::ATTR_IS_API_CALL, true);
// Attempt API key auth if a key exists.
$api_key = $this->getApiKey($request);
$api_user = (!empty($api_key)) ? $this->api_repo->authenticate($api_key) : null;
@ -117,7 +114,7 @@ class Api
if (!empty($queryApiKey)) {
return $queryApiKey;
}
return null;
}
}

View File

@ -1,180 +0,0 @@
<?php
namespace App\Service;
use App\Entity;
use App\Exception\SupervisorException;
use App\Settings;
use App\Version;
use App\Exception;
use Doctrine\DBAL\Exception\TableNotFoundException;
use fXmlRpc\Exception\FaultException;
use GuzzleHttp\Client;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
use League\Flysystem\FileNotFoundException;
use Monolog\Logger;
use Sentry\ClientBuilder;
use Sentry\Options;
use Sentry\Severity;
use Sentry\State\Hub;
use Sentry\State\Scope;
use Throwable;
class Sentry
{
protected Entity\Repository\SettingsRepository $settingsRepo;
protected Settings $appSettings;
protected Client $httpClient;
protected Version $version;
protected bool $isEnabled = false;
protected bool $isInitialized = false;
protected Hub $hub;
public function __construct(
Entity\Repository\SettingsRepository $settings_repo,
Settings $app_settings,
Version $version,
Client $http_client
) {
$this->settingsRepo = $settings_repo;
$this->appSettings = $app_settings;
$this->version = $version;
$this->httpClient = $http_client;
}
/**
* Initialize the Sentry reporting for the instance.
*/
public function init(): void
{
if ($this->isInitialized) {
return;
}
$this->isInitialized = true;
// Check for enabled status.
try {
$send_error_reports = (bool)$this->settingsRepo->getSetting(Entity\Settings::SEND_ERROR_REPORTS, false);
if (!$send_error_reports) {
return;
}
} catch (TableNotFoundException $e) {
return;
}
if ($this->appSettings->isTesting()) {
return;
}
$this->isEnabled = true;
$server_uuid = $this->settingsRepo->getUniqueIdentifier();
$options = [
'dsn' => $this->appSettings['sentry_io']['dsn'],
'environment' => $this->appSettings[Settings::APP_ENV],
'server_name' => $server_uuid,
'prefixes' => [
$this->appSettings[Settings::BASE_DIR],
],
'project_root' => $this->appSettings[Settings::BASE_DIR] . '/src',
'error_types' => E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT,
'excluded_exceptions' => [
FileNotFoundException::class,
FaultException::class,
SupervisorException::class,
],
];
$commit_hash = $this->version->getCommitHash();
if ($commit_hash) {
$options['release'] = 'AzuraCast/AzuraCast@' . $commit_hash;
}
$options = new Options($options);
$builder = new ClientBuilder($options);
$builder->setHttpClient(new GuzzleAdapter($this->httpClient));
$this->hub = new Hub($builder->getClient());
$this->hub->configureScope([$this, 'configureScope']);
}
/**
* Scope configuration handler for SentryIO
*
* @param Scope $scope
*/
public function configureScope(Scope $scope): void
{
$scope->setUser([
'ip' => null,
]);
$install_type = $this->appSettings->isDocker() ? 'docker' : 'traditional';
$scope->setTag('type', $install_type);
}
/**
* @return Hub
*/
public function getHub(): Hub
{
$this->init();
return $this->hub;
}
/**
* @return bool
*/
public function isEnabled(): bool
{
$this->init();
return $this->isEnabled;
}
/**
* @param Throwable $e
*/
public function handleException(Throwable $e): void
{
$this->init();
if (!$this->isEnabled) {
return;
}
// Don't send error reports for installations whose code is modified.
if ($this->version->isInstallationModified()) {
return;
}
$e_level = ($e instanceof Exception)
? $e->getLoggerLevel()
: Logger::ERROR;
if ($e_level < Logger::WARNING) {
return;
}
$sentry_levels = [
Logger::WARNING => Severity::warning(),
Logger::ERROR => Severity::error(),
Logger::CRITICAL => Severity::error(),
Logger::ALERT => Severity::fatal(),
Logger::EMERGENCY => Severity::fatal(),
];
$sentry_level = $sentry_levels[$e_level];
$this->hub->withScope(function (Scope $scope) use ($e, $sentry_level) {
$scope->setLevel($sentry_level);
$this->hub->captureException($e);
});
}
}