Skip to content

Commit c378f48

Browse files
Use CDN URL for DCS
1 parent 4c8c40f commit c378f48

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/StatsigNetwork.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ function guidv4($data = null)
2828
use GuzzleHttp\Pool;
2929
use GuzzleHttp\Psr7\Request;
3030

31+
const DCS_URL = "https://api.statsigcdn.com/v1/";
32+
const API_URL = "https://statsigapi.net/v1/";
33+
3134
class StatsigNetwork
3235
{
3336
private string $key;
@@ -63,8 +66,8 @@ function setSdkKey(string $key)
6366
'STATSIG-SDK-VERSION' => StatsigMetadata::VERSION,
6467
'Content-Type' => 'application/json'
6568
]
66-
]);
67-
$this->error_boundary = new ErrorBoundary($key);
69+
]);
70+
$this->error_boundary = new ErrorBoundary($key);
6871
}
6972

7073
function getErrorBoundary()
@@ -103,8 +106,17 @@ function logEventsWithStatusCode($events)
103106

104107
function postRequest(string $endpoint, string $input, array $extra_headers = [], bool $with_status = false)
105108
{
106-
107-
$response = $this->client->post($endpoint, [
109+
$client = new Client([
110+
'base_uri' => $endpoint === 'dcs' ? DCS_URL : API_URL,
111+
'headers' => [
112+
'STATSIG-API-KEY' => $this->key,
113+
'STATSIG-SERVER-SESSION-ID' => $this->session_id,
114+
'STATSIG-SDK-TYPE' => StatsigMetadata::SDK_TYPE,
115+
'STATSIG-SDK-VERSION' => StatsigMetadata::VERSION,
116+
'Content-Type' => 'application/json'
117+
]
118+
]);
119+
$response = $client->post($endpoint, [
108120
RequestOptions::BODY => $input,
109121
RequestOptions::HTTP_ERRORS => false,
110122
RequestOptions::HEADERS => $extra_headers,

0 commit comments

Comments
 (0)