1313use Sentry \Logs \LogsAggregator ;
1414use Sentry \Options ;
1515use Sentry \SentrySdk ;
16- use Sentry \State \Hub ;
1716use Sentry \State \Scope ;
1817use Sentry \Tests \StubTransport ;
1918use Sentry \Tracing \PropagationContext ;
@@ -38,8 +37,7 @@ public function testAttributes(array $attributes, array $expected): void
3837 'enable_logs ' => true ,
3938 ])->getClient ();
4039
41- $ hub = new Hub ($ client );
42- SentrySdk::setCurrentHub ($ hub );
40+ SentrySdk::init ($ client );
4341
4442 $ aggregator = new LogsAggregator ();
4543
@@ -96,8 +94,7 @@ public function testMessageFormatting(string $message, array $values, string $ex
9694 'enable_logs ' => true ,
9795 ])->getClient ();
9896
99- $ hub = new Hub ($ client );
100- SentrySdk::setCurrentHub ($ hub );
97+ SentrySdk::init ($ client );
10198
10299 $ aggregator = new LogsAggregator ();
103100
@@ -173,21 +170,19 @@ public function testAttributesAreAddedToLogMessage(): void
173170 'server_name ' => 'web-server-01 ' ,
174171 ])->getClient ();
175172
176- SentrySdk::setCurrentHub ( new Hub ( $ client) );
173+ SentrySdk::init ( $ client );
177174
178- SentrySdk::getCurrentHub ()->configureScope (static function (Scope $ scope ) {
179- $ userDataBag = new UserDataBag ();
180- $ userDataBag ->setId ('unique_id ' );
181- $ userDataBag ->setEmail ('foo@example.com ' );
182- $ userDataBag ->setUsername ('my_user ' );
183- $ scope ->setUser ($ userDataBag );
184- });
175+ $ userDataBag = new UserDataBag ();
176+ $ userDataBag ->setId ('unique_id ' );
177+ $ userDataBag ->setEmail ('foo@example.com ' );
178+ $ userDataBag ->setUsername ('my_user ' );
179+ SentrySdk::getIsolationScope ()->setUser ($ userDataBag );
185180
186181 $ spanContext = new SpanContext ();
187182 $ spanContext ->setTraceId (new TraceId ('566e3688a61d4bc888951642d6f14a19 ' ));
188183 $ spanContext ->setSpanId (new SpanId ('566e3688a61d4bc8 ' ));
189184 $ span = new Span ($ spanContext );
190- SentrySdk::getCurrentHub ()->setSpan ($ span );
185+ SentrySdk::getIsolationScope ()->setSpan ($ span );
191186
192187 $ aggregator = new LogsAggregator ();
193188
@@ -219,7 +214,7 @@ public function testMergedScopeAttributesAreAddedToLogMessage(): void
219214 'enable_logs ' => true ,
220215 ])->getClient ();
221216
222- SentrySdk::getGlobalScope ()-> setClient ($ client );
217+ SentrySdk::init ($ client );
223218 SentrySdk::getGlobalScope ()->setUser (UserDataBag::createFromUserIdentifier ('global-user ' ));
224219
225220 $ spanContext = new SpanContext ();
@@ -245,15 +240,13 @@ public function testUserAttributesCanBeSetManuallyWithDefaultPiiOff(): void
245240 'send_default_pii ' => false ,
246241 ])->getClient ();
247242
248- SentrySdk::setCurrentHub ( new Hub ( $ client) );
243+ SentrySdk::init ( $ client );
249244
250- SentrySdk::getCurrentHub ()->configureScope (static function (Scope $ scope ) {
251- $ userDataBag = new UserDataBag ();
252- $ userDataBag ->setId ('unique_id ' );
253- $ userDataBag ->setEmail ('foo@example.com ' );
254- $ userDataBag ->setUsername ('my_user ' );
255- $ scope ->setUser ($ userDataBag );
256- });
245+ $ userDataBag = new UserDataBag ();
246+ $ userDataBag ->setId ('unique_id ' );
247+ $ userDataBag ->setEmail ('foo@example.com ' );
248+ $ userDataBag ->setUsername ('my_user ' );
249+ SentrySdk::getIsolationScope ()->setUser ($ userDataBag );
257250
258251 $ aggregator = new LogsAggregator ();
259252 $ aggregator ->add (LogLevel::info (), 'User performed action ' );
@@ -278,8 +271,7 @@ public function testFlushesImmediatelyWhenThresholdIsReached(): void
278271 'log_flush_threshold ' => 2 ,
279272 ])->setTransport ($ transport )->getClient ();
280273
281- $ hub = new Hub ($ client );
282- SentrySdk::setCurrentHub ($ hub );
274+ SentrySdk::init ($ client );
283275
284276 $ aggregator = new LogsAggregator ();
285277
@@ -312,7 +304,7 @@ public function testFlushCapturesLogsWithProvidedClient(): void
312304 ]));
313305 $ fallbackClient ->expects ($ this ->never ())
314306 ->method ('captureEvent ' );
315- SentrySdk::setCurrentHub ( new Hub ( $ fallbackClient) );
307+ SentrySdk::init ( $ fallbackClient );
316308
317309 $ aggregator = new LogsAggregator ();
318310 $ aggregator ->add (LogLevel::info (), 'Test message ' );
@@ -340,8 +332,7 @@ public function testDoesNotFlushImmediatelyWhenThresholdIsNull(): void
340332 'log_flush_threshold ' => null ,
341333 ])->setTransport ($ transport )->getClient ();
342334
343- $ hub = new Hub ($ client );
344- SentrySdk::setCurrentHub ($ hub );
335+ SentrySdk::init ($ client );
345336
346337 $ aggregator = new LogsAggregator ();
347338
@@ -362,7 +353,7 @@ public function testDoesNotUsePropagationContextSpanIdAsParentSpanIdWhenNoLocalS
362353 $ propagationContext ->setTraceId (new TraceId ('771a43a4192642f0b136d5159a501700 ' ));
363354 $ propagationContext ->setSpanId (new SpanId ('1234567890abcdef ' ));
364355
365- SentrySdk::setCurrentHub ( new Hub ( $ client) );
356+ SentrySdk::init ( $ client );
366357 SentrySdk::getCurrentRuntimeContext ()->setIsolationScope (new Scope ($ propagationContext ));
367358
368359 $ aggregator = new LogsAggregator ();
@@ -384,8 +375,7 @@ public function testUsesExternalPropagationContextWhenNoLocalSpanExists(): void
384375 'enable_logs ' => true ,
385376 ])->getClient ();
386377
387- $ hub = new Hub ($ client );
388- SentrySdk::setCurrentHub ($ hub );
378+ SentrySdk::init ($ client );
389379
390380 Scope::registerExternalPropagationContext (static function (): array {
391381 return [
0 commit comments