Skip to content

Commit 187d364

Browse files
committed
Merge branch 'master' into develop
# Conflicts: # CHANGELOG.md # phpstan-baseline.neon # src/EventListener/ConsoleCommandListener.php # tests/DependencyInjection/SentryExtensionTest.php # tests/EventListener/ConsoleCommandListenerTest.php
2 parents 8f7a737 + 32fce0e commit 187d364

29 files changed

+326
-118
lines changed

.craft.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
minVersion: '0.9.0'
1+
minVersion: 0.9.0
22
github:
33
owner: getsentry
44
repo: sentry-symfony
55
changelogPolicy: simple
6-
statusProvider:
6+
statusProvider:
77
name: github
88
artifactProvider:
99
name: none

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; top-most EditorConfig file
2+
root = true
3+
4+
; Unix-style newlines
5+
[*]
6+
charset = utf-8
7+
end_of_line = LF
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.md]
14+
max_line_length = 80
15+
16+
[*.{yml, yaml}]
17+
indent_size = 2
18+
19+
[COMMIT_EDITMSG]
20+
max_line_length = 0
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: Version to release
8+
required: true
9+
force:
10+
description: Force a release even when there are release-blockers (optional)
11+
required: false
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
name: Release version
17+
steps:
18+
- uses: actions/checkout@v2
19+
with:
20+
token: ${{ secrets.GH_RELEASE_PAT }}
21+
fetch-depth: 0
22+
23+
- name: Prepare release
24+
uses: getsentry/action-prepare-release@v1
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
27+
with:
28+
version: ${{ github.event.inputs.version }}
29+
force: ${{ github.event.inputs.force }}

.github/workflows/static-analysis.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- master
8+
- develop
89
- 3.5.x
910

1011
jobs:

.github/workflows/tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- master
8+
- develop
89
- 3.5.x
910

