File tree Expand file tree Collapse file tree 7 files changed +39
-12
lines changed Expand file tree Collapse file tree 7 files changed +39
-12
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ parameters:
9
9
- '/Parameter \$.+ of method Sentry\\SentryBundle\\EventListener\\ErrorListener::onConsoleException\ (\ ) has invalid typehint type Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent./'
10
10
- '/Call to method getException\ (\ ) on an unknown class Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent./'
11
11
- '/Access to undefined constant Symfony\\Component\\Console\\ConsoleEvents::EXCEPTION./'
12
+ - '/Sentry\\SentrySdk/'
12
13
13
14
includes :
14
15
- vendor/jangregor/phpstan-prophecy/src/extension.neon
Original file line number Diff line number Diff line change 2
2
3
3
namespace Sentry \SentryBundle \Command ;
4
4
5
- use Sentry \State \ Hub ;
5
+ use Sentry \SentryBundle \ SentryBundle ;
6
6
use Symfony \Component \Console \Command \Command ;
7
7
use Symfony \Component \Console \Input \InputInterface ;
8
8
use Symfony \Component \Console \Output \OutputInterface ;
@@ -16,7 +16,7 @@ public function __construct()
16
16
17
17
protected function execute (InputInterface $ input , OutputInterface $ output ): int
18
18
{
19
- $ currentHub = Hub:: getCurrent ();
19
+ $ currentHub = SentryBundle:: getCurrentHub ();
20
20
$ client = $ currentHub ->getClient ();
21
21
22
22
if (! $ client ) {
Original file line number Diff line number Diff line change 2
2
3
3
namespace Sentry \SentryBundle \EventListener ;
4
4
5
+ use Sentry \SentryBundle \SentryBundle ;
5
6
use Sentry \State \Hub ;
6
7
use Sentry \State \HubInterface ;
7
8
use Sentry \State \Scope ;
@@ -33,7 +34,7 @@ public function onConsoleCommand(ConsoleCommandEvent $event): void
33
34
{
34
35
$ command = $ event ->getCommand ();
35
36
36
- Hub:: getCurrent ()
37
+ SentryBundle:: getCurrentHub ()
37
38
->configureScope (function (Scope $ scope ) use ($ command ): void {
38
39
$ scope ->setTag ('command ' , $ command ? $ command ->getName () : 'N/A ' );
39
40
});
Original file line number Diff line number Diff line change 2
2
3
3
namespace Sentry \SentryBundle \EventListener ;
4
4
5
+ use Sentry \SentryBundle \SentryBundle ;
5
6
use Sentry \State \Hub ;
6
7
use Sentry \State \HubInterface ;
7
8
use Sentry \State \Scope ;
@@ -54,7 +55,7 @@ public function onKernelRequest(GetResponseEvent $event): void
54
55
return ;
55
56
}
56
57
57
- $ currentClient = Hub:: getCurrent ()->getClient ();
58
+ $ currentClient = SentryBundle:: getCurrentHub ()->getClient ();
58
59
if (null === $ currentClient || ! $ currentClient ->getOptions ()->shouldSendDefaultPii ()) {
59
60
return ;
60
61
}
@@ -76,7 +77,7 @@ public function onKernelRequest(GetResponseEvent $event): void
76
77
77
78
$ userData ['ip_address ' ] = $ event ->getRequest ()->getClientIp ();
78
79
79
- Hub:: getCurrent ()
80
+ SentryBundle:: getCurrentHub ()
80
81
->configureScope (function (Scope $ scope ) use ($ userData ): void {
81
82
$ scope ->setUser ($ userData );
82
83
});
@@ -94,7 +95,7 @@ public function onKernelController(FilterControllerEvent $event): void
94
95
95
96
$ matchedRoute = (string ) $ event ->getRequest ()->attributes ->get ('_route ' );
96
97
97
- Hub:: getCurrent ()
98
+ SentryBundle:: getCurrentHub ()
98
99
->configureScope (function (Scope $ scope ) use ($ matchedRoute ): void {
99
100
$ scope ->setTag ('route ' , $ matchedRoute );
100
101
});
Original file line number Diff line number Diff line change 2
2
3
3
namespace Sentry \SentryBundle \EventListener ;
4
4
5
- use Sentry \State \ Hub ;
5
+ use Sentry \SentryBundle \ SentryBundle ;
6
6
use Symfony \Component \HttpKernel \Event \FinishRequestEvent ;
7
7
use Symfony \Component \HttpKernel \Event \GetResponseEvent ;
8
8
@@ -19,7 +19,7 @@ public function onKernelRequest(GetResponseEvent $event): void
19
19
return ;
20
20
}
21
21
22
- Hub:: getCurrent ()->pushScope ();
22
+ SentryBundle:: getCurrentHub ()->pushScope ();
23
23
}
24
24
25
25
/**
@@ -33,6 +33,6 @@ public function onKernelFinishRequest(FinishRequestEvent $event): void
33
33
return ;
34
34
}
35
35
36
- Hub:: getCurrent ()->popScope ();
36
+ SentryBundle:: getCurrentHub ()->popScope ();
37
37
}
38
38
}
Original file line number Diff line number Diff line change 17
17
18
18
<service id =" Sentry\State\HubInterface" class =" Sentry\State\Hub" public =" false" >
19
19
<argument type =" service" id =" Sentry\ClientInterface" />
20
- <call method =" setCurrent" >
21
- <argument type =" service" id =" Sentry\State\HubInterface" />
22
- </call >
23
20
</service >
24
21
25
22
<service id =" Sentry\SentryBundle\EventListener\ConsoleListener" class =" Sentry\SentryBundle\EventListener\ConsoleListener" public =" false" >
Original file line number Diff line number Diff line change 3
3
namespace Sentry \SentryBundle ;
4
4
5
5
use Jean85 \PrettyVersions ;
6
+ use Sentry \SentrySdk ;
7
+ use Sentry \State \Hub ;
8
+ use Sentry \State \HubInterface ;
6
9
use Symfony \Component \HttpKernel \Bundle \Bundle ;
7
10
8
11
class SentryBundle extends Bundle
@@ -14,4 +17,28 @@ public static function getSdkVersion(): string
14
17
return PrettyVersions::getVersion ('sentry/sentry-symfony ' )
15
18
->getPrettyVersion ();
16
19
}
20
+
21
+ /**
22
+ * This method avoids deprecations with sentry/sentry:^2.2
23
+ */
24
+ public static function getCurrentHub (): HubInterface
25
+ {
26
+ if (class_exists (SentrySdk::class)) {
27
+ return SentrySdk::getCurrentHub ();
28
+ }
29
+
30
+ return Hub::getCurrent ();
31
+ }
32
+
33
+ /**
34
+ * This method avoids deprecations with sentry/sentry:^2.2
35
+ */
36
+ public static function setCurrentHub (HubInterface $ hub ): void
37
+ {
38
+ if (class_exists (SentrySdk::class)) {
39
+ SentrySdk::setCurrentHub ($ hub );
40
+ }
41
+
42
+ Hub::setCurrent ($ hub );
43
+ }
17
44
}
You can’t perform that action at this time.
0 commit comments