Skip to content

Commit

Permalink
Merge pull request #267 from silinternational/release/6.6.0
Browse files Browse the repository at this point in the history
Release 6.6.0 - Sentry logging
  • Loading branch information
briskt authored Oct 10, 2023
2 parents 6add3e3 + da546c2 commit f806c6e
Show file tree
Hide file tree
Showing 7 changed files with 1,256 additions and 349 deletions.
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Added
-

### Changed
-

### Deprecated
-

### Removed
-

### Fixed
-

### Security
-

---

### Feature PR Checklist
- [ ] Documentation (README, etc.)
- [ ] Unit tests created or updated
- [ ] Run `make composershow`

### Release PR Checklist
- [ ] Update version number in main.php Sentry configuration
217 changes: 0 additions & 217 deletions CHANGELOG.md

This file was deleted.

27 changes: 23 additions & 4 deletions application/common/config/main.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use notamedia\sentry\SentryTarget;
use Sentry\Event;
use Sil\JsonLog\target\EmailServiceTarget;
use Sil\JsonLog\target\JsonStreamTarget;
use Sil\PhpEnv\Env;
Expand All @@ -18,7 +20,6 @@
$alertsEmail = Env::get('ALERTS_EMAIL');
$alertsEmailEnabled = Env::get('ALERTS_EMAIL_ENABLED');
$emailSignature = Env::get('EMAIL_SIGNATURE', Env::get('FROM_NAME'));
$appEnv = Env::get('APP_ENV');
$idpName = Env::get('IDP_NAME');
$idpDisplayName = Env::get('IDP_DISPLAY_NAME', $idpName);
$recaptchaRequired = Env::get('RECAPTCHA_REQUIRED', true);
Expand Down Expand Up @@ -134,16 +135,16 @@
'logVars' => [], // Disable logging of _SERVER, _POST, etc.
'message' => [
'to' => $alertsEmail ?? '(disabled)',
'subject' => 'ALERT - ' . $idpName . ' PW [env=' . $appEnv . ']',
'subject' => 'ALERT - ' . $idpName . ' PW [env=' . YII_ENV . ']',
],
'baseUrl' => $emailServiceConfig['baseUrl'],
'accessToken' => $emailServiceConfig['accessToken'],
'assertValidIp' => $emailServiceConfig['assertValidIp'],
'validIpRanges' => $emailServiceConfig['validIpRanges'],
'enabled' => $alertsEmailEnabled,
'prefix' => function($message) use ($appEnv) {
'prefix' => function($message) {
$prefixData = [
'env' => $appEnv,
'env' => YII_ENV,
];

// There is no user when a console command is run
Expand All @@ -169,6 +170,24 @@
},
'exportInterval' => 1,
],
[
'class' => SentryTarget::class,
'enabled' => !empty(Env::get('SENTRY_DSN')),
'dsn' => Env::get('SENTRY_DSN'),
'levels' => ['error'],
'context' => true,
// Additional options for `Sentry\init`
// https://docs.sentry.io/platforms/php/configuration/options
'clientOptions' => [
'attach_stacktrace' => false, // stack trace identifies the logger call stack, not helpful
'environment' => YII_ENV,
'release' => '[email protected]',
'before_send' => function (Event $event) use ($idpName): ?Event {
$event->setExtra(['idp' => $idpName]);
return $event;
},
],
],
],
],
'emailer' => [
Expand Down
6 changes: 4 additions & 2 deletions application/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"fillup/fake-bower-assets": "2.0.9",
"icawebdesign/hibp-php": "~5.1.1",
"codemix/yii2-streamlog": "^1.3",
"codeception/module-phpbrowser": "^1.0||^2.0||^3.0"
"codeception/module-phpbrowser": "^1.0||^2.0||^3.0",
"notamedia/yii2-sentry": "^1.7"
},
"require-dev": {
"yiisoft/yii2-debug": "*",
Expand All @@ -51,7 +52,8 @@
"bower-asset-library": "vendor/bower"
},
"allow-plugins": {
"yiisoft/yii2-composer": true
"yiisoft/yii2-composer": true,
"php-http/discovery": false
}
},
"autoload": {
Expand Down
Loading

0 comments on commit f806c6e

Please sign in to comment.