1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @author Christoph Wurst <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @license GNU AGPL version 3 or any later version |
9
|
|
|
* |
10
|
|
|
* This program is free software: you can redistribute it and/or modify |
11
|
|
|
* it under the terms of the GNU Affero General Public License as |
12
|
|
|
* published by the Free Software Foundation, either version 3 of the |
13
|
|
|
* License, or (at your option) any later version. |
14
|
|
|
* |
15
|
|
|
* This program is distributed in the hope that it will be useful, |
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
* GNU Affero General Public License for more details. |
19
|
|
|
* |
20
|
|
|
* You should have received a copy of the GNU Affero General Public License |
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace OCA\Sentry\AppInfo; |
26
|
|
|
|
27
|
|
|
use OCA\Sentry\Config; |
28
|
|
|
use OCA\Sentry\InitialState\DsnProvider; |
29
|
|
|
use OCA\Sentry\Reporter\ISentryReporter; |
30
|
|
|
use OCA\Sentry\Reporter\RecursionAwareReporter; |
31
|
|
|
use OCA\Sentry\Reporter\SentryReporterAdapter; |
32
|
|
|
use OCP\AppFramework\App; |
33
|
|
|
use OCP\AppFramework\Bootstrap\IBootContext; |
34
|
|
|
use OCP\AppFramework\Bootstrap\IBootstrap; |
35
|
|
|
use OCP\AppFramework\Bootstrap\IRegistrationContext; |
36
|
|
|
use OCP\AppFramework\Http\ContentSecurityPolicy; |
37
|
|
|
use OCP\EventDispatcher\IEventDispatcher; |
38
|
|
|
use OCP\IConfig; |
39
|
|
|
use OCP\IInitialStateService; |
40
|
|
|
use OCP\Security\CSP\AddContentSecurityPolicyEvent; |
41
|
|
|
use OCP\Support\CrashReport\IRegistry; |
42
|
|
|
use OCP\Support\CrashReport\IReporter; |
43
|
|
|
use OCP\Util; |
44
|
|
|
use Psr\Container\ContainerInterface; |
|
|
|
|
45
|
|
|
use function parse_url; |
46
|
|
|
use function Sentry\init as initSentry; |
47
|
|
|
|
48
|
|
|
class Application extends App implements IBootstrap { |
49
|
|
|
|
50
|
|
|
public function __construct(array $urlParams = []) { |
51
|
|
|
parent::__construct('sentry', $urlParams); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function register(IRegistrationContext $context): void { |
55
|
|
|
// Register the autoloader |
56
|
|
|
include_once __DIR__ . '/../../vendor/autoload.php'; |
57
|
|
|
|
58
|
|
|
// Wire the interface to our decorator and implementation |
59
|
|
|
$context->registerService(ISentryReporter::class, function (ContainerInterface $c) { |
60
|
|
|
/** @var Config $config */ |
61
|
|
|
$config = $c->get(Config::class); |
62
|
|
|
/** @var SentryReporterAdapter $inner */ |
63
|
|
|
$inner = $c->get(SentryReporterAdapter::class); |
64
|
|
|
|
65
|
|
|
// Now it's time to connect Sentry |
66
|
|
|
$dsn = $config->getDsn(); |
|
|
|
|
67
|
|
|
if ($dsn !== null) { |
68
|
|
|
initSentry([ |
69
|
|
|
'dsn' => $dsn, |
70
|
|
|
'release' => $config->getServerVersion(), |
71
|
|
|
]); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return new RecursionAwareReporter($inner); |
75
|
|
|
}); |
76
|
|
|
$context->registerCrashReporter(ISentryReporter::class); |
77
|
|
|
|
78
|
|
|
$context->registerInitialStateProvider(DsnProvider::class); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function boot(IBootContext $context): void { |
82
|
|
|
Util::addScript('sentry', 'sentry'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths