samueletur/laravel-error-tracking-to-telegram

This package send an alert notification to telegram when a error from laravel is executed

v1.0.1 2023-11-02 08:04 UTC

This package is auto-updated.

Last update: 2024-05-01 00:12:08 UTC


README

Latest Version on Packagist Software License Total Downloads

Installation

You can install the package via composer:

composer require samueletur/laravel-error-tracking-to-telegram

Call LaravelErrorTrackingToTelegram in app\Exceptions\Handler inside register function

    public function register(): void
    {
        $this->reportable(function (Throwable $e) {
            LaravelErrorTrackingToTelegram::send($e);
        });
    }

Configuration

Configuring for use within your Laravel app takes place mainly in the config/error_tracking_telegram.php file. Each item is broken down in the comment lines above it, describing what that item does and what value(s) it's anticipating.

Create and set parameters on .env

TELEGRAM_BOT_TOKEN='XXXXXXXXXX:XXXXXXXxxxXXxxXxXxx-xXxxXXxXXxXXxxx'
TELEGRAM_CHAT_ID=999999999

There are also two .env variables you'll need to set depending on if you use notifications:

  • TELEGRAM_BOT_TOKEN, the token of telegram app
  • TELEGRAM_CHAT_ID, ID from your chat or group room.

Tip: How to create a bot token on Telegram.

  1. Crie uma conta no Telegram
  2. Inicie uma conversa com o @botfather (lembre-se que os robôs oficiais do Telegram têm um tique azul do lado do nome)
  3. Clique em iniciar
  4. Escolha o comando /newbot
  5. Escolha o nome do seu chatbot e faça as configurações gerais

You can publish the config file with:

php artisan vendor:publish --tag=error_tracking_telegram_config

This is the contents of the published config file:

return [
    'telegram_bot_token' => env('TELEGRAM_BOT_TOKEN'),
    'telegram_chat_id' => env('TELEGRAM_CHAT_ID')
];

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits