From c816f9472d6a3dfe1b4094758d43191860081114 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 14:45:08 +0100 Subject: [PATCH 01/17] Fix a test --- test/DependencyInjection/ConfigurationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/DependencyInjection/ConfigurationTest.php b/test/DependencyInjection/ConfigurationTest.php index 7009068a..880a41cd 100644 --- a/test/DependencyInjection/ConfigurationTest.php +++ b/test/DependencyInjection/ConfigurationTest.php @@ -62,7 +62,7 @@ public function testConfigurationDefaults(): void '%kernel.cache_dir%', '%kernel.project_dir%/vendor', ], - 'integrations' => $defaultSdkValues->getIntegrations(), + 'integrations' => [], 'excluded_exceptions' => $defaultSdkValues->getExcludedExceptions(), 'prefixes' => $defaultSdkValues->getPrefixes(), 'project_root' => '%kernel.project_dir%', From 9619847078336fa68bc05ac7b77d85abb148b38c Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 14:45:34 +0100 Subject: [PATCH 02/17] Require sentry/sdk:^2.1 to obtain sentry/sentry:^2.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bc4c3cc9..f907e6dc 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": "^7.1", "jean85/pretty-package-versions": "^1.0", "ocramius/package-versions": "^1.3.0", - "sentry/sdk": "^2.0", + "sentry/sdk": "^2.1", "symfony/config": "^3.4||^4.0||^5.0", "symfony/console": "^3.4||^4.0||^5.0", "symfony/dependency-injection": "^3.4||^4.0||^5.0", From 135fa2ad7c0b8148b4d04c640e194d801609466e Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 16:17:58 +0100 Subject: [PATCH 03/17] Use a callable to filter the integrations --- .../ClientBuilderConfigurator.php | 21 -------- .../IntegrationFilterFactory.php | 32 ++++++++++++ src/DependencyInjection/SentryExtension.php | 10 ++-- .../SentryExtensionTest.php | 51 +++++++++++++------ 4 files changed, 75 insertions(+), 39 deletions(-) create mode 100644 src/DependencyInjection/IntegrationFilterFactory.php diff --git a/src/DependencyInjection/ClientBuilderConfigurator.php b/src/DependencyInjection/ClientBuilderConfigurator.php index 4ccf4b8b..2b5f1d46 100644 --- a/src/DependencyInjection/ClientBuilderConfigurator.php +++ b/src/DependencyInjection/ClientBuilderConfigurator.php @@ -3,9 +3,6 @@ namespace Sentry\SentryBundle\DependencyInjection; use Sentry\ClientBuilderInterface; -use Sentry\Integration\ErrorListenerIntegration; -use Sentry\Integration\ExceptionListenerIntegration; -use Sentry\Integration\IntegrationInterface; use Sentry\SentryBundle\SentryBundle; class ClientBuilderConfigurator @@ -14,23 +11,5 @@ public static function configure(ClientBuilderInterface $clientBuilder): void { $clientBuilder->setSdkIdentifier(SentryBundle::SDK_IDENTIFIER); $clientBuilder->setSdkVersion(SentryBundle::getSdkVersion()); - - $options = $clientBuilder->getOptions(); - if (! $options->hasDefaultIntegrations()) { - return; - } - - $integrations = $options->getIntegrations(); - $options->setIntegrations(array_filter($integrations, static function (IntegrationInterface $integration): bool { - if ($integration instanceof ErrorListenerIntegration) { - return false; - } - - if ($integration instanceof ExceptionListenerIntegration) { - return false; - } - - return true; - })); } } diff --git a/src/DependencyInjection/IntegrationFilterFactory.php b/src/DependencyInjection/IntegrationFilterFactory.php new file mode 100644 index 00000000..f74138d1 --- /dev/null +++ b/src/DependencyInjection/IntegrationFilterFactory.php @@ -0,0 +1,32 @@ +addMethodCall('setClassSerializers', [$classSerializers]); } + $integrations = []; if (\array_key_exists('integrations', $processedOptions)) { - $integrations = []; foreach ($processedOptions['integrations'] as $integrationName) { $integrations[] = new Reference(substr($integrationName, 1)); } - - $options->addMethodCall('setIntegrations', [$integrations]); } + + $integrationsCallable = new Definition('callable', [$integrations]); + $integrationsCallable->setFactory([IntegrationFilterFactory::class, 'create']); + + $options->addMethodCall('setIntegrations', [$integrationsCallable]); } private function valueToCallable($value) diff --git a/test/DependencyInjection/SentryExtensionTest.php b/test/DependencyInjection/SentryExtensionTest.php index 0d35ab1d..5df3c8ba 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/test/DependencyInjection/SentryExtensionTest.php @@ -8,6 +8,8 @@ use Sentry\Breadcrumb; use Sentry\ClientInterface; use Sentry\Event; +use Sentry\Integration\ErrorListenerIntegration; +use Sentry\Integration\ExceptionListenerIntegration; use Sentry\Integration\IntegrationInterface; use Sentry\Monolog\Handler; use Sentry\Options; @@ -203,8 +205,8 @@ public function testBeforeSendUsingServiceDefinition(): void { $container = $this->getContainer([ 'options' => [ - 'before_send' => '@callable_mock', - ], + 'before_send' => '@callable_mock', + ], ]); $beforeSendCallback = $this->getOptionsFrom($container)->getBeforeSendCallback(); @@ -228,8 +230,8 @@ public function testBeforeSendUsingScalarCallable($scalarCallable): void { $container = $this->getContainer([ 'options' => [ - 'before_send' => $scalarCallable, - ], + 'before_send' => $scalarCallable, + ], ]); $beforeSendCallback = $this->getOptionsFrom($container)->getBeforeSendCallback(); @@ -250,8 +252,8 @@ public function testBeforeSendWithInvalidServiceReference(): void { $container = $this->getContainer([ 'options' => [ - 'before_send' => '@event_dispatcher', - ], + 'before_send' => '@event_dispatcher', + ], ]); $this->expectException(\TypeError::class); @@ -263,8 +265,8 @@ public function testBeforeBreadcrumbUsingServiceDefinition(): void { $container = $this->getContainer([ 'options' => [ - 'before_breadcrumb' => '@callable_mock', - ], + 'before_breadcrumb' => '@callable_mock', + ], ]); $beforeBreadcrumbCallback = $this->getOptionsFrom($container)->getBeforeBreadcrumbCallback(); @@ -288,8 +290,8 @@ public function testBeforeBreadcrumbUsingScalarCallable($scalarCallable): void { $container = $this->getContainer([ 'options' => [ - 'before_breadcrumb' => $scalarCallable, - ], + 'before_breadcrumb' => $scalarCallable, + ], ]); $beforeBreadcrumbCallback = $this->getOptionsFrom($container)->getBeforeBreadcrumbCallback(); @@ -319,8 +321,8 @@ public function testBeforeBreadcrumbWithInvalidServiceReference(): void { $container = $this->getContainer([ 'options' => [ - 'before_breadcrumb' => '@event_dispatcher', - ], + 'before_breadcrumb' => '@event_dispatcher', + ], ]); $this->expectException(\TypeError::class); @@ -337,8 +339,24 @@ public function testIntegrations(): void ]); $integrations = $this->getOptionsFrom($container)->getIntegrations(); - $this->assertContainsOnlyInstancesOf(IntegrationMock::class, $integrations); - $this->assertCount(1, $integrations); + $this->assertNotEmpty($integrations); + + $found = false; + foreach ($integrations as $integration) { + if ($integration instanceof ErrorListenerIntegration) { + $this->fail('Should not have FatalErrorListenerIntegration registered'); + } + + if ($integration instanceof ExceptionListenerIntegration) { + $this->fail('Should not have ExceptionListenerIntegration registered'); + } + + if ($integration instanceof IntegrationMock) { + $found = true; + } + } + + $this->assertTrue($found, 'No IntegrationMock found in final integrations enabled'); } /** @@ -458,7 +476,10 @@ private function getContainer(array $configuration = []): Container private function getOptionsFrom(Container $container): Options { - $this->assertTrue($container->has(self::OPTIONS_TEST_PUBLIC_ALIAS), 'Options (or public alias) missing from container!'); + $this->assertTrue( + $container->has(self::OPTIONS_TEST_PUBLIC_ALIAS), + 'Options (or public alias) missing from container!' + ); $options = $container->get(self::OPTIONS_TEST_PUBLIC_ALIAS); $this->assertInstanceOf(Options::class, $options); From 41fc75c2601eaa3fe50318b3475f3327ddebf8e8 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 16:24:10 +0100 Subject: [PATCH 04/17] Remove deprecation --- src/EventListener/RequestListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EventListener/RequestListener.php b/src/EventListener/RequestListener.php index 99c99a31..30602754 100644 --- a/src/EventListener/RequestListener.php +++ b/src/EventListener/RequestListener.php @@ -81,7 +81,7 @@ public function onKernelRequest(RequestEvent $event): void SentryBundle::getCurrentHub() ->configureScope(function (Scope $scope) use ($userData): void { - $scope->setUser($userData); + $scope->setUser($userData, true); }); } From cb5df80cb8d93f8f2ac4448d84ea7853f0786146 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 16:48:36 +0100 Subject: [PATCH 05/17] Add in_app_include option support --- src/DependencyInjection/Configuration.php | 7 ++++++- test/BaseTestCase.php | 2 +- test/DependencyInjection/ConfigurationTest.php | 6 +++++- test/DependencyInjection/SentryExtensionTest.php | 3 ++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index bea54ec3..7ca7ba2e 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -75,6 +75,11 @@ public function getConfigTreeBuilder(): TreeBuilder ->defaultValue('%kernel.environment%') ->cannotBeEmpty(); $optionsChildNodes->scalarNode('error_types'); + $optionsChildNodes->arrayNode('in_app_include') + ->defaultValue([ + '%kernel.project_dir%', + ]) + ->prototype('scalar'); $optionsChildNodes->arrayNode('in_app_exclude') ->defaultValue([ '%kernel.cache_dir%', @@ -114,7 +119,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->defaultValue($defaultValues->getPrefixes()) ->prototype('scalar'); $optionsChildNodes->scalarNode('project_root') - ->defaultValue('%kernel.project_dir%'); + ->setDeprecated(); $optionsChildNodes->scalarNode('release') ->defaultValue(Versions::getVersion(Versions::ROOT_PACKAGE_NAME)) ->info('Release version to be reported to sentry, see https://docs.sentry.io/workflow/releases/?platform=php') diff --git a/test/BaseTestCase.php b/test/BaseTestCase.php index 8d4b6f7a..63562b1d 100644 --- a/test/BaseTestCase.php +++ b/test/BaseTestCase.php @@ -27,7 +27,7 @@ protected function maxRequestBodySizeIsSupported(): bool protected function getSupportedOptionsCount(): int { - $count = 23; + $count = 24; if ($this->classSerializersAreSupported()) { ++$count; diff --git a/test/DependencyInjection/ConfigurationTest.php b/test/DependencyInjection/ConfigurationTest.php index 880a41cd..afd5da99 100644 --- a/test/DependencyInjection/ConfigurationTest.php +++ b/test/DependencyInjection/ConfigurationTest.php @@ -58,6 +58,7 @@ public function testConfigurationDefaults(): void ], 'options' => [ 'environment' => '%kernel.environment%', + 'in_app_include' => ['%kernel.project_dir%'], 'in_app_exclude' => [ '%kernel.cache_dir%', '%kernel.project_dir%/vendor', @@ -65,7 +66,6 @@ public function testConfigurationDefaults(): void 'integrations' => [], 'excluded_exceptions' => $defaultSdkValues->getExcludedExceptions(), 'prefixes' => $defaultSdkValues->getPrefixes(), - 'project_root' => '%kernel.project_dir%', 'tags' => [], 'release' => Versions::getVersion('sentry/sentry-symfony'), ], @@ -87,6 +87,8 @@ public function testConfigurationDefaults(): void } /** + * @group legacy + * * @dataProvider optionValuesProvider */ public function testOptionValuesProcessing(string $option, $value): void @@ -111,6 +113,7 @@ public function optionValuesProvider(): array ['environment', 'staging'], ['error_types', E_ALL], ['http_proxy', '1.2.3.4:5678'], + ['in_app_include', ['some/path']], ['in_app_exclude', ['some/path']], ['integrations', []], ['excluded_exceptions', [\Throwable::class]], @@ -181,6 +184,7 @@ public function invalidValuesProvider(): array ['error_types', []], ['excluded_exceptions', 'some-string'], ['http_proxy', []], + ['in_app_include', 'some/single/path'], ['in_app_exclude', 'some/single/path'], ['integrations', [1]], ['integrations', 'a string'], diff --git a/test/DependencyInjection/SentryExtensionTest.php b/test/DependencyInjection/SentryExtensionTest.php index 5df3c8ba..67192688 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/test/DependencyInjection/SentryExtensionTest.php @@ -59,7 +59,7 @@ public function testOptionsDefaultValues(): void $options = $this->getOptionsFrom($container); $vendorDir = '/dir/project/root/vendor'; - $this->assertSame('/dir/project/root', $options->getProjectRoot()); + $this->assertContains('/dir/project/root', $options->getInAppIncludedPaths()); $this->assertNull($options->getDsn()); $this->assertSame('test', $options->getEnvironment()); @@ -126,6 +126,7 @@ public function optionsValueProvider(): array ['enable_compression', false, 'isCompressionEnabled'], ['environment', 'staging'], ['error_types', E_ALL & ~E_NOTICE], + ['in_app_include', ['/some/path'], 'getInAppIncludedPaths'], ['in_app_exclude', ['/some/path'], 'getInAppExcludedPaths'], ['excluded_exceptions', [\Throwable::class]], ['http_proxy', '1.2.3.4'], From 972e3756ade81721864db18570554db4deb688e9 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 17:09:41 +0100 Subject: [PATCH 06/17] Remap excluded_exceptions option to add the new IgnoreErrorIntegration and avoid deprecation --- src/DependencyInjection/Configuration.php | 2 +- src/DependencyInjection/SentryExtension.php | 10 +++++++++- test/DependencyInjection/ConfigurationTest.php | 4 ++-- test/DependencyInjection/SentryExtensionTest.php | 1 - 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 7ca7ba2e..7e4355db 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -87,7 +87,7 @@ public function getConfigTreeBuilder(): TreeBuilder ]) ->prototype('scalar'); $optionsChildNodes->arrayNode('excluded_exceptions') - ->defaultValue($defaultValues->getExcludedExceptions()) + ->defaultValue([]) ->prototype('scalar'); $optionsChildNodes->scalarNode('http_proxy'); $optionsChildNodes->arrayNode('integrations') diff --git a/src/DependencyInjection/SentryExtension.php b/src/DependencyInjection/SentryExtension.php index 061f8839..dd39e06e 100644 --- a/src/DependencyInjection/SentryExtension.php +++ b/src/DependencyInjection/SentryExtension.php @@ -4,6 +4,7 @@ use Monolog\Logger as MonologLogger; use Sentry\ClientBuilderInterface; +use Sentry\Integration\IgnoreErrorsIntegration; use Sentry\Monolog\Handler; use Sentry\Options; use Sentry\SentryBundle\ErrorTypesParser; @@ -64,7 +65,6 @@ private function passConfigurationToOptions(ContainerBuilder $container, array $ 'default_integrations', 'enable_compression', 'environment', - 'excluded_exceptions', 'http_proxy', 'logger', 'max_request_body_size', @@ -122,6 +122,14 @@ private function passConfigurationToOptions(ContainerBuilder $container, array $ } } + if (\array_key_exists('excluded_exceptions', $processedOptions) && $processedOptions['excluded_exceptions']) { + $ignoreOptions = [ + 'ignore_exceptions' => $processedOptions['excluded_exceptions'], + ]; + + $integrations[] = new Definition(IgnoreErrorsIntegration::class, [$ignoreOptions]); + } + $integrationsCallable = new Definition('callable', [$integrations]); $integrationsCallable->setFactory([IntegrationFilterFactory::class, 'create']); diff --git a/test/DependencyInjection/ConfigurationTest.php b/test/DependencyInjection/ConfigurationTest.php index afd5da99..003250e2 100644 --- a/test/DependencyInjection/ConfigurationTest.php +++ b/test/DependencyInjection/ConfigurationTest.php @@ -64,7 +64,7 @@ public function testConfigurationDefaults(): void '%kernel.project_dir%/vendor', ], 'integrations' => [], - 'excluded_exceptions' => $defaultSdkValues->getExcludedExceptions(), + 'excluded_exceptions' => [], 'prefixes' => $defaultSdkValues->getPrefixes(), 'tags' => [], 'release' => Versions::getVersion('sentry/sentry-symfony'), @@ -88,7 +88,7 @@ public function testConfigurationDefaults(): void /** * @group legacy - * + * * @dataProvider optionValuesProvider */ public function testOptionValuesProcessing(string $option, $value): void diff --git a/test/DependencyInjection/SentryExtensionTest.php b/test/DependencyInjection/SentryExtensionTest.php index 67192688..5135e20b 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/test/DependencyInjection/SentryExtensionTest.php @@ -128,7 +128,6 @@ public function optionsValueProvider(): array ['error_types', E_ALL & ~E_NOTICE], ['in_app_include', ['/some/path'], 'getInAppIncludedPaths'], ['in_app_exclude', ['/some/path'], 'getInAppExcludedPaths'], - ['excluded_exceptions', [\Throwable::class]], ['http_proxy', '1.2.3.4'], ['logger', 'sentry-logger'], ['max_breadcrumbs', 15], From be42948c3eb438d38c526894397fcec3d0e6f78d Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 17:27:27 +0100 Subject: [PATCH 07/17] Map the in_app_include option correctly --- src/DependencyInjection/SentryExtension.php | 4 ++++ test/DependencyInjection/SentryExtensionTest.php | 1 + 2 files changed, 5 insertions(+) diff --git a/src/DependencyInjection/SentryExtension.php b/src/DependencyInjection/SentryExtension.php index dd39e06e..c7974aa8 100644 --- a/src/DependencyInjection/SentryExtension.php +++ b/src/DependencyInjection/SentryExtension.php @@ -91,6 +91,10 @@ private function passConfigurationToOptions(ContainerBuilder $container, array $ $options->addMethodCall('setInAppExcludedPaths', [$processedOptions['in_app_exclude']]); } + if (\array_key_exists('in_app_include', $processedOptions)) { + $options->addMethodCall('setInAppIncludedPaths', [$processedOptions['in_app_include']]); + } + if (\array_key_exists('error_types', $processedOptions)) { $parsedValue = (new ErrorTypesParser($processedOptions['error_types']))->parse(); $options->addMethodCall('setErrorTypes', [$parsedValue]); diff --git a/test/DependencyInjection/SentryExtensionTest.php b/test/DependencyInjection/SentryExtensionTest.php index 5135e20b..159b1f13 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/test/DependencyInjection/SentryExtensionTest.php @@ -41,6 +41,7 @@ public function testDataProviderIsMappingTheRightNumberOfOptions(): void // subtracted one is `integration`, which cannot be tested with the provider $expectedCount = $this->getSupportedOptionsCount(); + --$expectedCount; // excluded_exceptions is remapped to the new IgnoreErrorIntegration if (PrettyVersions::getVersion('sentry/sentry')->getPrettyVersion() === '2.0.0') { --$expectedCount; From 4776060bee527f9d8b16b3cd41d1a88acec15eb9 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 17:35:19 +0100 Subject: [PATCH 08/17] Remove multiple conditional code that was necessary to avoid deprecations --- src/Command/SentryTestCommand.php | 4 +- src/DependencyInjection/Configuration.php | 39 ++++++------------- src/EventListener/ConsoleListener.php | 4 +- src/EventListener/RequestListener.php | 8 ++-- src/EventListener/SubRequestListener.php | 6 +-- src/SentryBundle.php | 15 +------ .../SentryExtensionTest.php | 4 +- test/SentryBundleTest.php | 4 +- 8 files changed, 28 insertions(+), 56 deletions(-) diff --git a/src/Command/SentryTestCommand.php b/src/Command/SentryTestCommand.php index 7634adad..f7df7d6b 100644 --- a/src/Command/SentryTestCommand.php +++ b/src/Command/SentryTestCommand.php @@ -2,7 +2,7 @@ namespace Sentry\SentryBundle\Command; -use Sentry\SentryBundle\SentryBundle; +use Sentry\SentrySdk; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -16,7 +16,7 @@ public function __construct() protected function execute(InputInterface $input, OutputInterface $output): int { - $currentHub = SentryBundle::getCurrentHub(); + $currentHub = SentrySdk::getCurrentHub(); $client = $currentHub->getClient(); if (! $client) { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 7e4355db..88ddaad1 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -2,7 +2,6 @@ namespace Sentry\SentryBundle\DependencyInjection; -use Jean85\PrettyVersions; use PackageVersions\Versions; use Sentry\Options; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; @@ -58,14 +57,10 @@ public function getConfigTreeBuilder(): TreeBuilder ->validate() ->ifTrue($this->isNotAValidCallback()) ->thenInvalid('Expecting callable or service reference, got %s'); - if (PrettyVersions::getVersion('sentry/sentry')->getPrettyVersion() !== '2.0.0') { - $optionsChildNodes->booleanNode('capture_silenced_errors'); - } - if ($this->classSerializersAreSupported()) { - $optionsChildNodes->arrayNode('class_serializers') - ->defaultValue([]) - ->prototype('scalar'); - } + $optionsChildNodes->booleanNode('capture_silenced_errors'); + $optionsChildNodes->arrayNode('class_serializers') + ->defaultValue([]) + ->prototype('scalar'); $optionsChildNodes->integerNode('context_lines') ->min(0) ->max(99); @@ -102,15 +97,13 @@ public function getConfigTreeBuilder(): TreeBuilder }) ->thenInvalid('Expecting service reference, got "%s"'); $optionsChildNodes->scalarNode('logger'); - if ($this->maxRequestBodySizeIsSupported()) { - $optionsChildNodes->enumNode('max_request_body_size') - ->values([ - 'none', - 'small', - 'medium', - 'always', - ]); - } + $optionsChildNodes->enumNode('max_request_body_size') + ->values([ + 'none', + 'small', + 'medium', + 'always', + ]); $optionsChildNodes->integerNode('max_breadcrumbs') ->min(1); $optionsChildNodes->integerNode('max_value_length') @@ -198,14 +191,4 @@ private function isNotAValidCallback(): \Closure return true; }; } - - private function classSerializersAreSupported(): bool - { - return method_exists(Options::class, 'getClassSerializers'); - } - - private function maxRequestBodySizeIsSupported(): bool - { - return method_exists(Options::class, 'getMaxRequestBodySize'); - } } diff --git a/src/EventListener/ConsoleListener.php b/src/EventListener/ConsoleListener.php index f7e1eca3..15870f13 100644 --- a/src/EventListener/ConsoleListener.php +++ b/src/EventListener/ConsoleListener.php @@ -2,7 +2,7 @@ namespace Sentry\SentryBundle\EventListener; -use Sentry\SentryBundle\SentryBundle; +use Sentry\SentrySdk; use Sentry\State\HubInterface; use Sentry\State\Scope; use Symfony\Component\Console\Event\ConsoleCommandEvent; @@ -38,7 +38,7 @@ public function onConsoleCommand(ConsoleCommandEvent $event): void $commandName = $command->getName(); } - SentryBundle::getCurrentHub() + SentrySdk::getCurrentHub() ->configureScope(static function (Scope $scope) use ($commandName): void { $scope->setTag('command', $commandName ?? 'N/A'); }); diff --git a/src/EventListener/RequestListener.php b/src/EventListener/RequestListener.php index 30602754..0e81b68f 100644 --- a/src/EventListener/RequestListener.php +++ b/src/EventListener/RequestListener.php @@ -2,7 +2,7 @@ namespace Sentry\SentryBundle\EventListener; -use Sentry\SentryBundle\SentryBundle; +use Sentry\SentrySdk; use Sentry\State\HubInterface; use Sentry\State\Scope; use Symfony\Component\HttpKernel\Event\ControllerEvent; @@ -56,7 +56,7 @@ public function onKernelRequest(RequestEvent $event): void return; } - $currentClient = SentryBundle::getCurrentHub()->getClient(); + $currentClient = SentrySdk::getCurrentHub()->getClient(); if (null === $currentClient || ! $currentClient->getOptions()->shouldSendDefaultPii()) { return; } @@ -79,7 +79,7 @@ public function onKernelRequest(RequestEvent $event): void $userData['ip_address'] = $event->getRequest()->getClientIp(); - SentryBundle::getCurrentHub() + SentrySdk::getCurrentHub() ->configureScope(function (Scope $scope) use ($userData): void { $scope->setUser($userData, true); }); @@ -97,7 +97,7 @@ public function onKernelController(ControllerEvent $event): void $matchedRoute = (string) $event->getRequest()->attributes->get('_route'); - SentryBundle::getCurrentHub() + SentrySdk::getCurrentHub() ->configureScope(function (Scope $scope) use ($matchedRoute): void { $scope->setTag('route', $matchedRoute); }); diff --git a/src/EventListener/SubRequestListener.php b/src/EventListener/SubRequestListener.php index a6198c57..87970ac1 100644 --- a/src/EventListener/SubRequestListener.php +++ b/src/EventListener/SubRequestListener.php @@ -2,7 +2,7 @@ namespace Sentry\SentryBundle\EventListener; -use Sentry\SentryBundle\SentryBundle; +use Sentry\SentrySdk; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; @@ -24,7 +24,7 @@ public function onKernelRequest(RequestEvent $event): void return; } - SentryBundle::getCurrentHub()->pushScope(); + SentrySdk::getCurrentHub()->pushScope(); } /** @@ -38,6 +38,6 @@ public function onKernelFinishRequest(FinishRequestEvent $event): void return; } - SentryBundle::getCurrentHub()->popScope(); + SentrySdk::getCurrentHub()->popScope(); } } diff --git a/src/SentryBundle.php b/src/SentryBundle.php index 7ae98468..03d95558 100644 --- a/src/SentryBundle.php +++ b/src/SentryBundle.php @@ -4,7 +4,6 @@ use Jean85\PrettyVersions; use Sentry\SentrySdk; -use Sentry\State\Hub; use Sentry\State\HubInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -23,11 +22,7 @@ public static function getSdkVersion(): string */ public static function getCurrentHub(): HubInterface { - if (class_exists(SentrySdk::class)) { - return SentrySdk::getCurrentHub(); - } - - return Hub::getCurrent(); + return SentrySdk::getCurrentHub(); } /** @@ -35,12 +30,6 @@ public static function getCurrentHub(): HubInterface */ public static function setCurrentHub(HubInterface $hub): void { - if (class_exists(SentrySdk::class)) { - SentrySdk::setCurrentHub($hub); - - return; - } - - Hub::setCurrent($hub); + SentrySdk::setCurrentHub($hub); } } diff --git a/test/DependencyInjection/SentryExtensionTest.php b/test/DependencyInjection/SentryExtensionTest.php index 159b1f13..bc24d098 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/test/DependencyInjection/SentryExtensionTest.php @@ -15,8 +15,8 @@ use Sentry\Options; use Sentry\SentryBundle\DependencyInjection\SentryExtension; use Sentry\SentryBundle\EventListener\ErrorListener; -use Sentry\SentryBundle\SentryBundle; use Sentry\SentryBundle\Test\BaseTestCase; +use Sentry\SentrySdk; use Sentry\Severity; use Sentry\State\HubInterface; use Sentry\State\Scope; @@ -468,7 +468,7 @@ private function getContainer(array $configuration = []): Container $hub = $this->prophesize(HubInterface::class); $hub->bindClient(Argument::type(ClientMock::class)); - SentryBundle::setCurrentHub($hub->reveal()); + SentrySdk::setCurrentHub($hub->reveal()); $containerBuilder->compile(); diff --git a/test/SentryBundleTest.php b/test/SentryBundleTest.php index 16cfdfa7..79950e2f 100644 --- a/test/SentryBundleTest.php +++ b/test/SentryBundleTest.php @@ -13,7 +13,7 @@ use Sentry\SentryBundle\EventListener\ErrorListener; use Sentry\SentryBundle\EventListener\RequestListener; use Sentry\SentryBundle\EventListener\SubRequestListener; -use Sentry\SentryBundle\SentryBundle; +use Sentry\SentrySdk; use Sentry\State\Hub; use Sentry\State\HubInterface; use Symfony\Component\Console\ConsoleEvents; @@ -151,7 +151,7 @@ private function getContainer(array $configuration = []): ContainerBuilder $extension = new SentryExtension(); $extension->load(['sentry' => $configuration], $containerBuilder); - SentryBundle::setCurrentHub(new Hub()); + SentrySdk::setCurrentHub(new Hub()); return $containerBuilder; } From cf0a1a094445882a1d26f5226c1c59dc49b897fe Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 17:49:00 +0100 Subject: [PATCH 09/17] Remove multiple conditional code from tests too --- phpstan.neon | 2 - test/BaseTestCase.php | 35 +----------- test/Command/SentryTestCommandTest.php | 9 +-- .../DependencyInjection/ConfigurationTest.php | 55 +++++-------------- .../SentryExtensionTest.php | 22 +++----- test/EventListener/ConsoleListenerTest.php | 3 +- test/EventListener/RequestListenerTest.php | 3 +- test/EventListener/SubRequestListenerTest.php | 3 +- 8 files changed, 35 insertions(+), 97 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index baadf954..4b4c5b47 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,8 +5,6 @@ parameters: - test/ ignoreErrors: - "/Call to function method_exists.. with 'Symfony.+' and 'getRootNode' will always evaluate to false./" - - "/Call to function method_exists.. with 'Sentry..Options' and 'getClassSerializers' will always evaluate to false./" - - "/Call to function method_exists.. with 'Sentry..Options' and 'getMaxRequestBodySi...' will always evaluate to false./" - '/Class PHPUnit_Framework_TestCase not found/' - '/Symfony\\Component\\HttpKernel\\Event\\(GetResponse|FilterController)Event not found.$/' - diff --git a/test/BaseTestCase.php b/test/BaseTestCase.php index 63562b1d..bf531286 100644 --- a/test/BaseTestCase.php +++ b/test/BaseTestCase.php @@ -3,10 +3,6 @@ namespace Sentry\SentryBundle\Test; use PHPUnit\Framework\TestCase; -use Sentry\Options; -use Sentry\SentrySdk; -use Sentry\State\Hub; -use Sentry\State\HubInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; @@ -15,38 +11,9 @@ abstract class BaseTestCase extends TestCase { - protected function classSerializersAreSupported(): bool - { - return method_exists(Options::class, 'getClassSerializers'); - } - - protected function maxRequestBodySizeIsSupported(): bool - { - return method_exists(Options::class, 'getMaxRequestBodySize'); - } - protected function getSupportedOptionsCount(): int { - $count = 24; - - if ($this->classSerializersAreSupported()) { - ++$count; - } - - if ($this->maxRequestBodySizeIsSupported()) { - ++$count; - } - - return $count; - } - - protected function setCurrentHub(HubInterface $hub): void - { - if (class_exists(SentrySdk::class)) { - SentrySdk::setCurrentHub($hub); - } else { - Hub::setCurrent($hub); - } + return 26; } protected function createRequestEvent(Request $request = null, int $type = KernelInterface::MASTER_REQUEST) diff --git a/test/Command/SentryTestCommandTest.php b/test/Command/SentryTestCommandTest.php index 80beb15f..08ced888 100644 --- a/test/Command/SentryTestCommandTest.php +++ b/test/Command/SentryTestCommandTest.php @@ -7,6 +7,7 @@ use Sentry\Options; use Sentry\SentryBundle\Command\SentryTestCommand; use Sentry\SentryBundle\Test\BaseTestCase; +use Sentry\SentrySdk; use Sentry\State\HubInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; @@ -28,7 +29,7 @@ public function testExecuteSuccessfully(): void ->shouldBeCalled() ->willReturn($lastEventId); - $this->setCurrentHub($hub->reveal()); + SentrySdk::setCurrentHub($hub->reveal()); $commandTester = $this->executeCommand(); @@ -50,7 +51,7 @@ public function testExecuteFailsDueToMissingDSN(): void $hub->getClient() ->willReturn($client->reveal()); - $this->setCurrentHub($hub->reveal()); + SentrySdk::setCurrentHub($hub->reveal()); $commandTester = $this->executeCommand(); @@ -74,7 +75,7 @@ public function testExecuteFailsDueToMessageNotSent(): void ->shouldBeCalled() ->willReturn(null); - $this->setCurrentHub($hub->reveal()); + SentrySdk::setCurrentHub($hub->reveal()); $commandTester = $this->executeCommand(); @@ -91,7 +92,7 @@ public function testExecuteFailsDueToMissingClient(): void $hub->getClient() ->willReturn(null); - $this->setCurrentHub($hub->reveal()); + SentrySdk::setCurrentHub($hub->reveal()); $commandTester = $this->executeCommand(); diff --git a/test/DependencyInjection/ConfigurationTest.php b/test/DependencyInjection/ConfigurationTest.php index 003250e2..5fdfcac0 100644 --- a/test/DependencyInjection/ConfigurationTest.php +++ b/test/DependencyInjection/ConfigurationTest.php @@ -2,7 +2,6 @@ namespace Sentry\SentryBundle\Test\DependencyInjection; -use Jean85\PrettyVersions; use PackageVersions\Versions; use Sentry\Options; use Sentry\SentryBundle\DependencyInjection\Configuration; @@ -17,11 +16,7 @@ public function testDataProviderIsMappingTheRightNumberOfOptions(): void $providerData = $this->optionValuesProvider(); $supportedOptions = \array_unique(\array_column($providerData, 0)); - $expectedCount = $this->getSupportedOptionsCount(); - - if (PrettyVersions::getVersion('sentry/sentry')->getPrettyVersion() !== '2.0.0') { - ++$expectedCount; - } + $expectedCount = $this->getSupportedOptionsCount() + 1; $this->assertCount( $expectedCount, @@ -57,6 +52,7 @@ public function testConfigurationDefaults(): void 'console_error' => 128, ], 'options' => [ + 'class_serializers' => [], 'environment' => '%kernel.environment%', 'in_app_include' => ['%kernel.project_dir%'], 'in_app_exclude' => [ @@ -78,10 +74,6 @@ public function testConfigurationDefaults(): void ], ]; - if ($this->classSerializersAreSupported()) { - $expectedDefaults['options']['class_serializers'] = []; - } - $this->assertEquals($expectedDefaults, $processed); $this->assertArrayNotHasKey('server_name', $processed['options'], 'server_name has to be fetched at runtime, not before (see #181)'); } @@ -101,10 +93,12 @@ public function testOptionValuesProcessing(string $option, $value): void public function optionValuesProvider(): array { - $options = [ + return [ ['attach_stacktrace', true], ['before_breadcrumb', 'count'], ['before_send', 'count'], + ['capture_silenced_errors', true], + ['class_serializers', ['count']], ['context_lines', 4], ['context_lines', 99], ['default_integrations', true], @@ -119,6 +113,10 @@ public function optionValuesProvider(): array ['excluded_exceptions', [\Throwable::class]], ['logger', 'some-logger'], ['max_breadcrumbs', 15], + ['max_request_body_size', 'none'], + ['max_request_body_size', 'small'], + ['max_request_body_size', 'medium'], + ['max_request_body_size', 'always'], ['max_value_length', 1000], ['prefixes', ['some-string']], ['project_root', '/some/dir'], @@ -131,23 +129,6 @@ public function optionValuesProvider(): array ['server_name', 'server001.example.com'], ['tags', ['tag-name' => 'value']], ]; - - if (PrettyVersions::getVersion('sentry/sentry')->getPrettyVersion() !== '2.0.0') { - $options[] = ['capture_silenced_errors', true]; - } - - if ($this->classSerializersAreSupported()) { - $options[] = ['max_request_body_size', 'none']; - $options[] = ['max_request_body_size', 'small']; - $options[] = ['max_request_body_size', 'medium']; - $options[] = ['max_request_body_size', 'always']; - } - - if ($this->maxRequestBodySizeIsSupported()) { - $options[] = ['class_serializers', ['count']]; - } - - return $options; } /** @@ -174,6 +155,10 @@ public function invalidValuesProvider(): array ['before_send', [$this, 'is not a callable']], ['before_send', false], ['before_send', -1], + ['class_serializers', 'this is not a callable'], + ['class_serializers', [$this, 'is not a callable']], + ['class_serializers', false], + ['class_serializers', -1], ['context_lines', -1], ['context_lines', 99999], ['context_lines', 'string'], @@ -191,6 +176,8 @@ public function invalidValuesProvider(): array ['logger', []], ['max_breadcrumbs', -1], ['max_breadcrumbs', 'string'], + ['max_request_body_size', null], + ['max_request_body_size', 'invalid'], ['max_value_length', -1], ['max_value_length', []], ['prefixes', 'string'], @@ -206,18 +193,6 @@ public function invalidValuesProvider(): array ['tags', 'invalid-unmapped-tag'], ]; - if ($this->classSerializersAreSupported()) { - $values[] = ['class_serializers', 'this is not a callable']; - $values[] = ['class_serializers', [$this, 'is not a callable']]; - $values[] = ['class_serializers', false]; - $values[] = ['class_serializers', -1]; - } - - if ($this->maxRequestBodySizeIsSupported()) { - $values[] = ['max_request_body_size', null]; - $values[] = ['max_request_body_size', 'invalid']; - } - return $values; } diff --git a/test/DependencyInjection/SentryExtensionTest.php b/test/DependencyInjection/SentryExtensionTest.php index bc24d098..26f134df 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/test/DependencyInjection/SentryExtensionTest.php @@ -122,6 +122,13 @@ public function optionsValueProvider(): array ['attach_stacktrace', true, 'shouldAttachStacktrace'], ['before_breadcrumb', __NAMESPACE__ . '\mockBeforeBreadcrumb', 'getBeforeBreadcrumbCallback'], ['before_send', __NAMESPACE__ . '\mockBeforeSend', 'getBeforeSendCallback'], + [ + 'class_serializers', + [ + self::class => __NAMESPACE__ . '\mockClassSerializer', + ], + 'getClassSerializers', + ], ['context_lines', 1], ['default_integrations', false, 'hasDefaultIntegrations'], ['enable_compression', false, 'isCompressionEnabled'], @@ -132,6 +139,7 @@ public function optionsValueProvider(): array ['http_proxy', '1.2.3.4'], ['logger', 'sentry-logger'], ['max_breadcrumbs', 15], + ['max_request_body_size', 'always'], ['max_value_length', 1000], ['prefixes', ['/some/path/prefix/']], ['project_root', '/some/project/'], @@ -147,20 +155,6 @@ public function optionsValueProvider(): array $options[] = ['capture_silenced_errors', true, 'shouldCaptureSilencedErrors']; } - if ($this->classSerializersAreSupported()) { - $options['class_serializer'] = [ - 'class_serializers', - [ - self::class => __NAMESPACE__ . '\mockClassSerializer', - ], - 'getClassSerializers', - ]; - } - - if ($this->maxRequestBodySizeIsSupported()) { - $options[] = ['max_request_body_size', 'always']; - } - return $options; } diff --git a/test/EventListener/ConsoleListenerTest.php b/test/EventListener/ConsoleListenerTest.php index f503a4fc..1eb325f6 100644 --- a/test/EventListener/ConsoleListenerTest.php +++ b/test/EventListener/ConsoleListenerTest.php @@ -6,6 +6,7 @@ use Sentry\Event; use Sentry\SentryBundle\EventListener\ConsoleListener; use Sentry\SentryBundle\Test\BaseTestCase; +use Sentry\SentrySdk; use Sentry\State\HubInterface; use Sentry\State\Scope; use Symfony\Component\Console\Command\Command; @@ -32,7 +33,7 @@ protected function setUp(): void $callable($scope); }); - $this->setCurrentHub($this->currentHub->reveal()); + SentrySdk::setCurrentHub($this->currentHub->reveal()); } public function testOnConsoleCommandAddsCommandName(): void diff --git a/test/EventListener/RequestListenerTest.php b/test/EventListener/RequestListenerTest.php index 9ffe10d7..e6577c55 100644 --- a/test/EventListener/RequestListenerTest.php +++ b/test/EventListener/RequestListenerTest.php @@ -8,6 +8,7 @@ use Sentry\Options; use Sentry\SentryBundle\EventListener\RequestListener; use Sentry\SentryBundle\Test\BaseTestCase; +use Sentry\SentrySdk; use Sentry\State\HubInterface; use Sentry\State\Scope; use Symfony\Component\HttpFoundation\Request; @@ -48,7 +49,7 @@ protected function setUp(): void $callable($scope); }); - $this->setCurrentHub($this->currentHub->reveal()); + SentrySdk::setCurrentHub($this->currentHub->reveal()); } /** diff --git a/test/EventListener/SubRequestListenerTest.php b/test/EventListener/SubRequestListenerTest.php index 77c49386..317fe9cb 100644 --- a/test/EventListener/SubRequestListenerTest.php +++ b/test/EventListener/SubRequestListenerTest.php @@ -4,6 +4,7 @@ use Sentry\SentryBundle\EventListener\SubRequestListener; use Sentry\SentryBundle\Test\BaseTestCase; +use Sentry\SentrySdk; use Sentry\State\HubInterface; use Sentry\State\Scope; use Symfony\Component\HttpFoundation\Request; @@ -18,7 +19,7 @@ protected function setUp(): void { $this->currentHub = $this->prophesize(HubInterface::class); - $this->setCurrentHub($this->currentHub->reveal()); + SentrySdk::setCurrentHub($this->currentHub->reveal()); } public function testOnKernelRequestWithMasterRequest(): void From 393337ea4ad80c2969ba5cc31a10382ba5f6fc7f Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 17:49:46 +0100 Subject: [PATCH 10/17] Make tests run faster by using process isolation only on End2End --- phpunit.xml | 1 - test/End2End/End2EndTest.php | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 3701ed6d..2695c705 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,7 +6,6 @@ backupGlobals="false" bootstrap="vendor/autoload.php" cacheResult="false" - processIsolation="true" > diff --git a/test/End2End/End2EndTest.php b/test/End2End/End2EndTest.php index f6690e37..b99b9e31 100644 --- a/test/End2End/End2EndTest.php +++ b/test/End2End/End2EndTest.php @@ -16,6 +16,9 @@ class_alias(TestCase::class, \PHPUnit_Framework_TestCase::class); class_alias(Client::class, KernelBrowser::class); } +/** + * @runTestsInSeparateProcesses + */ class End2EndTest extends WebTestCase { protected static function getKernelClass(): string From 22db0e1bc9ac45572925bdc840a9ee7e39cde1fc Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 14 Jan 2020 17:54:41 +0100 Subject: [PATCH 11/17] Add changelog entries --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1c26182..e67da868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## Unreleased - - ... + - Drop support for `sentry/sentry` < 2.3 (#298) + - Add support to `in_app_include` client option (#298) + - Remap `excluded_exception` option to use the new `IgnoreErrorIntegration` (#298) ## 3.3.0 (2020-01-14) - Add support for Symfony 5.0 (#266, thanks to @Big-Shark) From 68f7bf25da0fd4f323f1b0a076f09647861d1f9c Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Wed, 15 Jan 2020 00:22:13 +0100 Subject: [PATCH 12/17] Fix test failure message --- test/DependencyInjection/SentryExtensionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/DependencyInjection/SentryExtensionTest.php b/test/DependencyInjection/SentryExtensionTest.php index 26f134df..21b98908 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/test/DependencyInjection/SentryExtensionTest.php @@ -339,7 +339,7 @@ public function testIntegrations(): void $found = false; foreach ($integrations as $integration) { if ($integration instanceof ErrorListenerIntegration) { - $this->fail('Should not have FatalErrorListenerIntegration registered'); + $this->fail('Should not have ErrorListenerIntegration registered'); } if ($integration instanceof ExceptionListenerIntegration) { From 78f27cdcc683dfe7f4b1be6a86d20659ad6c6491 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Thu, 16 Jan 2020 10:33:53 +0100 Subject: [PATCH 13/17] Revert remapping of project_root to avoid confusion --- src/DependencyInjection/Configuration.php | 5 ++--- test/DependencyInjection/ConfigurationTest.php | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 88ddaad1..47ca3dc5 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -72,7 +72,7 @@ public function getConfigTreeBuilder(): TreeBuilder $optionsChildNodes->scalarNode('error_types'); $optionsChildNodes->arrayNode('in_app_include') ->defaultValue([ - '%kernel.project_dir%', + '%kernel.project_dir%/src', ]) ->prototype('scalar'); $optionsChildNodes->arrayNode('in_app_exclude') @@ -111,8 +111,7 @@ public function getConfigTreeBuilder(): TreeBuilder $optionsChildNodes->arrayNode('prefixes') ->defaultValue($defaultValues->getPrefixes()) ->prototype('scalar'); - $optionsChildNodes->scalarNode('project_root') - ->setDeprecated(); + $optionsChildNodes->scalarNode('project_root'); $optionsChildNodes->scalarNode('release') ->defaultValue(Versions::getVersion(Versions::ROOT_PACKAGE_NAME)) ->info('Release version to be reported to sentry, see https://docs.sentry.io/workflow/releases/?platform=php') diff --git a/test/DependencyInjection/ConfigurationTest.php b/test/DependencyInjection/ConfigurationTest.php index 5fdfcac0..81177e90 100644 --- a/test/DependencyInjection/ConfigurationTest.php +++ b/test/DependencyInjection/ConfigurationTest.php @@ -54,7 +54,9 @@ public function testConfigurationDefaults(): void 'options' => [ 'class_serializers' => [], 'environment' => '%kernel.environment%', - 'in_app_include' => ['%kernel.project_dir%'], + 'in_app_include' => [ + '%kernel.project_dir%/src', + ], 'in_app_exclude' => [ '%kernel.cache_dir%', '%kernel.project_dir%/vendor', From b171f4d270aa6e01f3350bb248eeb2a1c21dd507 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Thu, 16 Jan 2020 10:35:27 +0100 Subject: [PATCH 14/17] Add changelog entry for new sentry/sentry support --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e67da868..6ccaf898 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## Unreleased + - Add support for `sentry/sentry` 2.3 (#298) - Drop support for `sentry/sentry` < 2.3 (#298) - Add support to `in_app_include` client option (#298) - Remap `excluded_exception` option to use the new `IgnoreErrorIntegration` (#298) From c28319d45d7d6885a3ff7ffb3d7fb89e2c81a4c3 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Thu, 16 Jan 2020 10:45:07 +0100 Subject: [PATCH 15/17] Fix test --- test/DependencyInjection/SentryExtensionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/DependencyInjection/SentryExtensionTest.php b/test/DependencyInjection/SentryExtensionTest.php index 21b98908..701fcbc1 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/test/DependencyInjection/SentryExtensionTest.php @@ -60,7 +60,7 @@ public function testOptionsDefaultValues(): void $options = $this->getOptionsFrom($container); $vendorDir = '/dir/project/root/vendor'; - $this->assertContains('/dir/project/root', $options->getInAppIncludedPaths()); + $this->assertContains('/dir/project/root/src', $options->getInAppIncludedPaths()); $this->assertNull($options->getDsn()); $this->assertSame('test', $options->getEnvironment()); From 43f320801635feeaddcef73fdd918e0bfb21cd5c Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Thu, 16 Jan 2020 10:50:30 +0100 Subject: [PATCH 16/17] Fix another test --- test/SentryBundleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SentryBundleTest.php b/test/SentryBundleTest.php index 79950e2f..a8d6ada4 100644 --- a/test/SentryBundleTest.php +++ b/test/SentryBundleTest.php @@ -97,7 +97,7 @@ public function testContainerHasErrorListenerConfiguredCorrectly(): void $consoleListener = $container->getDefinition(ErrorListener::class); - $method = class_exists(ExceptionEvent::class) + $method = class_exists(ExceptionEvent::class) && method_exists(ExceptionEvent::class, 'getThrowable') ? 'onException' : 'onKernelException'; $expectedTag = [ From a44ca03c65f809ebebfcddadc5b46f1de2e16aca Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Fri, 17 Jan 2020 11:50:18 +0100 Subject: [PATCH 17/17] Update changelog to slate 3.4.0 release --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d9a5bae..5131453c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,16 +5,19 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## Unreleased + - ... + +## 3.4.0 (2020-01-17) - Add support for `sentry/sentry` 2.3 (#298) - Drop support for `sentry/sentry` < 2.3 (#298) - Add support to `in_app_include` client option (#298) - Remap `excluded_exception` option to use the new `IgnoreErrorIntegration` (#298) ## 3.3.2 (2020-01-16) -- Fix issue with exception listener under Symfony 4.3 (#301) + - Fix issue with exception listener under Symfony 4.3 (#301) ## 3.3.1 (2020-01-14) -- Fixed Release + - Fixed Release ## 3.3.0 (2020-01-14) - Add support for Symfony 5.0 (#266, thanks to @Big-Shark)