1717use Flownative \Sentry \Context \UserContextServiceInterface ;
1818use Flownative \Sentry \Context \WithExtraDataInterface ;
1919use Flownative \Sentry \Log \CaptureResult ;
20- use GuzzleHttp \Psr7 \ServerRequest ;
21- use Jenssegers \Agent \Agent ;
2220use Neos \Flow \Annotations as Flow ;
2321use Neos \Flow \Core \Bootstrap ;
2422use Neos \Flow \Error \WithReferenceCodeInterface ;
3129use Neos \Flow \Utility \Environment ;
3230use Neos \Utility \Arrays ;
3331use Psr \Log \LoggerInterface ;
34- use Psr \Log \LogLevel ;
3532use Sentry \Event ;
3633use Sentry \EventHint ;
3734use Sentry \EventId ;
@@ -93,6 +90,10 @@ public function injectSettings(array $settings): void
9390
9491 public function initializeObject (): void
9592 {
93+ if (empty ($ this ->dsn )) {
94+ return ;
95+ }
96+
9697 $ representationSerializer = new RepresentationSerializer (
9798 new Options ([])
9899 );
@@ -102,10 +103,6 @@ public function initializeObject(): void
102103 $ representationSerializer
103104 );
104105
105- if (empty ($ this ->dsn )) {
106- return ;
107- }
108-
109106 \Sentry \init ([
110107 'dsn ' => $ this ->dsn ,
111108 'environment ' => $ this ->environment ,
@@ -118,8 +115,7 @@ public function initializeObject(): void
118115 FLOW_PATH_ROOT . '/Packages/Framework/Neos.Flow/Classes/Log/ ' ,
119116 FLOW_PATH_ROOT . '/Packages/Libraries/neos/flow-log/ '
120117 ],
121- 'default_integrations ' => false ,
122- 'attach_stacktrace ' => true
118+ 'attach_stacktrace ' => true ,
123119 ]);
124120
125121 $ client = SentrySdk::getCurrentHub ()->getClient ();
@@ -136,38 +132,18 @@ private function setTags(): void
136132 try {
137133 $ flowPackage = $ this ->packageManager ->getPackage ('Neos.Flow ' );
138134 $ flowVersion = $ flowPackage ->getInstalledVersion ();
139- } catch (UnknownPackageException $ e ) {
135+ } catch (UnknownPackageException ) {
140136 }
141137 }
142138 if (empty ($ flowVersion )) {
143139 $ flowVersion = FLOW_VERSION_BRANCH ;
144140 }
145141
146- $ currentSession = null ;
147- if ($ this ->sessionManager ) {
148- $ currentSession = $ this ->sessionManager ->getCurrentSession ();
149- }
142+ $ currentSession = $ this ->sessionManager ?->getCurrentSession();
150143
151144 SentrySdk::getCurrentHub ()->configureScope (static function (Scope $ scope ) use ($ flowVersion , $ currentSession ): void {
152145 $ scope ->setTag ('flow_version ' , $ flowVersion );
153146 $ scope ->setTag ('flow_context ' , (string )Bootstrap::$ staticObjectManager ->get (Environment::class)->getContext ());
154- $ scope ->setTag ('php_version ' , PHP_VERSION );
155-
156- if (PHP_SAPI !== 'cli ' ) {
157- $ scope ->setTag ('uri ' ,
158- (string )ServerRequest::fromGlobals ()->getUri ());
159-
160- $ agent = new Agent ();
161- $ scope ->setContext ('client_os ' , [
162- 'name ' => $ agent ->platform (),
163- 'version ' => $ agent ->version ($ agent ->platform ())
164- ]);
165-
166- $ scope ->setContext ('client_browser ' , [
167- 'name ' => $ agent ->browser (),
168- 'version ' => $ agent ->version ($ agent ->browser ())
169- ]);
170- }
171147
172148 if ($ currentSession instanceof Session && $ currentSession ->isStarted ()) {
173149 $ scope ->setTag ('flow_session_sha1 ' , sha1 ($ currentSession ->getId ()));
@@ -226,7 +202,7 @@ public function captureThrowable(Throwable $throwable, array $extraData = [], ar
226202 $ message = 'ignored ' ;
227203 }
228204 return new CaptureResult (
229- true ,
205+ true ,
230206 $ message ,
231207 (string )$ sentryEventId
232208 );
@@ -326,7 +302,7 @@ private function prepareStacktrace(\Throwable $throwable = null): Stacktrace
326302 $ frame ->getRawFunctionName (),
327303 $ frame ->getAbsoluteFilePath (),
328304 $ frame ->getVars (),
329- strpos ($ classPathAndFilename , 'Packages/Framework/ ' ) === false
305+ ! str_contains ($ classPathAndFilename , 'Packages/Framework/ ' )
330306 );
331307 }
332308 return new Stacktrace ($ frames );
0 commit comments