violet88 / bugsnag-silverstripe-vue
一个模块,用于在 SilverStripe 项目中使用 Bugsnag 与 Vue 一起。
Requires
- php: ^7.4 || ^8.0
- bugsnag/bugsnag: ^3.0
- guzzlehttp/guzzle: ^7.0
- npm-asset/bugsnag-js: v7.18.0
- npm-asset/bugsnag-vue: 1.0.1
- silverstripe/admin: ^1.0
- silverstripe/framework: ^4.0
- silverstripe/recipe-cms: ^4.11
Requires (Dev)
- phpunit/phpunit: ^9.5.24
- squizlabs/php_codesniffer: ^3.0
- dev-master / 2.x-dev
- v1.0.1
- v1.0
- dev-development
- dev-dependabot/npm_and_yarn/json5-2.2.3
- dev-dependabot/composer/silverstripe/versioned-admin-1.11.1
- dev-dependabot/composer/silverstripe/framework-4.11.14
- dev-dependabot/composer/silverstripe/cms-4.11.3
- dev-dependabot/composer/silverstripe/assets-1.11.1
- dev-dependabot/composer/silverstripe/admin-1.11.3
This package is auto-updated.
Last update: 2024-09-09 14:03:54 UTC
README
需求
- SilverStripe ^4.0
- silverstripe/framework
- bugsnag/bugsnag
- guzzlehttp/guzzle
- silverstripe/admin
开发需求
NPM 需求
安装
要安装,首先将以下内容添加到您的 composer.json 文件中
"repositories": [ { "type": "composer", "url": "https://asset-packagist.org" } ],
然后运行以下命令
composer require violet88/bugsnag-silverstripe-vue
安装 composer 包后,安装模块的 node 依赖项非常重要。要简化此过程,请将以下内容添加到您的 composer.json 文件中
"scripts": { "install-bugsnag-packages": [ "cd vendor/violet88/bugsnag-silverstripe-vue && npm install" ] }
然后运行以下命令
composer install-bugsnag-packages
许可证
请参阅 许可证
文档
配置
对于基本使用,将以下内容添加到您的 .env 文件中
在本地运行时,为了防止 Bugsnag 被错误填满,请将 BUGSNAG_ACTIVE 设置为 false 或不声明它。(如果不声明,则不会将消息发送到 Bugsnag。
BUGSNAG_API_KEY=<YOUR BUGSNAG API KEY> BUGSNAG_STANDARD_SEVERITY=<STANDARD SEVERITY LEVEL FOR BUGSNAG (info OR warning OR error)> BUGSNAG_ACTIVE=<true OR false, depending on whether bugsnag should be ACTIVE>
要使用 BugsnagLogger 作为标准错误记录器,请将以下内容添加到您的配置 yaml 中
SilverStripe\Core\Injector\Injector: Psr\Log\LoggerInterface: calls: BugsnagHandler: [pushHandler, ['%$BugsnagHandler']] BugsnagHandler: class: Violet88\BugsnagModule\BugsnagLogger constructor: - '%$Violet88\BugsnagModule\Bugsnag'
要使用 CLI 命令将您的当前发布修订版发送到 Bugsnag,请将以下内容添加到您的路由 yaml 中
SilverStripe\Control\Director: rules: 'bugsnag//build': 'Violet88\BugsnagModule\BugsnagController' 'bugsnag//initial': 'Violet88\BugsnagModule\BugsnagController'
为了使模块的 Vue 部分正常工作,您必须运行
npm install dotenv webpack webpack-bugsnag-plugins
并将以下内容添加到您的 webpack.mix.js 中
require('dotenv').config(); let webpack = require('webpack'); const { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins'); const PACKAGE_VERSION = process.env.npm_package_version let dotenvplugin = new webpack.DefinePlugin({ 'process.env': { 'BUGSNAG_API_KEY': JSON.stringify(process.env.BUGSNAG_API_KEY), 'BUGSNAG_ACTIVE': JSON.stringify(process.env.BUGSNAG_ACTIVE), 'VERSION': JSON.stringify(PACKAGE_VERSION) } }); mix.options({legacyNodePolyfills: false}) mix.webpackConfig({ output: { library: 'BugsnagVue', libraryTarget: 'umd', umdNamedDefine: true, globalObject: 'this' }, plugins: [ dotenvplugin, new BugsnagSourceMapUploaderPlugin({ apiKey: process.env.BUGSNAG_API_KEY, appVersion: PACKAGE_VERSION ?? '1.0.0', overwrite: true, publicPath: '*' }) ] });
同时确保生成 sourcemaps,例如,通过在 mix.js() 之间添加 .sourceMaps(true, 'source-map')
。这可以看起来像这样
mix.sourceMaps(true, 'source-map').js([ `${theme}/javascript/bundle.js`, //'vendor/violet88/silverstripe-bugsnag-module-vue/src/js/BugsnagVue.js' ], `${theme}/dist/js/bundle.js`);
然后添加以下内容到您的根 composer.json 中
"scripts": { "install-bugsnag-packages": "cd vendor/violet88/bugsnag-silverstripe-vue && npm install" }
然后运行以下命令
composer run-script install-bugsnag-packages
基本用法
PHP
要向 Bugsnag 发送基本错误,请使用以下代码
use Violet88\BugsnagModule\Bugsnag; use Exception; use SilverStripe\Core\Injector\Injector; try{ //do something } catch (Exception $e) { $bugsnag = Injector::inst()->get(Bugsnag::class); $bugsnag->sendException($e); }
JavaScript
要向 Bugsnag 发送基本错误,请使用以下代码
// Here it is important that the require is pointing to the correct path. Point it to the path where you've installed the composer package. const Bugsnag = require('/vendor/Violet88/BugsnagVueModule/src/js/BugsnagVue.js'); Bugsnag.start(); try{ something.risky(); }catch(e){ Bugsnag.notify(e); }
维护者
- Sven van der Zwet s.vanderzwet@student.avans.nl
错误追踪器
错误在本存储库的问题部分跟踪。在提交问题之前,请阅读现有问题以确保您的错误是唯一的。
如果问题看起来像是一个新的错误
- 创建一个新的问题
- 为 'Bugs' 选择问题模板
- 遵循模板中的说明
请直接向模块维护者报告安全问题。请勿在错误追踪器中提交安全问题。
开发和贡献
如果您想向模块做出贡献,请确保您提出一个拉取请求并与模块维护者讨论。
请随时加入 Slack 社区: 加入 Slack