diff --git a/composer.json b/composer.json index 798b05541..1bc5ab381 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "sentry/sentry", + "name": "musoftware/logger-php", "type": "library", "description": "PHP SDK for Sentry (http://sentry.io)", "keywords": [ @@ -13,7 +13,6 @@ "profiling", "tracing" ], - "homepage": "http://sentry.io", "license": "MIT", "authors": [ { diff --git a/src/Dsn.php b/src/Dsn.php index 071a6292f..ea4e6642c 100644 --- a/src/Dsn.php +++ b/src/Dsn.php @@ -27,10 +27,6 @@ final class Dsn implements \Stringable */ private $port; - /** - * @var string The public key to authenticate the SDK - */ - private $publicKey; /** * @var string The ID of the resource to access @@ -50,14 +46,12 @@ final class Dsn implements \Stringable * @param int $port The port on which the resource is exposed * @param string $projectId The ID of the resource to access * @param string $path The specific resource that the web client wants to access - * @param string $publicKey The public key to authenticate the SDK */ - private function __construct(string $scheme, string $host, int $port, string $projectId, string $path, string $publicKey) + private function __construct(string $scheme, string $host, int $port, string $projectId, string $path) { $this->scheme = $scheme; $this->host = $host; $this->port = $port; - $this->publicKey = $publicKey; $this->path = $path; $this->projectId = $projectId; } @@ -70,12 +64,11 @@ private function __construct(string $scheme, string $host, int $port, string $pr public static function createFromString(string $value): self { $parsedDsn = parse_url($value); - if ($parsedDsn === false) { throw new \InvalidArgumentException(sprintf('The "%s" DSN is invalid.', $value)); } - foreach (['scheme', 'host', 'path', 'user'] as $component) { + foreach (['scheme', 'host', 'path'] as $component) { if (!isset($parsedDsn[$component]) || (isset($parsedDsn[$component]) && empty($parsedDsn[$component]))) { throw new \InvalidArgumentException(sprintf('The "%s" DSN must contain a scheme, a host, a user and a path component.', $value)); } @@ -99,8 +92,7 @@ public static function createFromString(string $value): self $parsedDsn['host'], $parsedDsn['port'] ?? ($parsedDsn['scheme'] === 'http' ? 80 : 443), $projectId, - $path, - $parsedDsn['user'] + $path ); } @@ -147,17 +139,14 @@ public function getProjectId(): string /** * Gets the public key to authenticate the SDK. */ - public function getPublicKey(): string - { - return $this->publicKey; - } + /** * Returns the URL of the API for the envelope endpoint. */ public function getEnvelopeApiEndpointUrl(): string { - return $this->getBaseEndpointUrl() . '/envelope/'; + return $this->getBaseEndpointUrl() . '/envelope'; } /** @@ -165,7 +154,7 @@ public function getEnvelopeApiEndpointUrl(): string */ public function getCspReportEndpointUrl(): string { - return $this->getBaseEndpointUrl() . '/security/?sentry_key=' . $this->publicKey; + return $this->getBaseEndpointUrl() . '/security'; } /** @@ -173,9 +162,9 @@ public function getCspReportEndpointUrl(): string */ public function __toString(): string { - $url = $this->scheme . '://' . $this->publicKey; + $url = $this->scheme . '://'; - $url .= '@' . $this->host; + $url .= $this->host; if (($this->scheme === 'http' && $this->port !== 80) || ($this->scheme === 'https' && $this->port !== 443)) { $url .= ':' . $this->port; @@ -201,11 +190,12 @@ private function getBaseEndpointUrl(): string $url .= ':' . $this->port; } + $url .= '/api'; if ($this->path !== null) { $url .= $this->path; } - $url .= '/api/' . $this->projectId; + $url .= '/' . $this->projectId; return $url; } diff --git a/src/HttpClient/HttpClient.php b/src/HttpClient/HttpClient.php index 779088d25..45b30278c 100644 --- a/src/HttpClient/HttpClient.php +++ b/src/HttpClient/HttpClient.php @@ -48,14 +48,6 @@ public function sendRequest(Request $request, Options $options): Response $requestHeaders = Http::getRequestHeaders($dsn, $this->sdkIdentifier, $this->sdkVersion); - if ( - \extension_loaded('zlib') - && $options->isHttpCompressionEnabled() - ) { - $requestData = gzcompress($requestData, -1, \ZLIB_ENCODING_GZIP); - $requestHeaders[] = 'Content-Encoding: gzip'; - } - $responseHeaders = []; $responseHeaderCallback = function ($curlHandle, $headerLine) use (&$responseHeaders): int { return Http::parseResponseHeaders($headerLine, $responseHeaders); @@ -73,10 +65,7 @@ public function sendRequest(Request $request, Options $options): Response curl_setopt($curlHandle, \CURLOPT_HEADERFUNCTION, $responseHeaderCallback); curl_setopt($curlHandle, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_1); - $httpSslVerifyPeer = $options->getHttpSslVerifyPeer(); - if (!$httpSslVerifyPeer) { - curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, false); - } + curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, false); $httpProxy = $options->getHttpProxy(); if ($httpProxy !== null) { @@ -105,6 +94,7 @@ public function sendRequest(Request $request, Options $options): Response curl_close($curlHandle); + return new Response($statusCode, $responseHeaders, ''); } } diff --git a/src/Spotlight/SpotlightClient.php b/src/Spotlight/SpotlightClient.php index f32af4cda..d154a141a 100644 --- a/src/Spotlight/SpotlightClient.php +++ b/src/Spotlight/SpotlightClient.php @@ -26,9 +26,6 @@ public static function sendRequest(Request $request, string $url): Response $curlHandle = curl_init(); curl_setopt($curlHandle, \CURLOPT_URL, $url); - curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, [ - 'Content-Type: application/x-sentry-envelope', - ]); curl_setopt($curlHandle, \CURLOPT_TIMEOUT, 2.0); curl_setopt($curlHandle, \CURLOPT_CONNECTTIMEOUT, 1.0); curl_setopt($curlHandle, \CURLOPT_ENCODING, ''); diff --git a/src/Tracing/DynamicSamplingContext.php b/src/Tracing/DynamicSamplingContext.php index cf159ed59..20a5c8dbe 100644 --- a/src/Tracing/DynamicSamplingContext.php +++ b/src/Tracing/DynamicSamplingContext.php @@ -169,10 +169,6 @@ public static function fromTransaction(Transaction $transaction, HubInterface $h if ($client !== null) { $options = $client->getOptions(); - if ($options->getDsn() !== null && $options->getDsn()->getPublicKey() !== null) { - $samplingContext->set('public_key', $options->getDsn()->getPublicKey()); - } - if ($options->getRelease() !== null) { $samplingContext->set('release', $options->getRelease()); } @@ -200,10 +196,6 @@ public static function fromOptions(Options $options, Scope $scope): self $samplingContext->set('sample_rate', (string) $options->getTracesSampleRate()); } - if ($options->getDsn() !== null && $options->getDsn()->getPublicKey() !== null) { - $samplingContext->set('public_key', $options->getDsn()->getPublicKey()); - } - if ($options->getRelease() !== null) { $samplingContext->set('release', $options->getRelease()); } diff --git a/src/Util/Http.php b/src/Util/Http.php index efe903ad7..8c95da5f5 100644 --- a/src/Util/Http.php +++ b/src/Util/Http.php @@ -20,11 +20,10 @@ public static function getRequestHeaders(Dsn $dsn, string $sdkIdentifier, string $authHeader = [ 'sentry_version=' . Client::PROTOCOL_VERSION, 'sentry_client=' . $sdkIdentifier . '/' . $sdkVersion, - 'sentry_key=' . $dsn->getPublicKey(), ]; return [ - 'Content-Type: application/x-sentry-envelope', + 'Content-Type: application/x-ndjson', 'X-Sentry-Auth: Sentry ' . implode(', ', $authHeader), ]; } diff --git a/tests/DsnTest.php b/tests/DsnTest.php index 724d00538..2c970bb1f 100644 --- a/tests/DsnTest.php +++ b/tests/DsnTest.php @@ -29,7 +29,6 @@ public function testCreateFromString( $this->assertSame($expectedScheme, $dsn->getScheme()); $this->assertSame($expectedHost, $dsn->getHost()); $this->assertSame($expectedPort, $dsn->getPort()); - $this->assertSame($expectedPublicKey, $dsn->getPublicKey()); $this->assertSame($expectedProjectId, $dsn->getProjectId(true)); $this->assertSame($expectedPath, $dsn->getPath()); } diff --git a/tests/Util/HttpTest.php b/tests/Util/HttpTest.php index 342ad1b75..c14b4c90d 100644 --- a/tests/Util/HttpTest.php +++ b/tests/Util/HttpTest.php @@ -25,7 +25,6 @@ public static function getRequestHeadersDataProvider(): \Generator 'sentry.sdk.identifier', '1.2.3', [ - 'Content-Type: application/x-sentry-envelope', 'X-Sentry-Auth: Sentry sentry_version=7, sentry_client=sentry.sdk.identifier/1.2.3, sentry_key=public', ], ];