Skip to content

Commit

Permalink
Merge pull request #299 from silinternational/sentry
Browse files Browse the repository at this point in the history
Fix Sentry logging details
  • Loading branch information
briskt authored Dec 11, 2024
2 parents dad8108 + fab7e97 commit 951dd0e
Show file tree
Hide file tree
Showing 13 changed files with 735 additions and 723 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ composer:
docker compose run --rm cli composer install

composershow:
docker compose run --rm cli bash -c 'composer show --format=json --no-dev --no-ansi --locked | jq ".locked[] | { \"name\": .name, \"version\": .version }" > dependencies.json'
docker compose run --rm cli bash -c 'composer show --format=json --no-dev --no-ansi --locked | jq "[.locked[] | { \"name\": .name, \"version\": .version }]" > dependencies.json'

composerupdate:
docker compose run --rm cli bash -c "composer update"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ The personnel component is used to look up informaton about users from your comp

1. Create a project on <https://console.developers.google.com/>.
2. Still in the Google Developers Console, create a Service Account.
3. Check "Furnish a new private key" and "Enable G Suite Domain-wide Delegation".
3. Check "Furnish a new private key" and "Enable Google Workspace Domain-wide Delegation".
4. Save the JSON file it provides (containing your private key), but **DO NOT**
store it in public version control (such as in a public GitHub repo).
5. Enable the "Admin SDK" API for your project in the Google Developers Console.
Expand Down Expand Up @@ -136,7 +136,7 @@ The personnel component is used to look up informaton about users from your comp
'emailFieldName' => 'email',
'employeeIdFieldName' => 'employee_id',
'userActiveRecordClass' => '\common\models\User',
'displayName' => 'G Suite',
'displayName' => 'Google Workspace',
]);

For details about what each of those fields is used for, see the documenting
Expand Down
1 change: 1 addition & 0 deletions application/common/components/passwordStore/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ protected function getUserByEmployeeId($employeeId)
'employee_id' => $employeeId,
'email1' => $response['users'][0]['primaryEmail'],
'email2' => $response['users'][1]['primaryEmail'],
'error' => 'Multiple email addresses found in Google Workspace. Cannot resolve.',
]);
throw new \Exception(\Yii::t('app', 'Google.MultipleEmailsFound'), 1560875143);
}
Expand Down
2 changes: 1 addition & 1 deletion application/common/config/local.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ return [
],
[
'class' => Google::class,
'displayName' => 'Acme G Suite',
'displayName' => 'Acme Google Workspace',
'applicationName' => 'Acme IdP',
'jsonAuthFilePath' => '/data/google.json',
'delegatedAdminEmail' => '[email protected]',
Expand Down
7 changes: 6 additions & 1 deletion application/common/config/main.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

use common\components\Emailer;
use notamedia\sentry\SentryTarget;
use Sentry\Event;
use Sil\JsonLog\target\EmailServiceTarget;
use Sil\JsonLog\target\JsonStreamTarget;
use Sil\PhpEnv\Env;
use Sil\Sentry\SentryTarget;
use yii\helpers\ArrayHelper;
use yii\helpers\Json;

Expand Down Expand Up @@ -177,11 +177,16 @@
'dsn' => Env::get('SENTRY_DSN'),
'levels' => ['error'],
'except' => [
'yii\web\HttpException:400', // BadRequest
'yii\web\HttpException:401', // Unauthorized
'yii\web\HttpException:404', // NotFound
'yii\web\HttpException:409', // Conflict
],
'context' => true,
'tagCallback' => function ($tags) use ($idpName): array {
$tags['idp'] = $idpName;
return $tags;
},
// Additional options for `Sentry\init`
// https://docs.sentry.io/platforms/php/configuration/options
'clientOptions' => [
Expand Down
6 changes: 5 additions & 1 deletion application/common/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,11 @@ public function beforeSave($insert): bool
'hide' => $this->hide,
]);
} catch (\Exception $e) {
\Yii::error(['action' => 'personnel update', 'status' => 'error'], __METHOD__);
\Yii::error([
'action' => 'personnel update',
'status' => 'error',
'message' => $e->getMessage(),
], __METHOD__);
}
}

Expand Down
4 changes: 2 additions & 2 deletions application/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"icawebdesign/hibp-php": "~5.1.1",
"codemix/yii2-streamlog": "^1.3",
"codeception/module-phpbrowser": "^1.0||^2.0||^3.0",
"notamedia/yii2-sentry": "^1.7",
"friendsofphp/php-cs-fixer": "^3.0"
"friendsofphp/php-cs-fixer": "^3.0",
"silinternational/yii2-sentry": "^2.0"
},
"require-dev": {
"yiisoft/yii2-debug": "*",
Expand Down
Loading

0 comments on commit 951dd0e

Please sign in to comment.