skater4/laravel-sentry-notifications

将Laravel Sentry异常发送到消息传递者

1.0.9 2024-10-01 10:48 UTC

This package is auto-updated.

Last update: 2024-10-01 10:50:04 UTC


README

Chat on Telegram Latest Version on Packagist Software License Quality Score Total Downloads

此包使您能够轻松将Sentry通知发送到Laravel中的不同通道。

内容

安装

您可以通过Composer安装此包

composer require skater4/laravel-sentry-notifications

设置Sentry

在基本Sentry设置完成后,您需要在.env文件中添加Issues URL

SENTRY_ISSUES_URL=https://sentry.io/organizations/sentry/issues

设置Telegram

要使用Telegram进行通知,您首先需要设置您的Telegram机器人并获取Chat\Channel ID。请按照以下说明

然后添加以下设置到.env

SENTRY_TELEGRAM_BOT_TOKEN=<your:bot-token>
SENTRY_TELEGRAM_CHAT_ID=<your_chat_id>
SENTRY_NOTIFICATION_SERVICE=telegram

用法

只需将以下代码添加到异常处理中即可报告

app(SentryNotifier::class)->reportSentryNotification($exception);

例如,在默认异常处理程序中的报告方法

public function report(Throwable $exception)
{
    if (app()->bound('sentry') && $this->shouldReport($exception)) {
        app(SentryNotifier::class)->reportSentryNotification($exception);
    }

    parent::report($exception);
}

替代方案

对于高级用法,请考虑使用laravel-notification-channels代替。

变更日志

请参阅CHANGELOG以获取更多关于最近更改的信息。

测试

$ composer test

贡献

请参阅CONTRIBUTING以获取详细信息。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。