承接 statikbe/craft-sentry 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

statikbe/craft-sentry

最新稳定版本:5.1.2

Composer 安装命令:

composer require statikbe/craft-sentry

包简介

Sentry.io integration for Craft CMS

README 文档

README

Sentry.io integration for Craft CMS. Inspired by born05/craft-sentry, but with our own twist.

Installation

To install the plugin, follow these instructions in your terminal.

cd /path/to/project
composer require statikbe/craft-sentry
./craft plugin/install craft-sentry

Configration

Create a config/craft-sentry.php config file with the following contents:

<?php

return [
    'enabled'       => true,
    'anonymous'     => true,
    'clientDsn'     => getenv('SENTRY_DSN') ?: 'https://example@sentry.io/123456789',
    'excludedCodes' => ['400', '404', '429'],
    'excludedExceptions' => [],
    'release'       => getenv('SENTRY_RELEASE') ?: null,
];

Usage

To let Sentry log your exception, you don't really need to do anything. Install the plugin and add your DSN and you're set.

When you're writing your own custom code and throwing your own exception, you'll also want to catch those and send them to Sentry. That can be done like this:

<?php

use statikbe\sentry\Sentry;
use yii\base\InvalidConfigException; // Don't copy this line, it's just here to make the example theoractically correct ;) 

try {
    throw new InvalidConfigException("Something went wrong here...");
} catch (Exception $e) {
    Sentry::handleException($e);
}

The plugin works for exceptions thrown in web requests as well as console requests. For web requests, the url where the error happened is included.

Excluding specific exceptions

Using the excludedExceptions, you can stop specific types of exceptions from being logged to Sentry, for example:

'excludedExceptions' => [
    \craft\errors\ImageTransformException::class,
],

Brought to you by Statik.be

统计信息

  • 总下载量: 11.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 8
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-07