Skip to content

Commit a28795f

Browse files
authored
Update the dependencies and require the SDK 3.x (#385)
1 parent a07d87e commit a28795f

19 files changed

+209
-146
lines changed

.github/workflows/tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
runs-on: ubuntu-latest
1313
continue-on-error: ${{ matrix.experimental == true }}
1414
strategy:
15+
fail-fast: false
1516
matrix:
1617
php:
1718
- '7.4'
1819
- '7.3'
1920
- '7.2'
20-
- '7.1'
2121
sentry_constraint: [false]
2222
symfony_constraint: [false]
2323
experimental: [false]
@@ -30,12 +30,12 @@ jobs:
3030
php: '7.3'
3131
symfony_constraint: 4.4.*
3232
- description: 'Symfony 3.4'
33-
php: '7.1'
33+
php: '7.2'
3434
symfony_constraint: 3.4.*
3535
env:
3636
SYMFONY_DEPRECATIONS_HELPER: disabled
3737
- description: 'prefer lowest'
38-
php: '7.1'
38+
php: '7.2'
3939
composer_option: '--prefer-lowest'
4040
symfony_constraint: 3.4.*
4141
env:
@@ -47,7 +47,7 @@ jobs:
4747
- uses: actions/cache@v2
4848
with:
4949
path: ~/.composer/cache/files
50-
key: ${{ matrix.php }}-${{ matrix.symfony_constraint }}-${{ matrix.composer_option }}
50+
key: ${{ matrix.php }}-${{ matrix.symfony_constraint }}-${{ matrix.composer_option }}
5151
- uses: shivammathur/setup-php@v2
5252
with:
5353
php-version: ${{ matrix.php }}

CHANGELOG.md

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,103 @@
11
# Changelog
2-
All notable changes to this project will be documented in this file.
3-
4-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
62

73
## Unreleased
8-
- CLI commands registration policy changed to lazy load
4+
5+
- Enable back all error listeners from base SDK integration (#322)
6+
- Added `options.traces_sampler` and `options.traces_sample_rate` configuration options (#385)
7+
- [BC BREAK] Removed the `options.project_root` configuration option. Instead of setting it, use a combination of `options.in_app_include` and `options.in_app_exclude` (#385)
8+
- [BC BREAK] Removed the `options.excluded_exceptions` configuration option. Instead of setting it, configure the `IgnoreErrorsIntegration` integration (#385)
9+
- CLI commands registration policy changed to lazy load
910

1011
## 3.5.3 (2020-10-13)
11-
- Refactors and fixes class aliases for more robustness (#315 #359, thanks to @guilliamxavier)
12+
13+
- Refactors and fixes class aliases for more robustness (#315 #359, thanks to @guilliamxavier)
1214

1315
## 3.5.2 (2020-07-08)
14-
- Use `jean85/pretty-package-versions` `^1.5` to leverage the new `getRootPackageVersion` method (c8799ac)
15-
- Fix support for PHP preloading (#354, thanks to @annuh)
16-
- Fix `capture_soft_fails: false` option for the Messenger (#353)
1716

18-
## 4.0.0 (TBA)
19-
- Enable back all error listeners from base SDK integration (#322)
17+
- Use `jean85/pretty-package-versions` `^1.5` to leverage the new `getRootPackageVersion` method (c8799ac)
18+
- Fix support for PHP preloading (#354, thanks to @annuh)
19+
- Fix `capture_soft_fails: false` option for the Messenger (#353)
2020

2121
## 3.5.1 (2020-05-07)
22-
- Capture events using the `Hub` in the `MessengerListener` to avoid loosing `Scope` data (#339, thanks to @sh41)
23-
- Capture multiple events if multiple exceptions are generated in a Messenger Worker context (#340, thanks to @emarref)
22+
23+
- Capture events using the `Hub` in the `MessengerListener` to avoid loosing `Scope` data (#339, thanks to @sh41)
24+
- Capture multiple events if multiple exceptions are generated in a Messenger Worker context (#340, thanks to @emarref)
2425

2526
## 3.5.0 (2020-05-04)
26-
- Capture and flush messages in a Messenger Worker context (#326, thanks to @emarref)
27-
- Support Composer 2 (#335)
28-
- Avoid issues with dependency lower bound, fix #331 (#335)
27+
28+
- Capture and flush messages in a Messenger Worker context (#326, thanks to @emarref)
29+
- Support Composer 2 (#335)
30+
- Avoid issues with dependency lower bound, fix #331 (#335)
2931

3032
## 3.4.4 (2020-03-16)
31-
- Improve `release` option default value (#325)
33+
34+
- Improve `release` option default value (#325)
3235

3336
## 3.4.3 (2020-02-03)
34-
- Change default of `in_app_include` to empty, due to getsentry/sentry-php#958 (#311)
35-
- Improve class_alias robustness (#315)
37+
38+
- Change default of `in_app_include` to empty, due to getsentry/sentry-php#958 (#311)
39+
- Improve class_alias robustness (#315)
3640

3741
## 3.4.2 (2020-01-29)
38-
- Remove space from classname used with `class_alias` (#313)
42+
43+
- Remove space from classname used with `class_alias` (#313)
3944

4045
## 3.4.1 (2020-01-24)
41-
- Fix issue due to usage of `class_alias` to fix deprecations, which could break BC layers of third party packages (#309, thanks to @scheb)
46+
47+
- Fix issue due to usage of `class_alias` to fix deprecations, which could break BC layers of third party packages (#309, thanks to @scheb)
4248

4349
## 3.4.0 (2020-01-20)
44-
- Add support for `sentry/sentry` 2.3 (#298)
45-
- Drop support for `sentry/sentry` < 2.3 (#298)
46-
- Add support to `in_app_include` client option (#298)
47-
- Remap `excluded_exceptions` option to use the new `IgnoreErrorsIntegration` (#298)
50+
51+
- Add support for `sentry/sentry` 2.3 (#298)
52+
- Drop support for `sentry/sentry` < 2.3 (#298)
53+
- Add support to `in_app_include` client option (#298)
54+
- Remap `excluded_exceptions` option to use the new `IgnoreErrorsIntegration` (#298)
4855

4956
## 3.3.2 (2020-01-16)
50-
- Fix issue with exception listener under Symfony 4.3 (#301)
57+
58+
- Fix issue with exception listener under Symfony 4.3 (#301)
5159

5260
## 3.3.1 (2020-01-14)
53-
- Fixed Release
61+
62+
- Fixed Release
5463

5564
## 3.3.0 (2020-01-14)
56-
- Add support for Symfony 5.0 (#266, thanks to @Big-Shark)
57-
- Drop support for Symfony < 3.4 (#277)
58-
- Add default value for the `release` option, using the detected root package version (#291 #292, thanks to @Ocramius)
65+
66+
- Add support for Symfony 5.0 (#266, thanks to @Big-Shark)
67+
- Drop support for Symfony < 3.4 (#277)
68+
- Add default value for the `release` option, using the detected root package version (#291 #292, thanks to @Ocramius)
5969

6070
## 3.2.1 (2019-12-19)
61-
- Fix handling of command with no name on `ConsoleListener` (#261)
62-
- Remove check by AuthorizationChecker in `RequestListener` (#264)
63-
- Fixed undefined variable in `RequestListener` (#263)
71+
72+
- Fix handling of command with no name on `ConsoleListener` (#261)
73+
- Remove check by AuthorizationChecker in `RequestListener` (#264)
74+
- Fixed undefined variable in `RequestListener` (#263)
6475

6576
## 3.2.0 (2019-10-04)
66-
- Add forward compatibility with Symfony 5 (#235, thanks to @garak)
67-
- Fix Hub initialization for `ErrorListener` (#243, thanks to @teohhanhui)
68-
- Fix compatibility with sentry/sentry 2.2+ (#244)
69-
- Add support for `class_serializers` option (#245)
70-
- Add support for `max_request_body_size` option (#249)
71-
- Add option to disable the error listener completely (#247, thanks to @HypeMC)
72-
- Add options to register the Monolog Handler (#247, thanks to @HypeMC)
77+
78+
- Add forward compatibility with Symfony 5 (#235, thanks to @garak)
79+
- Fix Hub initialization for `ErrorListener` (#243, thanks to @teohhanhui)
80+
- Fix compatibility with sentry/sentry 2.2+ (#244)
81+
- Add support for `class_serializers` option (#245)
82+
- Add support for `max_request_body_size` option (#249)
83+
- Add option to disable the error listener completely (#247, thanks to @HypeMC)
84+
- Add options to register the Monolog Handler (#247, thanks to @HypeMC)
7385

7486
## 3.1.0 (2019-07-02)
75-
- Add support for Symfony 2.8 (#233, thanks to @nocive)
76-
- Fix handling of ESI requests (#213, thanks to @franmomu)
87+
88+
- Add support for Symfony 2.8 (#233, thanks to @nocive)
89+
- Fix handling of ESI requests (#213, thanks to @franmomu)
7790

7891
## 3.0.0 (2019-05-10)
79-
- Add the `sentry:test` command, to test if the Sentry SDK is functioning properly.
92+
93+
- Add the `sentry:test` command, to test if the Sentry SDK is functioning properly.
8094

8195
## 3.0.0-beta2 (2019-03-22)
82-
- Disable Sentry's ErrorHandler, and report all errors using Symfony's events (#204)
96+
97+
- Disable Sentry's ErrorHandler, and report all errors using Symfony's events (#204)
8398

8499
## 3.0.0-beta1 (2019-03-06)
100+
85101
The 3.0 major release has multiple breaking changes. The most notable one is the upgrade to the 2.0 base SDK client.
86102
Refer to the [UPGRADE-3.0.md](https://github.com/getsentry/sentry-symfony/blob/master/UPGRADE-3.0.md) document for a
87103
detailed explanation.

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ sentry:
8686
options:
8787
environment: '%kernel.environment%'
8888
release: '%env(VERSION)%' #your app version
89-
excluded_exceptions: #exclude validation errors
90-
- App\Exception\UserNotFoundException
91-
- Symfony\Component\Security\Core\Exception\AccessDeniedException
9289
```
9390
9491
The parameter `options` allows to fine-tune exceptions. To discover more options, please refer to

UPGRADE-4.0.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Upgrade 3.x to 4.0
2+
3+
- Removed the `sentry.options.excluded_exceptions` configuration option.
4+
5+
Before:
6+
7+
```yaml
8+
sentry:
9+
options:
10+
excluded_exceptions:
11+
- RuntimeException
12+
```
13+
14+
After:
15+
16+
```yaml
17+
sentry:
18+
integrations:
19+
- '@Sentry\Integration\IgnoreErrorsIntegration'
20+
21+
services:
22+
Sentry\Integration\IgnoreErrorsIntegration:
23+
arguments:
24+
$options:
25+
ignore_exceptions:
26+
- RuntimeException
27+
```

composer.json

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require": {
2222
"php": "^7.1",
2323
"jean85/pretty-package-versions": "^1.5",
24-
"sentry/sdk": "^2.1",
24+
"sentry/sdk": "^3.0",
2525
"symfony/config": "^3.4||^4.0||^5.0",
2626
"symfony/console": "^3.4||^4.0||^5.0",
2727
"symfony/dependency-injection": "^3.4||^4.0||^5.0",
@@ -30,14 +30,14 @@
3030
"symfony/security-core": "^3.4||^4.0||^5.0"
3131
},
3232
"require-dev": {
33-
"friendsofphp/php-cs-fixer": "^2.8",
34-
"jangregor/phpstan-prophecy": "^0.6.2",
35-
"monolog/monolog": "^1.11||^2.0",
36-
"php-http/mock-client": "^1.0",
33+
"friendsofphp/php-cs-fixer": "^2.16",
34+
"jangregor/phpstan-prophecy": "^0.8",
35+
"monolog/monolog": "^1.3||^2.0",
36+
"php-http/mock-client": "^1.4",
3737
"phpspec/prophecy": "!=1.11.0",
3838
"phpstan/extension-installer": "^1.0",
39-
"phpstan/phpstan": "^0.12.19",
40-
"phpstan/phpstan-phpunit": "^0.12.8",
39+
"phpstan/phpstan": "^0.12",
40+
"phpstan/phpstan-phpunit": "^0.12",
4141
"phpunit/phpunit": "^7.5||^8.5",
4242
"symfony/browser-kit": "^3.4||^4.0||^5.0",
4343
"symfony/expression-language": "^3.4||^4.0||^5.0",
@@ -49,7 +49,7 @@
4949
"symfony/yaml": "^3.4||^4.0||^5.0"
5050
},
5151
"suggest": {
52-
"monolog/monolog": "Required to use the Monolog handler"
52+
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."
5353
},
5454
"autoload": {
5555
"psr-4": {
@@ -62,13 +62,19 @@
6262
}
6363
},
6464
"scripts": {
65-
"phpstan": "vendor/bin/phpstan analyse",
66-
"cs-check": "vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run",
67-
"cs-fix": "vendor/bin/php-cs-fixer fix --ansi --verbose"
65+
"tests": [
66+
"vendor/bin/phpunit --verbose"
67+
],
68+
"phpcs": [
69+
"vendor/bin/php-cs-fixer fix --verbose --diff --dry-run"
70+
],
71+
"phpstan": [
72+
"vendor/bin/phpstan analyse"
73+
]
6874
},
6975
"extra": {
7076
"branch-alias": {
71-
"master": "4.x-dev",
77+
"dev-master": "4.x-dev",
7278
"releases/3.2.x": "3.2.x-dev",
7379
"releases/2.x": "2.x-dev",
7480
"releases/1.x": "1.x-dev"

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ parameters:
229229
message: "#^Comparison operation \"\\>\\=\" between \\d+ and 40300 is always true\\.$#"
230230
count: 1
231231
path: test/End2End/App/Kernel.php
232-
233232
-
234233
message: "#^Class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Client not found\\.$#"
235234
count: 1
@@ -300,11 +299,6 @@ parameters:
300299
count: 1
301300
path: test/EventListener/RequestListenerTest.php
302301

303-
-
304-
message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:getUserContext\\(\\) return type has no value type specified in iterable type array\\.$#"
305-
count: 1
306-
path: test/EventListener/RequestListenerTest.php
307-
308302
-
309303
message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:getTagsContext\\(\\) return type has no value type specified in iterable type array\\.$#"
310304
count: 1

src/DependencyInjection/Configuration.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ public function getConfigTreeBuilder(): TreeBuilder
7979
'%kernel.project_dir%/vendor',
8080
])
8181
->prototype('scalar');
82-
$optionsChildNodes->arrayNode('excluded_exceptions')
83-
->defaultValue([])
84-
->prototype('scalar');
8582
$optionsChildNodes->scalarNode('http_proxy');
8683
$optionsChildNodes->arrayNode('integrations')
8784
->prototype('scalar')
@@ -109,7 +106,6 @@ public function getConfigTreeBuilder(): TreeBuilder
109106
$optionsChildNodes->arrayNode('prefixes')
110107
->defaultValue($defaultValues->getPrefixes())
111108
->prototype('scalar');
112-
$optionsChildNodes->scalarNode('project_root');
113109

114110
$releaseNode = $optionsChildNodes->scalarNode('release')
115111
->info('Release version to be reported to sentry, see https://docs.sentry.io/workflow/releases/?platform=php')
@@ -126,6 +122,13 @@ public function getConfigTreeBuilder(): TreeBuilder
126122
$optionsChildNodes->arrayNode('tags')
127123
->normalizeKeys(false)
128124
->prototype('scalar');
125+
$optionsChildNodes->scalarNode('traces_sampler')
126+
->validate()
127+
->ifTrue($this->isNotAValidCallback())
128+
->thenInvalid('Expecting callable or service reference, got %s');
129+
$optionsChildNodes->floatNode('traces_sample_rate')
130+
->min(0.0)
131+
->max(1.0);
129132

130133
// Bundle-specific configuration
131134
$listenerPriorities = $rootNode->children()

src/DependencyInjection/SentryExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ private function passConfigurationToOptions(ContainerBuilder $container, array $
7474
'max_breadcrumbs',
7575
'max_value_length',
7676
'prefixes',
77-
'project_root',
7877
'release',
7978
'sample_rate',
8079
'send_attempts',
8180
'send_default_pii',
8281
'server_name',
8382
'tags',
83+
'traces_sample_rate',
84+
'traces_sampler',
8485
];
8586

8687
foreach ($mappableOptions as $optionName) {
@@ -130,9 +131,8 @@ private function passConfigurationToOptions(ContainerBuilder $container, array $
130131
}
131132

132133
// we ignore fatal errors wrapped by Symfony because they produce double event reporting
133-
$processedOptions['excluded_exceptions'][] = FatalError::class;
134134
$ignoreOptions = [
135-
'ignore_exceptions' => $processedOptions['excluded_exceptions'],
135+
'ignore_exceptions' => [FatalError::class],
136136
];
137137

138138
$integrations[] = new Definition(IgnoreErrorsIntegration::class, [$ignoreOptions]);

src/EventListener/MessengerListener.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Sentry\SentryBundle\EventListener;
44

5-
use Sentry\FlushableClientInterface;
65
use Sentry\State\HubInterface;
76
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
87
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;
@@ -66,7 +65,7 @@ public function onWorkerMessageHandled(WorkerMessageHandledEvent $event): void
6665
private function flush(): void
6766
{
6867
$client = $this->hub->getClient();
69-
if ($client instanceof FlushableClientInterface) {
68+
if (null !== $client) {
7069
$client->flush();
7170
}
7271
}

src/EventListener/RequestListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function onKernelRequest(RequestListenerRequestEvent $event): void
9090

9191
SentrySdk::getCurrentHub()
9292
->configureScope(function (Scope $scope) use ($userData): void {
93-
$scope->setUser($userData, true);
93+
$scope->setUser($userData);
9494
});
9595
}
9696

0 commit comments

Comments
 (0)