Skip to content

Commit ea17496

Browse files
Merge pull request #680 from bugsnag/release/v3.30.0
Release v3.30.0
2 parents 9d9aa66 + 037fe23 commit ea17496

File tree

4 files changed

+92
-10
lines changed

4 files changed

+92
-10
lines changed

.github/workflows/test-package.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ jobs:
2525
guzzle-version: '^7.0'
2626
- php-version: '8.3'
2727
guzzle-version: '^7.0'
28-
- php-version: '8.4'
29-
guzzle-version: '^7.9'
28+
# PHP 8.4 skipped pending PLAT-14402
29+
#- php-version: '8.4'
30+
# guzzle-version: '^7.9'
3031

3132
steps:
3233
- uses: actions/checkout@v2

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
## 3.30.0 (2025-07-08)
5+
6+
### Enhancements
7+
8+
* Set default endpoints based on API key
9+
[#679](https://github.com/bugsnag/bugsnag-php/pull/679)
10+
411
## 3.29.3 (2025-03-06)
512

613
### Fixes

src/Configuration.php

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,35 @@
88
class Configuration implements FeatureDataStore
99
{
1010
/**
11-
* The default endpoint for event notifications.
11+
* The default endpoint for event notifications with Bugsnag.
1212
*/
1313
const NOTIFY_ENDPOINT = 'https://notify.bugsnag.com';
1414

1515
/**
16-
* The default endpoint for session tracking.
16+
* The default endpoint for session tracking with Bugsnag.
1717
*/
1818
const SESSION_ENDPOINT = 'https://sessions.bugsnag.com';
1919

2020
/**
21-
* The default endpoint for build notifications.
21+
* The default endpoint for build notifications with Bugsnag.
2222
*/
2323
const BUILD_ENDPOINT = 'https://build.bugsnag.com';
2424

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+
2540
/**
2641
* @var string
2742
*/
@@ -85,7 +100,7 @@ class Configuration implements FeatureDataStore
85100
*/
86101
protected $notifier = [
87102
'name' => 'Bugsnag PHP (Official)',
88-
'version' => '3.29.3',
103+
'version' => '3.30.0',
89104
'url' => 'https://bugsnag.com',
90105
];
91106

@@ -150,17 +165,17 @@ class Configuration implements FeatureDataStore
150165
/**
151166
* @var string
152167
*/
153-
protected $notifyEndpoint = self::NOTIFY_ENDPOINT;
168+
protected $notifyEndpoint;
154169

155170
/**
156171
* @var string
157172
*/
158-
protected $sessionEndpoint = self::SESSION_ENDPOINT;
173+
protected $sessionEndpoint;
159174

160175
/**
161176
* @var string
162177
*/
163-
protected $buildEndpoint = self::BUILD_ENDPOINT;
178+
protected $buildEndpoint;
164179

165180
/**
166181
* The amount to increase the memory_limit to handle an OOM.
@@ -201,15 +216,36 @@ public function __construct($apiKey)
201216
if (!is_string($apiKey)) {
202217
throw new InvalidArgumentException('Invalid API key');
203218
}
204-
205219
$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+
206231
$this->fallbackType = php_sapi_name();
207232
$this->featureFlags = new FeatureFlagDelegate();
208233

209234
// Add PHP runtime version to device data
210235
$this->mergeDeviceData(['runtimeVersions' => ['php' => phpversion()]]);
211236
}
212237

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+
213249
/**
214250
* Get the Bugsnag API Key.
215251
*

tests/ConfigurationTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,51 @@ public function testSessionTrackingCanBeEnabled()
298298
$this->assertTrue($this->config->shouldCaptureSessions());
299299
}
300300

301+
public function testTheNotifyEndpointHasASensibleDefault()
302+
{
303+
$expected = 'https://notify.bugsnag.com';
304+
305+
$this->assertSame($expected, $this->config->getNotifyEndpoint());
306+
}
307+
308+
public function testTheNotifyEndpointForHubHasASensibleDefault()
309+
{
310+
$expected = 'https://notify.insighthub.smartbear.com';
311+
$this->config = new Configuration('00000123123123123');
312+
313+
$this->assertSame($expected, $this->config->getNotifyEndpoint());
314+
}
315+
301316
public function testTheSessionEndpointHasASensibleDefault()
302317
{
303318
$expected = 'https://sessions.bugsnag.com';
304319

305320
$this->assertSame($expected, $this->config->getSessionEndpoint());
306321
}
307322

323+
public function testTheSessionEndpointForHubHasASensibleDefault()
324+
{
325+
$expected = 'https://sessions.insighthub.smartbear.com';
326+
$this->config = new Configuration('00000123123123123');
327+
328+
$this->assertSame($expected, $this->config->getSessionEndpoint());
329+
}
330+
331+
public function testTheBuildEndpointHasASensibleDefault()
332+
{
333+
$expected = 'https://build.bugsnag.com';
334+
335+
$this->assertSame($expected, $this->config->getBuildEndpoint());
336+
}
337+
338+
public function testTheBuildEndpointForHubHasASensibleDefault()
339+
{
340+
$expected = 'https://build.insighthub.smartbear.com';
341+
$this->config = new Configuration('00000123123123123');
342+
343+
$this->assertSame($expected, $this->config->getBuildEndpoint());
344+
}
345+
308346
public function testTheSessionEndpointCanBeSetIfNecessary()
309347
{
310348
$expected = 'https://example.com';

0 commit comments

Comments
 (0)