codex-team / hawk.php
PHP errors Catcher module for Hawk.so
Installs: 16 938
Dependents: 1
Suggesters: 0
Security: 0
Stars: 20
Watchers: 8
Forks: 4
Open Issues: 7
Requires
- php: ^7.2 || ^8.0
- ext-curl: *
- ext-json: *
- jean85/pretty-package-versions: ^1.5 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15
- phpunit/phpunit: ^8.2
- symfony/var-dumper: ^5.2
This package is auto-updated.
Last update: 2024-12-05 14:38:54 UTC
README
PHP errors Catcher for Hawk.so.
Setup
-
Register an account, create a Project and get an Integration Token.
-
Install SDK via composer to install the Catcher
Catcher provides support for PHP 7.2 or later
$ composer require codex-team/hawk.php
Configuration
\Hawk\Catcher::init([ 'integrationToken' => 'your integration token' ]);
After initialization you can set user
or context
for any event that will be send to Hawk
\Hawk\Catcher::get() ->setUser([ 'name' => 'user name', 'photo' => 'user photo', ]) ->setContext([ ... ]);
Send events and exceptions manually
Use sendException
method to send any caught exception
try { throw new Exception("Error Processing Request", 1); } catch (Exception $e) { \Hawk\Catcher::get()->sendException($e); }
Use sendEvent
method to send any data (logs, notices or something else)
\Hawk\Catcher::get()->sendMessage('your message', [ ... // Context ]);
Filtering sensitive information
Use the beforeSend
hook to filter any data you don't want to send to Hawk. Use setters to clear any property.
\Hawk\Catcher::init([ // ... 'beforeSend' => function (\Hawk\EventPayload $eventPayload) { $user = $eventPayload->getUser(); if (!empty($user['email'])){ unset($user['email']); $eventPayload->setUser($user); } return $eventPayload; } ]);
Issues and improvements
Feel free to ask questions or improve the project.
Links
Repository: https://github.com/codex-team/hawk.php
Report a bug: https://github.com/codex-team/hawk.php/issues
Composer Package: https://packagist.org/packages/codex-team/hawk.php
CodeX Team: https://codex.so
License
MIT