PHP code example of diginov / craft-sentry-logger

1. Go to this page and download the library: Download diginov/craft-sentry-logger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

diginov / craft-sentry-logger example snippets




use craft\helpers\App;

return [

    '*' => [
        'enabled' => false,
        'anonymous' => false,
        'dsn' => App::env('SENTRY_DSN'),
        'release' => App::env('SENTRY_RELEASE'),
        'environment' => App::env('SENTRY_ENVIRONMENT'),
        'levels' => ['error', 'warning'],
        'exceptCodes' => [403, 404],
        'exceptPatterns' => [],
    ],

    'staging' => [
        'enabled' => true,
    ],

    'production' => [
        'enabled' => true,
    ],

];



use craft\helpers\App;
use diginov\sentrylogger\log\SentryTarget;

return [

    'components' => [
        'log' => [
            'targets' => [
                'sentry' => function() {
                    if (!class_exists(SentryTarget::class)) {
                        return null;
                    }

                    return Craft::createObject([
                        'class' => SentryTarget::class,
                        'enabled' => App::env('CRAFT_ENVIRONMENT') !== 'dev',
                        'anonymous' => false,
                        'dsn' => App::env('SENTRY_DSN'),
                        'release' => App::env('SENTRY_RELEASE'),
                        'environment' => App::env('SENTRY_ENVIRONMENT'),
                        'levels' => ['error', 'warning'],
                        'exceptCodes' => [403, 404],
                        'exceptPatterns' => [],
                    ]);
                },
            ],
        ],
    ],

];