websupport/yii-sentry

为与 Sentry 日志 API 通信而设计的 Yii 框架层

安装次数: 14,215

依赖项: 0

建议者: 0

安全: 0

星级: 1

关注者: 10

分支: 5

开放问题: 1

类型:yii-extension

dev-master / 0.x-dev 2023-03-21 10:34 UTC

This package is auto-updated.

Last update: 2024-09-21 13:26:49 UTC


README

为与 Sentry 日志 API 通信而设计的 Yii 框架的日志扩展

安装

Yii Sentry 是 composer 库,因此您可以使用以下命令安装最新版本:

composer require websupport/yii-sentry

配置

将以下内容添加到您的应用程序配置中:

PHP 错误报告

'components' => [
    'log' => [
        'class' => \CLogRouter::class,
        'routes' => [
            // your other log routers
            array(
                'class' => \Websupport\YiiSentry\LogRoute::class,
                'levels' => E_ALL,
                'enabled' => !YII_DEBUG,
            ],
        ],
    ],
    'sentry' => [
        'class' => \Websupport\YiiSentry\Client::class,
        'dsn' => '', // Your's DSN from Sentry
    ],
)

JS 错误报告

'preload' => ['sentry'],
'components' => [
    'sentry' => [
        'class' => \Websupport\YiiSentry\Client::class,
        'jsDsn' => '', // Your's DSN from Sentry
    ],
]

将用户上下文发送到 JS

\Websupport\YiiSentry\Client 组件有一个公共方法:setJsUserContext($context),它将 $context 发送到 Raven JS 实例。您可以从系统的任何部分多次调用此方法。然而,推荐的做法是在 CWebUser 类初始化后立即使用它。