Giter Site home page Giter Site logo

hawk.php's Introduction

Hawk PHP

PHP errors Catcher for Hawk.so.

Setup

  1. Register an account, create a Project and get an Integration Token.

  2. 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://ifmo.su

License

MIT

hawk.php's People

Contributors

khaydarov avatar talyguryn avatar n0str avatar ilyatos avatar nespecc avatar envomer avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.