Skip to content

Commit 26cc3f6

Browse files
committed
feat: add custom User-Agent header to HttpClient
Included a dynamic User-Agent header using Composer's InstalledVersions and PHP runtime version. This provides better tracking and debugging capabilities for API requests.
1 parent 7c4f82c commit 26cc3f6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/Client/HttpClient.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Lettermint\Client;
44

5+
use Composer\InstalledVersions;
56
use GuzzleHttp\Client;
67
use GuzzleHttp\Exception\GuzzleException;
78

@@ -23,6 +24,11 @@ public function __construct(string $apiToken, string $baseUrl)
2324
'headers' => [
2425
'Content-Type' => 'application/json',
2526
'x-lettermint-token' => $this->apiToken,
27+
'User-Agent' => sprintf(
28+
'Lettermint/%s (PHP; PHP %s)',
29+
InstalledVersions::getPrettyVersion('lettermint/lettermint-php') ?? 'unknown',
30+
PHP_VERSION
31+
),
2632
],
2733
]);
2834
}

0 commit comments

Comments
 (0)