websupport / yii-sentry
为与 Sentry 日志 API 通信而设计的 Yii 框架层
dev-master / 0.x-dev
2023-03-21 10:34 UTC
Requires
- php: >=7.1
- guzzlehttp/psr7: ^1.6 || ^2.0
- php-http/curl-client: ^2.0
- sentry/sdk: ^3.1
- yiisoft/yii: ^1.1.18
Requires (Dev)
- roave/security-advisories: dev-latest
Conflicts
- yiisoft/yii2: *
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
类初始化后立即使用它。