From 59c0103211109d72750865e1388d94391444c5ec Mon Sep 17 00:00:00 2001 From: Pavel Zotikov Date: Mon, 11 Nov 2024 15:48:04 +0300 Subject: [PATCH 1/6] Add Hostname addon to include hostname in error event payload --- composer.json | 2 +- src/Addons/Hostname.php | 35 +++++++++++++++++++++++++++++++++++ src/Catcher.php | 2 ++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/Addons/Hostname.php diff --git a/composer.json b/composer.json index 4e9183d..ea4053f 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "PHP errors Catcher module for Hawk.so", "keywords": ["hawk", "php", "error", "catcher"], "type": "library", - "version": "2.2.4", + "version": "2.2.5", "license": "MIT", "require": { "ext-curl": "*", diff --git a/src/Addons/Hostname.php b/src/Addons/Hostname.php new file mode 100644 index 0000000..b7b1105 --- /dev/null +++ b/src/Addons/Hostname.php @@ -0,0 +1,35 @@ + $hostname]; + } +} \ No newline at end of file diff --git a/src/Catcher.php b/src/Catcher.php index a8be68c..086b1c4 100644 --- a/src/Catcher.php +++ b/src/Catcher.php @@ -5,6 +5,7 @@ namespace Hawk; use Hawk\Addons\Headers; +use Hawk\Addons\Hostname; use Hawk\Transport\CurlTransport; use Throwable; @@ -154,6 +155,7 @@ private function __construct(array $options) */ $builder = new EventPayloadBuilder($stacktraceBuilder); $builder->registerAddon(new Headers()); + $builder->registerAddon(new Hostname()); $transport = new CurlTransport($options->getUrl()); From 55a06218f524fd77bad3308684c3106e0be67454 Mon Sep 17 00:00:00 2001 From: Pavel Zotikov Date: Mon, 11 Nov 2024 15:55:38 +0300 Subject: [PATCH 2/6] Update Hostname.php --- src/Addons/Hostname.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Addons/Hostname.php b/src/Addons/Hostname.php index b7b1105..d7c5a85 100644 --- a/src/Addons/Hostname.php +++ b/src/Addons/Hostname.php @@ -32,4 +32,4 @@ public function resolve(): array return ['hostname' => $hostname]; } -} \ No newline at end of file +} From 8038fe27f034a8835bb3a5e5baab4fd78b2f0e3e Mon Sep 17 00:00:00 2001 From: Pavel Zotikov Date: Tue, 12 Nov 2024 15:25:24 +0300 Subject: [PATCH 3/6] environment addon --- src/Addons/Environment.php | 42 ++++++++++++++++++++++++++++++++++++++ src/Addons/Hostname.php | 35 ------------------------------- src/Catcher.php | 4 ++-- 3 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 src/Addons/Environment.php delete mode 100644 src/Addons/Hostname.php diff --git a/src/Addons/Environment.php b/src/Addons/Environment.php new file mode 100644 index 0000000..e98cd60 --- /dev/null +++ b/src/Addons/Environment.php @@ -0,0 +1,42 @@ +addHostname(); + + return $this->environment; + } + + private function addHostname(): void + { + $hostname = gethostname(); + + if ($hostname !== false) { + $this->environment['hostname'] = $hostname; + } + } +} diff --git a/src/Addons/Hostname.php b/src/Addons/Hostname.php deleted file mode 100644 index d7c5a85..0000000 --- a/src/Addons/Hostname.php +++ /dev/null @@ -1,35 +0,0 @@ - $hostname]; - } -} diff --git a/src/Catcher.php b/src/Catcher.php index 086b1c4..a6304c6 100644 --- a/src/Catcher.php +++ b/src/Catcher.php @@ -5,7 +5,7 @@ namespace Hawk; use Hawk\Addons\Headers; -use Hawk\Addons\Hostname; +use Hawk\Addons\Environment; use Hawk\Transport\CurlTransport; use Throwable; @@ -155,7 +155,7 @@ private function __construct(array $options) */ $builder = new EventPayloadBuilder($stacktraceBuilder); $builder->registerAddon(new Headers()); - $builder->registerAddon(new Hostname()); + $builder->registerAddon(new Environment()); $transport = new CurlTransport($options->getUrl()); From 16589d19c31c9f22fb5e46d8fd7adf5d9ac50c00 Mon Sep 17 00:00:00 2001 From: Pavel Zotikov Date: Tue, 12 Nov 2024 15:29:43 +0300 Subject: [PATCH 4/6] Update Environment.php --- src/Addons/Environment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Addons/Environment.php b/src/Addons/Environment.php index e98cd60..b832d73 100644 --- a/src/Addons/Environment.php +++ b/src/Addons/Environment.php @@ -40,3 +40,4 @@ private function addHostname(): void } } } + From c124abf1a94fab12c835479c12449b1f5173c943 Mon Sep 17 00:00:00 2001 From: Pavel Zotikov Date: Tue, 12 Nov 2024 15:33:49 +0300 Subject: [PATCH 5/6] linter --- src/Addons/Environment.php | 1 - src/Catcher.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Addons/Environment.php b/src/Addons/Environment.php index b832d73..e98cd60 100644 --- a/src/Addons/Environment.php +++ b/src/Addons/Environment.php @@ -40,4 +40,3 @@ private function addHostname(): void } } } - diff --git a/src/Catcher.php b/src/Catcher.php index a6304c6..6403630 100644 --- a/src/Catcher.php +++ b/src/Catcher.php @@ -4,8 +4,8 @@ namespace Hawk; -use Hawk\Addons\Headers; use Hawk\Addons\Environment; +use Hawk\Addons\Headers; use Hawk\Transport\CurlTransport; use Throwable; From 95e85c4d98b03cf593ec17c5000ac8074901ed2e Mon Sep 17 00:00:00 2001 From: Pavel Zotikov Date: Thu, 14 Nov 2024 12:18:28 +0300 Subject: [PATCH 6/6] Capitalized addon names --- src/Addons/Environment.php | 2 +- src/Addons/Headers.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Addons/Environment.php b/src/Addons/Environment.php index e98cd60..646d824 100644 --- a/src/Addons/Environment.php +++ b/src/Addons/Environment.php @@ -18,7 +18,7 @@ class Environment implements AddonInterface */ public function getName(): string { - return 'environment'; + return 'Environment'; } /** diff --git a/src/Addons/Headers.php b/src/Addons/Headers.php index 9c4414b..7888a04 100644 --- a/src/Addons/Headers.php +++ b/src/Addons/Headers.php @@ -16,7 +16,7 @@ class Headers implements AddonInterface */ public function getName(): string { - return 'headers'; + return 'Headers'; } /**