nxsspryker / sentry
3.1.1
2018-09-04 19:45 UTC
Requires
- php: >=7.1.0
- nxsspryker/error-handler: ^1.0.0
- sentry/sentry: ^1.9.0
- spryker/error-handler: ^2.1.0
- spryker/kernel: ^3.0.0
Requires (Dev)
README
Spryker 模块,用于添加 Sentry 错误监控。
安装
composer require nxsspryker/sentry
对于 PHP 跟踪,您需要在 NxsErrorHandlerDependencyProvider 中注册处理器。
<?php namespace Pyz\Service\NxsErrorHandler; use NxsSpryker\Service\NxsErrorHandler\NxsErrorHandlerDependencyProvider as NxsSpyNxsErrorHandlerDependencyProvider; use NxsSpryker\Service\Sentry\Business\Model\Handler\ErrorHandler; use NxsSpryker\Service\Sentry\Business\Model\Handler\ExceptionHandler; use NxsSpryker\Service\Sentry\Business\Model\Handler\ShutdownHandler; class NxsErrorHandlerDependencyProvider extends NxsSpyNxsErrorHandlerDependencyProvider { /** * @return array */ protected function getErrorHandlerPlugins(): array { return [ new ErrorHandler() ]; } /** * @return array */ protected function getExceptionHandlerPlugins(): array { return [ new ExceptionHandler() ]; } /** * @return array */ protected function getShutdownHandlerPlugins(): array { return [ new ShutdownHandler() ]; } }
对于 JS 跟踪,您必须在 ShopApplicationDependencyProvider 中激活小部件
<?php namespace Pyz\Yves\ShopApplication; use NxsSpryker\Yves\SentryWidget\Plugin\Provider\SentryWidgetPlugin; use SprykerShop\Yves\ShopApplication\ShopApplicationDependencyProvider as SprykerShopApplicationDependencyProvider; class ShopApplicationDependencyProvider extends SprykerShopApplicationDependencyProvider { /** * @return string[] */ protected function getGlobalWidgetPlugins(): array { return [ // ... SentryWidgetPlugin::class ]; } }
同时,您还需要在模板中添加小部件
{{ widgetGlobal('SentryWidgetPlugin') }}
配置
您可以通过实现 \NxsSpryker\Yves\Sentry\Dependency\Plugin\SentryClientPluginInterface 来扩展客户端,并使用自有的插件。您可以将它们添加到 SentryDependencyProvider。
同时,您还需要在 config_default.php 中将 "NxsSpryker" 添加为项目命名空间。
您需要在配置中配置 PHP 的 Sentry-项目
use NxsSpryker\Service\Sentry\SentryConfig; $config[SentryConfig::URL_KEY] = 'abc'; $config[SentryConfig::URL_DOMAIN] = 'sentry.io'; $config[SentryConfig::URL_PROJECT] = 'myproject'; $config[SentryConfig::IS_ACTIVE] = true; $config[SentryConfig::CLIENT_URL] = sprintf( 'https://%s@%s/%s', $config[SentryConfig::URL_KEY], $config[SentryConfig::URL_DOMAIN], $config[SentryConfig::URL_PROJECT] );
您需要在配置中配置 JS 的 Sentry-项目
use NxsSpryker\Yves\SentryWidget\SentryWidgetConfig; $config[SentryWidgetConfig::URL_KEY] = 'abc'; $config[SentryWidgetConfig::URL_DOMAIN] = 'sentry.io'; $config[SentryWidgetConfig::URL_PROJECT] = 'myproject'; $config[SentryWidgetConfig::JS_IS_ACTIVE] = true; $config[SentryWidgetConfig::JS_CLIENT_URL] = sprintf( 'https://%s@%s/%s', $config[SentryWidgetConfig::URL_KEY], $config[SentryWidgetConfig::URL_DOMAIN], $config[SentryWidgetConfig::URL_PROJECT] );