1011
jobs:
@@ -44,6 +45,8 @@ jobs:
4445
name: PHP ${{ matrix.php }} tests (${{ matrix.description }})
4546
steps:
4647
- uses: actions/checkout@v2
48+
with:
49+
fetch-depth: 2
4750
- uses: actions/cache@v2
4851
with:
4952
path: ~/.composer/cache/files

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
- Added missing `capture-soft-fails` config schema option (#417)
99
- Deprecate the `Sentry\SentryBundle\EventListener\ConsoleCommandListener` class in favor of its parent class `Sentry\SentryBundle\EventListener\ConsoleListener` (#429)
1010

11+
## 4.0.3 (2021-03-03)
12+
- Fix regression from #454 for `null` value on DSN not disabling Sentry (#457)
13+
14+
## 4.0.2 (2021-03-03)
15+
16+
- Add `kernel.project_dir` to `prefixes` default value to trim paths to the project root (#434)
17+
- Fix `null`, `false` or empty value not disabling Sentry (#454)
18+
19+
## 4.0.1 (2021-01-26)
20+
21+
- Add missing `capture-soft-fails` option to the XSD schema for the XML config (#417)
22+
- Fix regression that send PII even when the `send_default_pii` option is off (#425)
23+
- Fix capture of console errors when the `register_error_listener` option is disabled (#427)
24+
1125
## 4.0.0 (2021-01-19)
1226

1327
**Breaking Change**: This version uses the [envelope endpoint](https://develop.sentry.dev/sdk/envelopes/). If you are
@@ -38,7 +52,7 @@ using an on-premise installation it requires Sentry version `>= v20.6.0` to work
3852

3953
- Use `jean85/pretty-package-versions` `^1.5` to leverage the new `getRootPackageVersion` method (c8799ac)
4054
- Fix support for PHP preloading (#354, thanks to @annuh)
41-
- Fix `capture_soft_fails: false` option for the Messenger (#353)
55+
- Fix `capture_soft_fails: false` option for the Messenger (#353)
4256

4357
## 3.5.1 (2020-05-07)
4458

README.md

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -22,53 +22,58 @@ Use `sentry-symfony` for:
2222
- app path
2323
- excluded paths (cache and vendor)
2424

25-
## Installation with Symfony Flex (Symfony 4 or newer):
26-
If you're using the [Symfony Flex](https://symfony.com/doc/current/setup/flex.html) Composer plugin, you can install this bundle in a single, easy step:
25+
## Installation
26+
27+
To install the SDK you will need to be using [Composer]([https://getcomposer.org/)
28+
in your project. To install it please see the [docs](https://getcomposer.org/download/).
29+
2730
```bash
2831
composer require sentry/sentry-symfony
2932
```
30-
This could show a message similar to this:
33+
34+
If you're using the [Symfony Flex](https://symfony.com/doc/current/setup/flex.html) Composer plugin, it could show a message similar to this:
35+
3136
```
32-
The recipe for this package comes from the "contrib" repository, which is open to community contributions.
33-
Review the recipe at https://github.com/symfony/recipes-contrib/tree/master/sentry/sentry-symfony/3.0
37+
The recipe for this package comes from the "contrib" repository, which is open to community contributions.
38+
Review the recipe at https://github.com/symfony/recipes-contrib/tree/master/sentry/sentry-symfony/3.0
3439
35-
Do you want to execute this recipe?
40+
Do you want to execute this recipe?
3641
```
37-
Press `y` and return to allow the installation.
3842

39-
## Installation without Symfony Flex:
40-
### Step 1: Download the Bundle
41-
You can install this bundle using Composer:
43+
Just type `y`, press return, and the procedure will continue.
4244

43-
```bash
44-
composer require sentry/sentry-symfony
45+
**Warning:** due to a bug in all versions lower than `6.0` of the [`SensioFrameworkExtra`](https://github.com/sensiolabs/SensioFrameworkExtraBundle) bundle,
46+
if you have it installed you will likely get an error during the execution of the commands above in regards to the missing `Nyholm\Psr7\Factory\Psr17Factory`
47+
class. To workaround the issue, if you are not using the PSR-7 bridge, please change the configuration of that bundle as follows:
48+
49+
```yaml
50+
sensio_framework_extra:
51+
psr_message:
52+
enabled: false
4553
```
4654
55+
For more details about the issue see https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/710.
56+
4757
### Step 2: Enable the Bundle
4858
49-
Then, enable the bundle by adding it to the list of registered bundles
50-
in the `app/AppKernel.php` file of your project:
59+
If you installed the package using the Flex recipe, the bundle will be automatically enabled. Otherwise, enable it by adding it to the list
60+
of registered bundles in the `Kernel.php` file of your project:
5161

5262
```php
53-
<?php
54-
// app/AppKernel.php
55-
56-
// ...
57-
class AppKernel extends Kernel
63+
class AppKernel extends \Symfony\Component\HttpKernel\Kernel
5864
{
59-
public function registerBundles()
65+
public function registerBundles(): array
6066
{
61-
$bundles = [
67+
return [
6268
// ...
6369
new \Sentry\SentryBundle\SentryBundle(),
6470
];
65-
66-
// ...
6771
}
6872
6973
// ...
7074
}
7175
```
76+
7277
Note that, unlike before in version 3, the bundle will be enabled in all environments; event reporting, instead, is enabled
7378
only when providing a DSN (see the next step).
7479

@@ -92,43 +97,6 @@ The parameter `options` allows to fine-tune exceptions. To discover more options
9297
[the Unified APIs](https://docs.sentry.io/development/sdk-dev/unified-api/#options) options and
9398
the [PHP specific](https://docs.sentry.io/platforms/php/#php-specific-options) ones.
9499

95-
#### Optional: use monolog handler provided by `sentry/sentry` (available since 3.2.0)
96-
*Note: this step is optional*
97-
98-
If you're using `monolog` for logging e.g. in-app errors, you
99-
can use this handler in order for them to show up in Sentry.
100-
101-
First, enable & configure the `Sentry\Monolog\Handler`; you'll also need
102-
to disable the `Sentry\SentryBundle\EventListener\ErrorListener` to
103-
avoid having duplicate events in Sentry:
104-
105-
```yaml
106-
sentry:
107-
register_error_listener: false # Disables the ErrorListener
108-
monolog:
109-
error_handler:
110-
enabled: true
111-
level: error
112-
```
113-
114-
Then enable it in `monolog` config:
115-
116-
```yaml
117-
monolog:
118-
handlers:
119-
sentry:
120-
type: service
121-
id: Sentry\Monolog\Handler
122-
```
123-
124-
Additionally, you can register the `PsrLogMessageProcessor` to resolve PSR-3 placeholders in reported messages:
125-
126-
```yaml
127-
services:
128-
Monolog\Processor\PsrLogMessageProcessor:
129-
tags: { name: monolog.processor, handler: sentry }
130-
```
131-
132100
#### Optional: use custom HTTP factory/transport
133101

134102
Since SDK 2.0 uses HTTPlug to remain transport-agnostic, you need to have installed two packages that provides

UPGRADE-4.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ using an on-premise installation it requires Sentry version `>= v20.6.0` to work
140140
```yaml
141141
sentry:
142142
options:
143-
before_send: 'app.sentry.before_breadcrumb'
143+
before_breadcrumb: 'app.sentry.before_breadcrumb'
144144
```
145145

146146
- 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.

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ parameters:
167167

168168
-
169169
message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent not found\\.$#"
170-
count: 6
170+
count: 8
171171
path: tests/EventListener/RequestListenerTest.php
172172

173173
-

psalm-baseline.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.3.0@6f916553a8de3c5c2483162b6cc01b21b24e4d1d">
2+
<files psalm-version="4.6.1@e93e532e4eaad6d68c4d7b606853800eaceccc72">
33
<file src="src/EventListener/ConsoleCommandListener.php">
44
<InvalidExtendClass occurrences="1">
55
<code>ConsoleListener</code>
66
</InvalidExtendClass>
7-
<MethodSignatureMismatch occurrences="1">
8-
<code>public function __construct(HubInterface $hub)</code>
9-
</MethodSignatureMismatch>
10-
</file>
11-
<file src="src/Tracing/Doctrine/DBAL/TracingDriver.php">
12-
<TooManyArguments occurrences="1">
13-
<code>getSchemaManager</code>
14-
</TooManyArguments>
15-
<UndefinedClass occurrences="1">
16-
<code>ExceptionConverter</code>
17-
</UndefinedClass>
7+
<MethodSignatureMismatch occurrences="1"/>
188
</file>
199
</files>

src/DependencyInjection/Configuration.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ public function getConfigTreeBuilder(): TreeBuilder
3030
$rootNode
3131
->children()
3232
->scalarNode('dsn')
33-
->beforeNormalization()
34-
->ifTrue(static function ($value): bool {
35-
return empty($value) || (\is_string($value) && '' === trim($value));
36-
})
37-
->thenUnset()
38-
->end()
33+
->info('If this value is not provided, the SDK will try to read it from the SENTRY_DSN environment variable. If that variable also does not exist, the SDK will just not send any events.')
3934
->end()
4035
->booleanNode('register_error_listener')->defaultTrue()->end()
4136
->arrayNode('options')
@@ -51,6 +46,7 @@ public function getConfigTreeBuilder(): TreeBuilder
5146
->booleanNode('default_integrations')->end()
5247
->integerNode('send_attempts')->min(0)->end()
5348
->arrayNode('prefixes')
49+
->defaultValue(array_merge(['%kernel.project_dir%'], array_filter(explode(\PATH_SEPARATOR, get_include_path() ?: ''))))
5450
->scalarPrototype()->end()
5551
->end()
5652
->floatNode('sample_rate')

src/DependencyInjection/SentryExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Sentry\Integration\RequestFetcherInterface;
1515
use Sentry\Integration\RequestIntegration;
1616
use Sentry\Options;
17+
use Sentry\SentryBundle\EventListener\ConsoleListener;
1718
use Sentry\SentryBundle\EventListener\ErrorListener;
1819
use Sentry\SentryBundle\EventListener\MessengerListener;
1920
use Sentry\SentryBundle\SentryBundle;
@@ -73,7 +74,7 @@ private function registerConfiguration(ContainerBuilder $container, array $confi
7374
{
7475
$options = $config['options'];
7576

76-
if (isset($config['dsn'])) {
77+
if (\array_key_exists('dsn', $config)) {
7778
$options['dsn'] = $config['dsn'];
7879
}
7980

@@ -140,6 +141,8 @@ private function registerErrorListenerConfiguration(ContainerBuilder $container,
140141
if (!$config['register_error_listener']) {
141142
$container->removeDefinition(ErrorListener::class);
142143
}
144+
145+
$container->getDefinition(ConsoleListener::class)->setArgument(1, $config['register_error_listener']);
143146
}
144147

145148
/**

src/EventListener/ConsoleCommandListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
*/
1212
final class ConsoleCommandListener extends ConsoleListener
1313
{
14-
public function __construct(HubInterface $hub)
14+
public function __construct(HubInterface $hub, bool $captureErrors = true)
1515
{
16-
parent::__construct($hub);
16+
parent::__construct($hub, $captureErrors);
1717

1818
@trigger_error(sprintf('The "%s" class is deprecated since version 4.1 and will be removed in 5.0. Use "%s" instead.', self::class, ConsoleListener::class), \E_USER_DEPRECATED);
1919
}

src/EventListener/ConsoleListener.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ class ConsoleListener
2323
*/
2424
private $hub;
2525

26+
/**
27+
* @var bool Whether to capture console errors
28+
*/
29+
private $captureErrors;
30+
2631
/**
2732
* Constructor.
2833
*
29-
* @param HubInterface $hub The current hub
34+
* @param HubInterface $hub The current hub
35+
* @param bool $captureErrors Whether to capture console errors
3036
*/
31-
public function __construct(HubInterface $hub)
37+
public function __construct(HubInterface $hub, bool $captureErrors = true)
3238
{
3339
$this->hub = $hub;
40+
$this->captureErrors = $captureErrors;
3441
}
3542

3643
/**
@@ -68,7 +75,9 @@ public function handleConsoleErrorEvent(ConsoleErrorEvent $event): void
6875
$this->hub->configureScope(function (Scope $scope) use ($event): void {
6976
$scope->setTag('console.command.exit_code', (string) $event->getExitCode());
7077

71-
$this->hub->captureException($event->getError());
78+
if ($this->captureErrors) {
79+
$this->hub->captureException($event->getError());
80+
}
7281
});
7382
}
7483
}

src/EventListener/RequestListener.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public function handleKernelRequestEvent(RequestListenerRequestEvent $event): vo
5151
return;
5252
}
5353

54+
$client = $this->hub->getClient();
55+
56+
if (null === $client || !$client->getOptions()->shouldSendDefaultPii()) {
57+
return;
58+
}
59+
5460
$token = null;
5561
$userData = UserDataBag::createFromUserIpAddress($event->getRequest()->getClientIp());
5662

0 commit comments

Comments
 (0)