2017-25 © Pedro Peláez
 

library yii2-sentry

A Yii2 component for Sentry (http://getsentry.com)

image

otsec/yii2-sentry

A Yii2 component for Sentry (http://getsentry.com)

  • Tuesday, February 28, 2017
  • by otsec
  • Repository
  • 1 Watchers
  • 0 Stars
  • 110 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 124 % Grown

The README.md

Yii2 Sentry Component

Automatically catch all PHP and JS errors and send them to Sentry., (*1)

Supports PHP SDK and JavaScript Client., (*2)

Installation

Install via composer., (*3)

composer require --prefer-dist otsec/yii2-sentry

Add component to your application configuration:, (*4)

return [
    'components' => [
        ...

        'sentry' => [
            'class' => 'otsec\yii2\sentry\Raven',
            'dsn' => 'https://****@sentry.io/12345',
        ],
    ],
];

Do not forget to bootstrap it to register event handlers., (*5)

return [
    'bootstrap' => ['sentry'],

    ...
];

You are ready to go!, (*6)

Configuration

There are a lot of options profived., (*7)

'components' => [
    ...

    'sentry' => [
        ...

        // Register Raven_Client error and exception handler on init.
        // Enabled by default
        'enableErrorHandler' => true,

        // Options will be passed to Raven_Client
        'options' => [],

        // Cathing JS errors is disabled by default.
        'enableClientScript' => false,

        // Options for client library.
        'clientOptions' => [],

        // DSN for client libary. 
        // Will be extracted from private DSN if empty.
        'publicDsn' => null,

        // Client library will be loaded from CDN by default.
        // You can use any other asset bundle if you want. 
        'assetBundle' => 'otsec\yii2\sentry\RavenCdnAsset',

        // Asset bundles for Bower and NPM already created but you have to 
        // install assets before you will use it.
        // 'assetBundle' => 'otsec\yii2\sentry\RavenBowerAsset',
        // 'assetBundle' => 'otsec\yii2\sentry\RavenNpmAsset',
    ],
],

Usage

Component registers error handler by default. It will catch any appeared error or not captured exception., (*8)

Captured exceptions can be handled manually., (*9)

try {
    throw new Exception('Oh, shit!');
} catch (Exception $e) {
    Yii::$app->sentry->captureException($e, ['extra' => 'data']);
}

There are some methods to work with context., (*10)

Yii::$app->sentry->extraContext($data);
Yii::$app->sentry->tagsContext($data);
Yii::$app->sentry->userContext($data);
Yii::$app->sentry->clearContext();

Or you can get access to Raven_Client itself., (*11)

$ravenClient = Yii::$app->sentry->getClient();

The Versions

28/02 2017

dev-master

9999999-dev https://github.com/otsec/yii2-sentry

A Yii2 component for Sentry (http://getsentry.com)

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Artem Belov

yii2 raven sentry error crash

28/02 2017

0.9.0

0.9.0.0 https://github.com/otsec/yii2-sentry

A Yii2 component for Sentry (http://getsentry.com)

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Artem Belov

yii2 raven sentry error crash