Skip to content

Commit 41818fb

Browse files
committed
Log gate response
Summary: For better visibility and contxt in Sentry, log the response sent to the automated service with how the notification has been processed. Test Plan: - Units tests added to omnitools for the toArray() method - Once deployed, Sentry should get two new new log.info entries Reviewers: dereckson Reviewed By: dereckson Differential Revision: https://devcentral.nasqueron.org/D2957
1 parent 8388a67 commit 41818fb

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

app/Actions/ActionsReport.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Nasqueron\Notifications\Actions;
44

5+
use Keruald\OmniTools\Collections\HashMap;
6+
57
class ActionsReport {
68
/**
79
* List of actions
@@ -79,6 +81,13 @@ public function containsError () : bool {
7981
/// Output
8082
///
8183

84+
/**
85+
* Gets an array representation of the current instance
86+
*/
87+
public function toArray() : array {
88+
return HashMap::from($this)->toArray();
89+
}
90+
8291
/**
8392
* Gets a JSON string representation of the current instance
8493
*/

app/Http/Controllers/Gate/GateController.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Nasqueron\Notifications\Http\Controllers\Gate;
44

5+
use Nasqueron\Notifications\Actions\ActionsReport;
56
use Nasqueron\Notifications\Config\Features;
67
use Nasqueron\Notifications\Config\Services\Service;
78
use Nasqueron\Notifications\Facades\Services;
@@ -75,10 +76,21 @@ protected function renderReport () : BaseResponse {
7576

7677
$report = App::make('report');
7778
$statusCode = $report->containsError() ? 503 : 200;
79+
80+
$this->logResponse($report, $statusCode);
81+
7882
return Response::json($report)
7983
->setStatusCode($statusCode);
8084
}
8185

86+
/**
87+
* Logs the action reports sent as response by the controller
88+
*/
89+
protected function logResponse (ActionsReport $report, int $statusCode) : void {
90+
Log::info("[Gate] Actions report.", $report->toArray());
91+
Log::info("[Gate] Response is HTTP $statusCode");
92+
}
93+
8294
///
8395
/// Credentials
8496
///

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"keruald/github": "^0.2.1",
1818
"keruald/broker": "^0.5.0",
1919
"keruald/mailgun": "^0.1.0",
20+
"keruald/omnitools": "^0.8.0",
2021
"netresearch/jsonmapper": "^1.1.1",
2122
"sentry/sentry-laravel": "^3.2"
2223
},

0 commit comments

Comments
 (0)