diff --git a/src/Tracing/DynamicSamplingContext.php b/src/Tracing/DynamicSamplingContext.php index c3a704a53..cf159ed59 100644 --- a/src/Tracing/DynamicSamplingContext.php +++ b/src/Tracing/DynamicSamplingContext.php @@ -182,12 +182,6 @@ public static function fromTransaction(Transaction $transaction, HubInterface $h } } - $hub->configureScope(static function (Scope $scope) use ($samplingContext): void { - if ($scope->getUser() !== null && $scope->getUser()->getSegment() !== null) { - $samplingContext->set('user_segment', $scope->getUser()->getSegment()); - } - }); - if ($transaction->getSampled() !== null) { $samplingContext->set('sampled', $transaction->getSampled() ? 'true' : 'false'); } @@ -218,10 +212,6 @@ public static function fromOptions(Options $options, Scope $scope): self $samplingContext->set('environment', $options->getEnvironment()); } - if ($scope->getUser() !== null && $scope->getUser()->getSegment() !== null) { - $samplingContext->set('user_segment', $scope->getUser()->getSegment()); - } - $samplingContext->freeze(); return $samplingContext; diff --git a/src/UserDataBag.php b/src/UserDataBag.php index 5e08dbb5b..ec536faef 100644 --- a/src/UserDataBag.php +++ b/src/UserDataBag.php @@ -183,6 +183,8 @@ public function setEmail(?string $email): self /** * Gets the segement of the user. + * + * @deprecated since version 4.4. To be removed in version 5.0 */ public function getSegment(): ?string { @@ -193,6 +195,8 @@ public function getSegment(): ?string * Sets the segment of the user. * * @param string|null $segment The segment + * + * @deprecated since version 4.4. To be removed in version 5.0. You may use a custom tag or context instead. */ public function setSegment(?string $segment): self { diff --git a/tests/Tracing/DynamicSamplingContextTest.php b/tests/Tracing/DynamicSamplingContextTest.php index 137e7030c..73ecb5052 100644 --- a/tests/Tracing/DynamicSamplingContextTest.php +++ b/tests/Tracing/DynamicSamplingContextTest.php @@ -15,7 +15,6 @@ use Sentry\Tracing\Transaction; use Sentry\Tracing\TransactionContext; use Sentry\Tracing\TransactionSource; -use Sentry\UserDataBag; final class DynamicSamplingContextTest extends TestCase { @@ -29,7 +28,6 @@ public function testFromHeader( ?string $expectedSampleRate, ?string $expectedRelease, ?string $expectedEnvironment, - ?string $expectedUserSegment, ?string $expectedTransaction ): void { $samplingContext = DynamicSamplingContext::fromHeader($header); @@ -39,7 +37,6 @@ public function testFromHeader( $this->assertSame($expectedSampleRate, $samplingContext->get('sample_rate')); $this->assertSame($expectedRelease, $samplingContext->get('release')); $this->assertSame($expectedEnvironment, $samplingContext->get('environment')); - $this->assertSame($expectedUserSegment, $samplingContext->get('user_segment')); $this->assertSame($expectedTransaction, $samplingContext->get('transaction')); } @@ -64,7 +61,6 @@ public static function fromHeaderDataProvider(): \Generator null, null, null, - null, ]; yield [ @@ -74,7 +70,6 @@ public static function fromHeaderDataProvider(): \Generator '1', '1.0.0', 'test', - 'my_segment', '', ]; } @@ -90,13 +85,7 @@ public function testFromTransaction(): void 'environment' => 'test', ])); - $user = new UserDataBag(); - $user->setSegment('my_segment'); - - $scope = new Scope(); - $scope->setUser($user); - - $hub = new Hub($client, $scope); + $hub = new Hub($client); $transactionContext = new TransactionContext(); $transactionContext->setName('foo'); @@ -112,7 +101,6 @@ public function testFromTransaction(): void $this->assertSame('public', $samplingContext->get('public_key')); $this->assertSame('1.0.0', $samplingContext->get('release')); $this->assertSame('test', $samplingContext->get('environment')); - $this->assertSame('my_segment', $samplingContext->get('user_segment')); $this->assertTrue($samplingContext->isFrozen()); } @@ -143,11 +131,7 @@ public function testFromOptions(): void $propagationContext = PropagationContext::fromDefaults(); $propagationContext->setTraceId(new TraceId('21160e9b836d479f81611368b2aa3d2c')); - $user = new UserDataBag(); - $user->setSegment('my_segment'); - $scope = new Scope(); - $scope->setUser($user); $scope->setPropagationContext($propagationContext); $samplingContext = DynamicSamplingContext::fromOptions($options, $scope); @@ -157,7 +141,6 @@ public function testFromOptions(): void $this->assertSame('public', $samplingContext->get('public_key')); $this->assertSame('1.0.0', $samplingContext->get('release')); $this->assertSame('test', $samplingContext->get('environment')); - $this->assertSame('my_segment', $samplingContext->get('user_segment')); $this->assertTrue($samplingContext->isFrozen()); }