violet88/bugsnag-silverstripe

A module to use Bugsnag in SilverStripe projects.

Installs: 468

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 0

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

v1.4.0 2024-01-02 09:32 UTC

README

CI codecov.io Scrutinizer Code Quality Build Status Code Intelligence Status

Requirements

Dev requirements

Installation

To install run the following command

composer require violet88/bugsnag-silverstripe

Note: Make sure the required modules are installed before using the module.

License

See License

Documentation

Configuration

For base use, add the following to your .env file

When running local, to prevent Bugsnag from being filled with errors, set BUGSNAG_ACTIVE to false OR do not declare it. (If not declared messages will also not be sent to 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>
BUGSNAG_RELEASE_STAGE=<RELEASE STAGE FOR YOUR CURRENT REVISION>

For using the BugsnagLogger as the standard error logger, add the following to your configuration yaml

SilverStripe\Core\Injector\Injector:
  Psr\Log\LoggerInterface:
    calls:
      BugsnagHandler: [pushHandler, ['%$BugsnagHandler']]
  BugsnagHandler:
    class: Violet88\BugsnagModule\BugsnagLogger
    constructor:
      - '%$Violet88\BugsnagModule\Bugsnag'
SilverStripe\SiteConfig\SiteConfig:
  extensions:
    - Violet88\BugsnagModule\BugsnagSiteConfigExtension

For using the CLI command to sent your current release revision to Bugsnag, add the following to your routes yaml

SilverStripe\Control\Director:
    rules:
        'bugsnag//build': 'Violet88\BugsnagModule\BugsnagController'
        'bugsnag//initial': 'Violet88\BugsnagModule\BugsnagController'

Basic usage

For sending a basic error to Bugsnag, use the following code

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);
}

Maintainers

Bugtracker

Bugs are tracked in the issues section of this repository. Before submitting an issue please read over existing issues to ensure yours is unique.

If the issue does look like a new bug:

  • Create a new issue
  • Choose the issue template for 'Bugs'
  • Follow the instructions in the template

Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker.

Development and contribution

If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.

Feel free to join the community on slack: Join Slack