diff --git a/composer.json b/composer.json index a68c320a..7d2c858e 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php": "^7.2||^8.0", "guzzlehttp/psr7": "^2.1.1", "jean85/pretty-package-versions": "^1.5||^2.0", - "sentry/sentry": "^4.14.1", + "sentry/sentry": "^4.15.0", "symfony/cache-contracts": "^1.1||^2.4||^3.0", "symfony/config": "^4.4.20||^5.0.11||^6.0||^7.0", "symfony/console": "^4.4.20||^5.0.11||^6.0||^7.0", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9e15536c..2c01285c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -85,6 +85,11 @@ parameters: count: 1 path: src/DependencyInjection/SentryExtension.php + - + message: "#^Cannot access offset 'before_send_logs' on mixed\\.$#" + count: 1 + path: src/DependencyInjection/SentryExtension.php + - message: "#^Parameter \\#1 \\$array of function array_filter expects array, mixed given\\.$#" count: 1 @@ -97,7 +102,7 @@ parameters: - message: "#^Parameter \\#1 \\$id of class Symfony\\\\Component\\\\DependencyInjection\\\\Reference constructor expects string, mixed given\\.$#" - count: 10 + count: 11 path: src/DependencyInjection/SentryExtension.php - diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index ca095895..f2618281 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -85,6 +85,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->max(1.0) ->info('The sampling factor to apply to profiles. A value of 0 will deny sending any profiles, and a value of 1 will send all profiles. Profiles are sampled in relation to traces_sample_rate') ->end() + ->booleanNode('enable_logs')->end() ->booleanNode('attach_stacktrace')->end() ->booleanNode('attach_metric_code_locations')->end() ->integerNode('context_lines')->min(0)->end() @@ -112,6 +113,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarNode('before_send_transaction')->end() ->scalarNode('before_send_check_in')->end() ->scalarNode('before_send_metrics')->end() + ->scalarNode('before_send_logs')->end() ->variableNode('trace_propagation_targets')->end() ->arrayNode('tags') ->useAttributeAsKey('name') diff --git a/src/DependencyInjection/SentryExtension.php b/src/DependencyInjection/SentryExtension.php index a05a62e8..55a268cc 100644 --- a/src/DependencyInjection/SentryExtension.php +++ b/src/DependencyInjection/SentryExtension.php @@ -124,6 +124,10 @@ private function registerConfiguration(ContainerBuilder $container, array $confi $options['before_send_metrics'] = new Reference($options['before_send_metrics']); } + if (isset($options['before_send_logs'])) { + $options['before_send_logs'] = new Reference($options['before_send_logs']); + } + if (isset($options['before_breadcrumb'])) { $options['before_breadcrumb'] = new Reference($options['before_breadcrumb']); } diff --git a/src/Resources/config/schema/sentry-1.0.xsd b/src/Resources/config/schema/sentry-1.0.xsd index 3bad5d57..0bd49d7a 100644 --- a/src/Resources/config/schema/sentry-1.0.xsd +++ b/src/Resources/config/schema/sentry-1.0.xsd @@ -37,6 +37,7 @@ + @@ -54,6 +55,7 @@ + diff --git a/tests/DependencyInjection/Fixtures/php/full.php b/tests/DependencyInjection/Fixtures/php/full.php index aa11c22f..89862bb9 100644 --- a/tests/DependencyInjection/Fixtures/php/full.php +++ b/tests/DependencyInjection/Fixtures/php/full.php @@ -17,6 +17,7 @@ 'traces_sample_rate' => 1, 'traces_sampler' => 'App\\Sentry\\Tracing\\TracesSampler', 'profiles_sample_rate' => 1, + 'enable_logs' => true, 'attach_stacktrace' => true, 'attach_metric_code_locations' => true, 'context_lines' => 0, @@ -32,6 +33,7 @@ 'before_send_transaction' => 'App\\Sentry\\BeforeSendTransactionCallback', 'before_send_check_in' => 'App\\Sentry\\BeforeSendCheckInCallback', 'before_send_metrics' => 'App\\Sentry\\BeforeSendMetricsCallback', + 'before_send_logs' => 'App\\Sentry\\BeforeSendLogsCallback', 'trace_propagation_targets' => ['website.invalid'], 'tags' => [ 'context' => 'development', diff --git a/tests/DependencyInjection/Fixtures/xml/full.xml b/tests/DependencyInjection/Fixtures/xml/full.xml index df951eb4..ba325880 100644 --- a/tests/DependencyInjection/Fixtures/xml/full.xml +++ b/tests/DependencyInjection/Fixtures/xml/full.xml @@ -13,6 +13,7 @@ 1, 'traces_sampler' => new Reference('App\\Sentry\\Tracing\\TracesSampler'), 'profiles_sample_rate' => 1, + 'enable_logs' => true, 'attach_stacktrace' => true, 'attach_metric_code_locations' => true, 'context_lines' => 0, @@ -228,6 +229,7 @@ public function testClientIsCreatedFromOptions(): void 'before_send_transaction' => new Reference('App\\Sentry\\BeforeSendTransactionCallback'), 'before_send_check_in' => new Reference('App\\Sentry\\BeforeSendCheckInCallback'), 'before_send_metrics' => new Reference('App\\Sentry\\BeforeSendMetricsCallback'), + 'before_send_logs' => new Reference('App\\Sentry\\BeforeSendLogsCallback'), 'trace_propagation_targets' => ['website.invalid'], 'tags' => [ 'context' => 'development',