|
8 | 8 | class Configuration implements FeatureDataStore |
9 | 9 | { |
10 | 10 | /** |
11 | | - * The default endpoint for event notifications. |
| 11 | + * The default endpoint for event notifications with Bugsnag. |
12 | 12 | */ |
13 | 13 | const NOTIFY_ENDPOINT = 'https://notify.bugsnag.com'; |
14 | 14 |
|
15 | 15 | /** |
16 | | - * The default endpoint for session tracking. |
| 16 | + * The default endpoint for session tracking with Bugsnag. |
17 | 17 | */ |
18 | 18 | const SESSION_ENDPOINT = 'https://sessions.bugsnag.com'; |
19 | 19 |
|
20 | 20 | /** |
21 | | - * The default endpoint for build notifications. |
| 21 | + * The default endpoint for build notifications with Bugsnag. |
22 | 22 | */ |
23 | 23 | const BUILD_ENDPOINT = 'https://build.bugsnag.com'; |
24 | 24 |
|
| 25 | + /** |
| 26 | + * The default endpoint for event notifications with InsightHub. |
| 27 | + */ |
| 28 | + const HUB_NOTIFY_ENDPOINT = 'https://notify.insighthub.smartbear.com'; |
| 29 | + |
| 30 | + /** |
| 31 | + * The default endpoint for session tracking with InsightHub. |
| 32 | + */ |
| 33 | + const HUB_SESSION_ENDPOINT = 'https://sessions.insighthub.smartbear.com'; |
| 34 | + |
| 35 | + /** |
| 36 | + * The default endpoint for build notifications with InsightHub. |
| 37 | + */ |
| 38 | + const HUB_BUILD_ENDPOINT = 'https://build.insighthub.smartbear.com'; |
| 39 | + |
25 | 40 | /** |
26 | 41 | * @var string |
27 | 42 | */ |
@@ -85,7 +100,7 @@ class Configuration implements FeatureDataStore |
85 | 100 | */ |
86 | 101 | protected $notifier = [ |
87 | 102 | 'name' => 'Bugsnag PHP (Official)', |
88 | | - 'version' => '3.29.3', |
| 103 | + 'version' => '3.30.0', |
89 | 104 | 'url' => 'https://bugsnag.com', |
90 | 105 | ]; |
91 | 106 |
|
@@ -150,17 +165,17 @@ class Configuration implements FeatureDataStore |
150 | 165 | /** |
151 | 166 | * @var string |
152 | 167 | */ |
153 | | - protected $notifyEndpoint = self::NOTIFY_ENDPOINT; |
| 168 | + protected $notifyEndpoint; |
154 | 169 |
|
155 | 170 | /** |
156 | 171 | * @var string |
157 | 172 | */ |
158 | | - protected $sessionEndpoint = self::SESSION_ENDPOINT; |
| 173 | + protected $sessionEndpoint; |
159 | 174 |
|
160 | 175 | /** |
161 | 176 | * @var string |
162 | 177 | */ |
163 | | - protected $buildEndpoint = self::BUILD_ENDPOINT; |
| 178 | + protected $buildEndpoint; |
164 | 179 |
|
165 | 180 | /** |
166 | 181 | * The amount to increase the memory_limit to handle an OOM. |
@@ -201,15 +216,36 @@ public function __construct($apiKey) |
201 | 216 | if (!is_string($apiKey)) { |
202 | 217 | throw new InvalidArgumentException('Invalid API key'); |
203 | 218 | } |
204 | | - |
205 | 219 | $this->apiKey = $apiKey; |
| 220 | + |
| 221 | + if ($this->isHubApiKey()) { |
| 222 | + $this->notifyEndpoint = self::HUB_NOTIFY_ENDPOINT; |
| 223 | + $this->sessionEndpoint = self::HUB_SESSION_ENDPOINT; |
| 224 | + $this->buildEndpoint = self::HUB_BUILD_ENDPOINT; |
| 225 | + } else { |
| 226 | + $this->notifyEndpoint = self::NOTIFY_ENDPOINT; |
| 227 | + $this->sessionEndpoint = self::SESSION_ENDPOINT; |
| 228 | + $this->buildEndpoint = self::BUILD_ENDPOINT; |
| 229 | + } |
| 230 | + |
206 | 231 | $this->fallbackType = php_sapi_name(); |
207 | 232 | $this->featureFlags = new FeatureFlagDelegate(); |
208 | 233 |
|
209 | 234 | // Add PHP runtime version to device data |
210 | 235 | $this->mergeDeviceData(['runtimeVersions' => ['php' => phpversion()]]); |
211 | 236 | } |
212 | 237 |
|
| 238 | + /** |
| 239 | + * Checks if the API Key is associated with the InsightHub instance. |
| 240 | + * |
| 241 | + * @return bool |
| 242 | + */ |
| 243 | + public function isHubApiKey() |
| 244 | + { |
| 245 | + // Does the API key start with 00000 |
| 246 | + return strpos($this->apiKey, '00000') === 0; |
| 247 | + } |
| 248 | + |
213 | 249 | /** |
214 | 250 | * Get the Bugsnag API Key. |
215 | 251 | * |
|
0 commit comments