Skip to content

Commit f6f5dcf

Browse files
authored
feat: make endpoint app url configurable (#204)
1 parent a0cc4c2 commit f6f5dcf

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/CheckInsClient.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
class CheckInsClient extends ApiClient
1414
{
15-
const BASE_URL = 'https://app.honeybadger.io/';
16-
1715
/**
1816
* @param string $projectApiKey
1917
* @return string The project ID for the given API key.
@@ -188,7 +186,7 @@ public function remove(string $projectId, string $checkInId): void {
188186
public function makeClient(): Client
189187
{
190188
return new Client([
191-
'base_uri' => self::BASE_URL,
189+
'base_uri' => $this->config['app_endpoint'],
192190
RequestOptions::HTTP_ERRORS => false,
193191
RequestOptions::AUTH => [
194192
$this->config['personal_auth_token'], ''

src/Config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ private function mergeConfig($config = []): array
3131
'api_key' => null,
3232
'personal_auth_token' => null,
3333
'endpoint' => Honeybadger::API_URL,
34+
'app_endpoint' => Honeybadger::APP_URL,
3435
'notifier' => [
3536
'name' => 'honeybadger-php',
3637
'url' => 'https://github.com/honeybadger-io/honeybadger-php',

src/Honeybadger.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ class Honeybadger implements Reporter
2626

2727
/**
2828
* Honeybadger API URL.
29+
* Used to send notices (errors), events (Insights), and check-ins.
30+
* If you are using our EU stack, this should be set to "https://eu-api.honeybadger.io/".
2931
*/
3032
const API_URL = 'https://api.honeybadger.io/';
3133

34+
/**
35+
* Honeybadger APP URL.
36+
* Used to configure/synchronize check-ins.
37+
* If you are using our EU stack, this should be set to "https://eu-app.honeybadger.io/".
38+
*/
39+
const APP_URL = 'https://app.honeybadger.io/';
40+
3241
/**
3342
* @var CheckInsClient;
3443
*/

tests/ConfigTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ class ConfigTest extends TestCase
1111
/** @test */
1212
public function it_merges_configuration_values()
1313
{
14-
$config = (new Config(['api_key' => '1234']))->all();
14+
$config = (new Config([
15+
'api_key' => '1234',
16+
'app_endpoint' => 'https://eu-app.honeybadger.io',
17+
]))->all();
1518

1619
$this->assertArrayHasKey('service_exception_handler', $config);
1720
unset($config['service_exception_handler']);
@@ -20,6 +23,7 @@ public function it_merges_configuration_values()
2023
'api_key' => '1234',
2124
'personal_auth_token' => null,
2225
'endpoint' => Honeybadger::API_URL,
26+
'app_endpoint' => 'https://eu-app.honeybadger.io',
2327
'notifier' => [
2428
'name' => 'honeybadger-php',
2529
'url' => 'https://github.com/honeybadger-io/honeybadger-php',
@@ -82,6 +86,7 @@ public function it_set_shutdown_handler_to_true_by_default()
8286
'api_key' => '1234',
8387
'personal_auth_token' => null,
8488
'endpoint' => Honeybadger::API_URL,
89+
'app_endpoint' => Honeybadger::APP_URL,
8590
'notifier' => [
8691
'name' => 'honeybadger-php',
8792
'url' => 'https://github.com/honeybadger-io/honeybadger-php',

0 commit comments

Comments
 (0)