Componette

Componette

rootpd

rootpd / nette-sentry 2.2.0

Nette Sentry logger extension

download-cloud-line composer require rootpd/nette-sentry

Nette Sentry

Build Status

Tracy logger extension capable of logging messages and errors to Sentry.

Note: If you have debug mode enabled in your application, logger will only send \Tracy\Debugger::log() messages to sentry. Any exception ending with Tracy's blue screen is not going to be logged as you can see the exception details directly.

Installation

Install package via Composer:

composer require rootpd/nette-sentry

Configuration

Enable and configure the extension in Nette config file:

extensions:
	# ...
	sentry: Rootpd\NetteSentry\DI\SentryExtension

sentry:
    dsn: https://123abc123abc123abc123abc123abc12@sentry.io/3 # required
    environment: production # optional, defaults to "local"
    user_fields: # optional, defaults to empty array; Nette's identity ID is being sent automatically
        - email
    session_sections: # optional, list of session sections to track
        - mySection
    priority_mapping:
        mypriority: warning

Priority-Severity mapping

Sometimes you might need to use custom priority when logging the error in Nette:

\Tracy\Debugger::log('foo', 'mypriority');

Sentry only allows strict set of severities. By default any message with unknown (non-standard) severity is not being logged.

You can map your custom priority to Sentry's severity in config by using priority_mapping as shown in the example.

The allowed set of Sentry severities can be checked in Sentry's PHP repository.

Usage

Once enabled as extension, you can continue to throw exceptions without any change. To log message please use \Tracy\Debugger::log() method.

  • 2.2.0 2.2.0

    • Updated sentry/sentry to v4.
    • Bumped minimum version of PHP to 8.1.
  • 2.0.0 2.0.0

    • BREAKING: Removed support for Nette 2.
    • BREAKING: Removed support for PHP <8.0
    • BREAKING: Changed session section tracking.
      • Sections are not tracked automatically anymore, but the developer needs to provide them in the extension configuration. See session_sections property of the configuration object in the README.
    • Added support for traces sample rate configuration.
  • 1.3.1 1.3.1

    • Fixed session ID to be different on every request due to accessing identity very early in the initialization process. #7 #5
  • 1.2.0 1.2.0

    • Fixed issue when setUser was called also for logged out users. Now it's only provided if the user is actually logged in.
    • Fixed other types of log value than string.
    • Library sentry/sdk was bumped to 3.0.
    • Added tests, Makefile and Travis CI definition.
bar-chart-fill

Statistics

download-cloud-fill
74825
star-fill
8
bug-fill
1
flashlight-fill
84d
price-tag-2-line

Badges

guide-fill

Dependencies

ext-iconv (*)
php (^7.1)
nette/di (^2.4)
Componette Componette felix@nette.org