Skip to content

Commit

Permalink
Add Hostname addon to include hostname in error event payload
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzotikov committed Nov 11, 2024
1 parent c5cfdb2 commit 59c0103
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down
35 changes: 35 additions & 0 deletions src/Addons/Hostname.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Hawk\Addons;

/**
* Class Hostname
*
* @package Hawk\Addons
*/
class Hostname implements AddonInterface
{
/**
* @inheritdoc
*/
public function getName(): string
{
return 'env';
}

/**
* @inheritDoc
*/
public function resolve(): array
{
$hostname = gethostname();

if ($hostname === false) {
return [];
}

return ['hostname' => $hostname];
}
}
2 changes: 2 additions & 0 deletions src/Catcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Hawk;

use Hawk\Addons\Headers;
use Hawk\Addons\Hostname;
use Hawk\Transport\CurlTransport;
use Throwable;

Expand Down Expand Up @@ -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());

Expand Down

0 comments on commit 59c0103

Please sign in to comment.