Skip to content

Commit

Permalink
Merge pull request #18 from lukeyouell/develop-v2
Browse files Browse the repository at this point in the history
1.5.1
  • Loading branch information
lukeyouell authored Mar 12, 2019
2 parents 27cb1d7 + d8b5ee9 commit 43d041b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## 1.5.1 - 2019-03-12

### Added
- Reinstated the `enabled` setting [#17](https://github.com/lukeyouell/craft-sentry/issues/17)

## 1.5.0 - 2019-02-14

### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Here’s what that config file might look like along with a list of all of the p
<?php

return [
'enabled' => true,
'clientDsn' => '$SENTRY_DSN', // NOT getenv('SENTRY_DSN')
'environment' => '$SENTRY_ENVIRONMENT', // NOT getenv('SENTRY_ENVIRONMENT')
'excludedCodes' => '400, 404, 429', // Comma-separated list
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lukeyouell/craft-sentry",
"description": "Error tracking that helps developers monitor and fix crashes in real time. Iterate continuously. Boost efficiency. Improve user experience.",
"type": "craft-plugin",
"version": "1.5.0",
"version": "1.5.1",
"keywords": [
"craft",
"cms",
Expand Down
6 changes: 6 additions & 0 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class Settings extends Model
// Public Properties
// =========================================================================

/**
* @var boolean
*/
public $enabled = true;

/**
* @var string
*/
Expand All @@ -33,6 +38,7 @@ class Settings extends Model
public function rules()
{
return [
['enabled', 'boolean'],
[['clientDsn', 'environment', 'excludedCodes'], 'string'],
[['clientDsn', 'environment'], 'required'],
];
Expand Down
5 changes: 5 additions & 0 deletions src/services/SentryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public function init()

public function handleException($exception)
{
if (!$this->settings->enabled) {
Craft::info('Exception not reported to Sentry as the plugin is disabled.', $this->plugin->handle);
return;
}

if (!$this->settings->clientDsn) {
Craft::error('Failed to report exception due to missing client key (DSN)', $this->plugin->handle);
return;
Expand Down
12 changes: 11 additions & 1 deletion src/templates/settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@

{% from _self import configWarning %}

{{ forms.autosuggestField({
{{ forms.lightswitchField({
first: true,
label: "Enabled"|t(plugin.handle),
instructions: "If disabled, the plugin will not report exceptions to Sentry."|t(plugin.handle),
id: 'enabled',
name: 'enabled',
on: settings.enabled,
disabled: 'enabled' in overrides,
warning: 'enabled' in overrides ? configWarning(plugin, 'enabled')
}) }}

{{ forms.autosuggestField({
required: true,
label: "Client Key (DSN)"|t(plugin.handle),
instructions: "To send data to Sentry you will need to configure an SDK with a client key which can be found in your [project settings](https://sentry.io/settings/) underneath 'Client Keys (DSN)'."|t(plugin.handle),
Expand Down

0 comments on commit 43d041b

Please sign in to comment.