55namespace Pluswerk \Sentry \Service ;
66
77use InvalidArgumentException ;
8- use Pluswerk \Sentry \Transport \MockTransportFactory ;
8+ use Pluswerk \Sentry \Integration \ExtSentryIntegration ;
9+ use Pluswerk \Sentry \Tests \Helper \MockTransportFactory ;
910use Pluswerk \Sentry \Transport \QueueTransportFactory ;
1011use Sentry \ClientBuilder ;
1112use Sentry \ClientInterface ;
1819use TYPO3 \CMS \Core \Core \Environment ;
1920use TYPO3 \CMS \Core \SingletonInterface ;
2021use TYPO3 \CMS \Core \Utility \GeneralUtility ;
21-
22- use function dd ;
2322use function getenv ;
2423use function Sentry \captureException ;
2524use function Sentry \configureScope ;
@@ -31,8 +30,27 @@ public function __construct(
3130 protected ScopeConfig $ scopeConfig ,
3231 protected ConfigService $ config ,
3332 ) {
34- dd ();
35- $ this ->setup ();
33+ // $this->setup();
34+ }
35+
36+ public function staticSetup ()
37+ {
38+ // $config = GeneralUtility::makeInstance(
39+ // ConfigService::class,
40+ // GeneralUtility::makeInstance(ExtensionConfiguration::class),
41+ // );
42+
43+ \Sentry \init ([
44+ // 'environment' => preg_replace('#[\/\s]#', '', (string)Environment::getContext()),
45+ 'dsn ' => 'https://sentry.example.com/123456 ' , // $config->getDsn(),
46+ // 'attach_stacktrace' => true,
47+ // 'error_types' => $config->getErrorsToReport(),
48+ // 'prefixes' => [Environment::getProjectPath()],
49+ // 'release' => $config->isWithGitReleases() ? shell_exec('git rev-parse HEAD') : null,
50+ 'integrations ' => [
51+ new ExtSentryIntegration (),
52+ ]
53+ ]);
3654 }
3755
3856 public function isDisabled (): bool
@@ -60,7 +78,8 @@ protected function setup(): void
6078
6179 $ builder = ClientBuilder::create (array_filter ($ options ));
6280 if ($ this ->config ->isQueueEnabled ()) {
63- $ builder ->setTransportFactory (new QueueTransportFactory ());
81+ $ transport = (new QueueTransportFactory ())->create ($ builder ->getOptions ());
82+ $ builder ->setTransport ($ transport );
6483 }
6584
6685 $ this ->addMockIfNeeded ($ builder );
@@ -121,6 +140,7 @@ private function addMockIfNeeded(ClientBuilder $builder): void
121140 if (!$ mockSeed ) {
122141 return ;
123142 }
124- $ builder ->setTransportFactory (new MockTransportFactory ($ mockSeed ));
143+ $ transport = (new MockTransportFactory ($ mockSeed ))->register ($ builder ->getOptions ());
144+ $ builder ->setTransport ($ transport );
125145 }
126146}
0 commit comments