Skip to content

Commit c95a2bd

Browse files
ste93cryJean85
andauthored
Refactor the bundle configuration and add support for XML format (#401)
* Refactor the bundle configuration * Fix CR issues and broken build * Skip Symfony Messenger related test if package is not installed * Fix broken build and bump minimum required SDK version * Add missing test for the TransportFactory class * Fix CR issues * Update the README Co-authored-by: Alessandro Lai <[email protected]>
1 parent f7ef17c commit c95a2bd

File tree

62 files changed

+1764
-1388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1764
-1388
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
- [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)
88
- [BC BREAK] Removed the `options.excluded_exceptions` configuration option. Instead of setting it, configure the `IgnoreErrorsIntegration` integration (#385)
99
- [BC BREAK] Refactorized the `ConsoleCommandListener`, `ErrorListener`, `RequestListener` and `SubRequestListener` event listeners (#387)
10-
- CLI commands registration policy changed to lazy load
10+
- Registered the CLI commands as lazy services (#373)
11+
- [BC BREAK] Refactorized the configuration tree and the definitions of some container services (#401)
12+
- Support the XML format for the bundle configuration (#401)
1113
- PHP 8 support (#399, thanks to @Yozhef)
1214

1315
## 3.5.3 (2020-10-13)

README.md

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -159,44 +159,16 @@ composer require pugx/sentry-sdk
159159
```
160160

161161
## Maintained versions
162-
* 3.x is actively maintained and developed on the master branch, and uses Sentry SDK 2.0;
163-
* 2.x is supported only for fixes; from this version onwards it requires Symfony 3+ and PHP 7.1+;
162+
163+
* 4.x is actively maintained and developed on the master branch, and uses Sentry SDK 3.0;
164+
* 3.x is supported only for fixes and uses Sentry SDK 2.0;
165+
* 2.x is no longer maintained; from this version onwards it requires Symfony 3+ and PHP 7.1+;
164166
* 1.x is no longer maintained; you can use it for Symfony < 2.8 and PHP 5.6/7.0;
165167
* 0.8.x is no longer maintained.
166168

167-
### Upgrading to 3.0
168-
The 3.0 version of the bundle uses the newest version (2.x) of the underlying Sentry SDK. If you need to migrate from previous versions, please check the `UPGRADE-3.0.md` document.
169-
170-
## Customization
171-
172-
The Sentry 2.0 SDK uses the Unified API, hence it uses the concept of `Scope`s to hold information about the current
173-
state of the app, and attach it to any event that is reported. This bundle has three listeners (`RequestListener`,
174-
`SubRequestListener` and `ConsoleListener`) that adds some easy default information. Since 3.5, a fourth listener has been added to handle the case of Messenger Workers: `MessengerListener`.
175-
176-
Those listeners normally are executed with a priority of `1` to allow easier customization with custom listener, that by
177-
default run with a lower priority of `0`.
178-
179-
Those listeners are `final` so not extendable, but you can look at those to know how to add more information to the
180-
current `Scope` and enrich you Sentry events.
181-
182-
183-
#### Services configuration
169+
### Upgrading to 4.0
184170

185-
Services registered by the bundle (the `ClientBuilder` in the example below) can be configured in several ways, one of them is by using a [compiler pass](https://symfony.com/doc/current/service_container/compiler_passes.html):
186-
187-
```php
188-
final class SentryCustomizationCompilerPass implements CompilerPassInterface
189-
{
190-
public function process(ContainerBuilder $containerBuilder): void
191-
{
192-
// Example - setting own serializer to Sentry\ClientBuilder
193-
$containerBuilder->getDefinition(ClientBuilderInterface::class)
194-
->addMethodCall('setSerializer', [
195-
new Reference(MyCustomSerializer::class),
196-
]);
197-
}
198-
}
199-
```
171+
The 4.0 version of the bundle uses the newest version (3.x) of the underlying Sentry SDK. If you need to migrate from previous versions, please check the `UPGRADE-4.0.md` document.
200172

201173
#### Custom serializers
202174

@@ -205,7 +177,7 @@ The option class_serializers can be used to send customized objects serializatio
205177
sentry:
206178
options:
207179
class_serializers:
208-
YourValueObject: '@ValueObjectSerializer'
180+
YourValueObject: 'ValueObjectSerializer'
209181
```
210182

211183
Several serializers can be added and the serializable check is done using **instanceof**. The serializer must implements the `__invoke` method returning an **array** with the information to send to sentry (class name is always sent).

UPGRADE-4.0.md

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
- Renamed the `RequestListener::onKernelController` method to `RequestListener::handleKernelControllerEvent`.
1111
- Renamed the `SubRequestListener::onKernelRequest` method to `SubRequestListener::handleKernelRequestEvent`.
1212
- Renamed the `SubRequestListener::onKernelFinishRequest` method to `SubRequestListener::handleKernelFinishRequestEvent`.
13-
- Removed the `sentry.listener_priorities.console` configuration option.
1413
- Removed the `Sentry\FlushableClientInterface` service alias.
1514
- Removed the `sentry.options.excluded_exceptions` configuration option.
1615

@@ -41,3 +40,123 @@
4140
4241
- Changed the default value of the `sentry.listener_priorities.console_error` configuration option to `-64`.
4342
- Changed the default value of the `sentry.listener_priorities.console` configuration option to `128`.
43+
- Changed the default value of the `sentry.listener_priorities.worker_error` configuration option to `50`.
44+
- Changed the type of the `sentry.options.before_send` configuration option from `scalar` to `string`. The value must always be the name of the container service to call without the `@` prefix.
45+
46+
Before
47+
48+
```yaml
49+
sentry:
50+
options:
51+
before_send: '@app.sentry.before_send'
52+
```
53+
54+
```yaml
55+
sentry:
56+
options:
57+
before_send: 'App\Sentry\BeforeSend::__invoke'
58+
```
59+
60+
```yaml
61+
sentry:
62+
options:
63+
before_send: ['App\Sentry\BeforeSend', '__invoke']
64+
```
65+
66+
After
67+
68+
```yaml
69+
sentry:
70+
options:
71+
before_send: 'app.sentry.before_send'
72+
```
73+
74+
- Changed the type of the `sentry.options.before_breadcrumb` configuration option from `scalar` to `string`. The value must always be the name of the container service to call without the `@` prefix.
75+
76+
Before
77+
78+
```yaml
79+
sentry:
80+
options:
81+
before_breadcrumb: '@app.sentry.before_breadcrumb'
82+
```
83+
84+
```yaml
85+
sentry:
86+
options:
87+
before_breadcrumb: 'App\Sentry\BeforeBreadcrumb::__invoke'
88+
```
89+
90+
```yaml
91+
sentry:
92+
options:
93+
before_breadcrumb: ['App\Sentry\BeforeBreadcrumb', '__invoke']
94+
```
95+
96+
After
97+
98+
```yaml
99+
sentry:
100+
options:
101+
before_send: 'app.sentry.before_breadcrumb'
102+
```
103+
104+
- Changed the type of the `sentry.options.class_serializers` configuration option from an array of `scalar` values to an array of `string` values. The value must always be the name of the container service to call without the `@` prefix.
105+
106+
Before
107+
108+
```yaml
109+
sentry:
110+
options:
111+
class_serializers:
112+
App\FooClass: '@app.sentry.foo_class_serializer'
113+
```
114+
115+
```yaml
116+
sentry:
117+
options:
118+
class_serializers:
119+
App\FooClass: 'App\Sentry\FooClassSerializer::__invoke'
120+
```
121+
122+
```yaml
123+
sentry:
124+
options:
125+
class_serializers:
126+
App\FooClass: ['App\Sentry\FooClassSerializer', 'invoke']
127+
```
128+
129+
After
130+
131+
```yaml
132+
sentry:
133+
options:
134+
class_serializers:
135+
App\FooClass: 'app.sentry.foo_class_serializer'
136+
```
137+
138+
- Changed the type of the `sentry.options.integrations` configuration option from an array of `scalar` values to an array of `string` values. The value must always be the name of the container service to call without the `@` prefix.
139+
140+
Before
141+
142+
```yaml
143+
sentry:
144+
options:
145+
integrations:
146+
- '@app.sentry.foo_integration'
147+
```
148+
149+
After
150+
151+
```yaml
152+
sentry:
153+
options:
154+
integrations:
155+
- 'app.sentry.foo_integration'
156+
```
157+
158+
- Removed the `ClientBuilderConfigurator` class.
159+
- Removed the `SentryBundle::getSdkVersion()` method.
160+
- Removed `SentryBundle::getCurrentHub()` method, use `SentrySdk::getCurrentHub()` instead.
161+
- Removed the `Sentry\ClientBuilderInterface` and `Sentry\Options` services.
162+
- Refactorized the `ErrorTypesParser` class and made it `@internal`.

composer.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
"require": {
2222
"php": "^7.2||^8.0",
2323
"jean85/pretty-package-versions": "^1.5",
24-
"sentry/sdk": "^3.0",
25-
"symfony/config": "^3.4||^4.0||^5.0",
26-
"symfony/console": "^3.4||^4.0||^5.0",
27-
"symfony/dependency-injection": "^3.4||^4.0||^5.0",
28-
"symfony/event-dispatcher": "^3.4||^4.0||^5.0",
29-
"symfony/http-kernel": "^3.4||^4.0||^5.0",
30-
"symfony/security-core": "^3.4||^4.0||^5.0"
24+
"php-http/discovery": "^1.11",
25+
"sentry/sdk": "^3.1",
26+
"symfony/config": "^3.4.43||^4.4.11||^5.0.11",
27+
"symfony/console": "^3.4.43||^4.4.11||^5.0.11",
28+
"symfony/dependency-injection": "^3.4.43||^4.4.11||^5.0.11",
29+
"symfony/event-dispatcher": "^3.4.43||^4.4.11||^5.0.11",
30+
"symfony/http-kernel": "^3.4.43||^4.4.11||^5.0.11",
31+
"symfony/security-core": "^3.4.43||^4.4.11||^5.0.11"
3132
},
3233
"require-dev": {
3334
"friendsofphp/php-cs-fixer": "^2.17",
@@ -39,12 +40,12 @@
3940
"phpstan/phpstan": "^0.12",
4041
"phpstan/phpstan-phpunit": "^0.12",
4142
"phpunit/phpunit": "^8.5||^9.0",
42-
"symfony/browser-kit": "^3.4||^4.0||^5.0",
43-
"symfony/framework-bundle": "^3.4.23||^4.0||^5.0",
44-
"symfony/messenger": "^4.3||^5.0",
43+
"symfony/browser-kit": "^3.4.43||^4.4.11||^5.0.11",
44+
"symfony/framework-bundle": "^3.4.43||^4.4.11||^5.0.11",
45+
"symfony/messenger": "^4.4.11||^5.0.11",
4546
"symfony/monolog-bundle": "^3.4",
4647
"symfony/phpunit-bridge": "^5.0",
47-
"symfony/yaml": "^3.4||^4.0||^5.0"
48+
"symfony/yaml": "^3.4.43||^4.4.11||^5.0.11"
4849
},
4950
"suggest": {
5051
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."

0 commit comments

Comments
 (0)