Skip to content

Commit 2c0665c

Browse files
authored
Merge pull request #220 from Theodo-UK/feature/58-push-notifications
Feature/58 push notifications
2 parents 14f8d9c + 2691ff3 commit 2c0665c

File tree

9 files changed

+54
-11
lines changed

9 files changed

+54
-11
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ sls-dev-tools is currently being actively maintained. If you find a problem with
5959
- [Shortcuts to AWS Console](#shortcuts-to-aws-console)
6060
- [Changing region using the map](#changing-region-using-the-map)
6161
- [Shortcuts](#shortcuts)
62+
- [Error Notifications](#error-notifications)
6263

6364
[A note on AWS API calls and pricing](#a-note-on-aws-api-calls-and-pricing)\
6465
[Libs](#libs)\
65-
[Contributors ✨](#contributors-)
66+
[Contributors ✨](#contributors-)
6667

6768
## Installation
6869

@@ -196,6 +197,12 @@ Shortcuts
196197
- Pressing "l" will display a box with more statistics on the selected lambda
197198
```
198199

200+
## Error notifications
201+
202+
The tool will notify you when the Lambda you're monitoring errors.
203+
204+
![pushNotification](./img/pushNotification.gif)
205+
199206
# A note on AWS API calls and pricing
200207

201208
This tool does make use of the AWS API to get metrics. Authentication is handled implicitly via the AWS NodeJS SDK. Pricing around Cloudwatch is designed for scale, but be warned that this tool is making calls to AWS.

docs/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ Shortcuts
135135
- Pressing "l" will display a box with more statistics on the selected lambda
136136
```
137137

138+
## Error notifications
139+
140+
The tool will notify you when the Lambda you're monitoring errors.
141+
142+
![pushNotification](./assets/pushNotification.gif)
143+
138144
# A note on AWS API calls and pricing
139145

140146
This tool does make use of the AWS API to get metrics. Authentication is handled implicitly via the AWS NodeJS SDK. Pricing around Cloudwatch is designed for scale, but be warned that this tool is making calls to AWS.

docs/assets/pushNotification.gif

4.06 MB
Loading

img/pushNotification.gif

4.06 MB
Loading

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"js-yaml": "^3.13.1",
1212
"moment": "^2.24.0",
1313
"node-emoji": "^1.10.0",
14+
"node-notifier": "^7.0.0",
1415
"open": "^7.0.3",
1516
"prop-types": "^15.7.2",
1617
"update-notifier": "^4.1.0"

src/index.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ class Main {
276276
this.prevError = {};
277277
// Store events from cloudwatchLogs
278278
this.events = [];
279-
// Allows use of .bell() function for notifications
280-
this.notifier = new blessed.Program();
281-
279+
// Check if there's an npm update available
282280
checkForUpdates();
283281
}
284282

@@ -377,7 +375,6 @@ class Main {
377375

378376
async render() {
379377
setInterval(() => {
380-
console.log(process.memoryUsage());
381378
this.map.updateMap();
382379
this.updateResourcesInformation();
383380
this.updateGraphs();

src/services/invoke.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ function invokeLambda(awsLambdaApi, functionName, payload) {
55
Payload: payload,
66
};
77
awsLambdaApi.invoke(params, (err, data) => {
8-
if (err) console.log(err, err.stack);
8+
if (err) console.error(err, err.stack);
99
// an error occurred
10-
else console.log(data); // successful response
10+
else console.log(data.Payload); // successful response
1111
});
1212
}
1313

src/services/processEventLogs.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const notifier = require("node-notifier");
2+
13
function updateLogContentsFromEvents(log, events) {
24
if (!events || events.length === 0) {
35
log.setContent("ERROR: No log streams found for this function.");
@@ -30,8 +32,11 @@ function checkLogsForErrors(events, application) {
3032
latestError.errorId !== application.prevError.errorId &&
3133
latestError.logId === application.prevError.logId
3234
) {
33-
application.notifier.bell();
34-
console.log("Recent lambda error. Check logs for details");
35+
notifier.notify({
36+
title: "sls-dev-tools: Recent lambda error",
37+
message: "Check the dashboard logs for details",
38+
sound: true,
39+
});
3540
}
3641

3742
application.setPrevError(latestError);

yarn.lock

+29-2
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2:
24562456
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423"
24572457
integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
24582458

2459+
growly@^1.3.0:
2460+
version "1.3.0"
2461+
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
2462+
integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=
2463+
24592464
has-ansi@^2.0.0:
24602465
version "2.0.0"
24612466
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
@@ -3353,6 +3358,18 @@ node-fetch@^2.3.0:
33533358
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
33543359
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
33553360

3361+
node-notifier@^7.0.0:
3362+
version "7.0.0"
3363+
resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-7.0.0.tgz#513bc42f2aa3a49fce1980a7ff375957c71f718a"
3364+
integrity sha512-y8ThJESxsHcak81PGpzWwQKxzk+5YtP3IxR8AYdpXQ1IB6FmcVzFdZXrkPin49F/DKUCfeeiziB8ptY9npzGuA==
3365+
dependencies:
3366+
growly "^1.3.0"
3367+
is-wsl "^2.1.1"
3368+
semver "^7.2.1"
3369+
shellwords "^0.1.1"
3370+
uuid "^7.0.3"
3371+
which "^2.0.2"
3372+
33563373
node-releases@^1.1.53:
33573374
version "1.1.53"
33583375
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.53.tgz#2d821bfa499ed7c5dffc5e2f28c88e78a08ee3f4"
@@ -4188,7 +4205,7 @@ [email protected]:
41884205
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
41894206
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==
41904207

4191-
4208+
[email protected], semver@^7.2.1:
41924209
version "7.3.2"
41934210
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
41944211
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
@@ -4241,6 +4258,11 @@ [email protected]:
42414258
interpret "^1.0.0"
42424259
rechoir "^0.6.2"
42434260

4261+
shellwords@^0.1.1:
4262+
version "0.1.1"
4263+
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
4264+
integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==
4265+
42444266
signal-exit@^3.0.0:
42454267
version "3.0.3"
42464268
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
@@ -4740,6 +4762,11 @@ [email protected]:
47404762
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.0.0.tgz#bc6ccf91b5ff0ac07bbcdbf1c7c4e150db4dbb6c"
47414763
integrity sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw==
47424764

4765+
uuid@^7.0.3:
4766+
version "7.0.3"
4767+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b"
4768+
integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==
4769+
47434770
v8-compile-cache@^2.0.3:
47444771
version "2.1.0"
47454772
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e"
@@ -4767,7 +4794,7 @@ which@^1.2.9:
47674794
dependencies:
47684795
isexe "^2.0.0"
47694796

4770-
which@^2.0.1:
4797+
which@^2.0.1, which@^2.0.2:
47714798
version "2.0.2"
47724799
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
47734800
integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==

0 commit comments

Comments
 (0)