@gus-eip/loggers 3.5.2 → 3.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudwatch.logger.d.ts +2 -0
- package/dist/cloudwatch.logger.js +79 -0
- package/dist/enum.d.ts +7 -0
- package/dist/enum.js +10 -3
- package/package.json +1 -1
@@ -11,6 +11,8 @@ export declare class CloudWatchLoggerService implements ILogger {
|
|
11
11
|
logToCloudWatch(type: string, logObject: any, logStreamName: string): Promise<void>;
|
12
12
|
logStreamExists(logStreamName: string): Promise<boolean>;
|
13
13
|
sendAlerttoTeams(errorMessage: any, errorStack: any, handler: any, input: any, logStreamName: any): Promise<any>;
|
14
|
+
sendNotificationtoTeams(title: any, summary: any, handler: any, logStreamName: any, isFormattingRequired?: boolean): Promise<any>;
|
14
15
|
log(correlationId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, sourcePayload: any, destinationPayload: any, logMessage: any, brand: any, secondaryKey: string, logStreamName: string, destinationObjectType?: string, destinationObjectId?: string, sourceObjectType?: string, sourceObjectId?: string, destinationResponse?: any): Promise<any>;
|
15
16
|
error(correlationId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, sourcePayload: any, destinationPayload: any, errorMessage: any, brand: any, secondaryKey: string, logStreamName: string, destinationObjectType?: string, destinationObjectId?: string, sourceObjectType?: string, sourceObjectId?: string, destinationResponse?: any): Promise<any>;
|
17
|
+
logAlert(correlationId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, sourcePayload: any, destinationPayload: any, logMessage: any, brand: any, secondaryKey: string, logStreamName: string, isAlertFormattingRequired?: boolean, destinationObjectType?: string, destinationObjectId?: string, sourceObjectType?: string, sourceObjectId?: string, destinationResponse?: any): Promise<any>;
|
16
18
|
}
|
@@ -128,6 +128,59 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
|
|
128
128
|
}
|
129
129
|
}
|
130
130
|
;
|
131
|
+
async sendNotificationtoTeams(title, summary, handler, logStreamName, isFormattingRequired = true) {
|
132
|
+
console.log("Notification summary", summary);
|
133
|
+
const webhookUrl = this.teamWebhookUrl;
|
134
|
+
const timestamp = new Date().toISOString();
|
135
|
+
const headers = Object.keys(summary[0]);
|
136
|
+
const headerRow = `| ${headers.join(' | ')} |`;
|
137
|
+
const separatorRow = `| ${headers.map(() => '---').join(' | ')} |`;
|
138
|
+
const rows = summary.map(item => `| ${headers.map(header => item[header] || '').join(' | ')} |`).join('\n');
|
139
|
+
const formattedSummary = [headerRow, separatorRow, rows].join('\n');
|
140
|
+
const summaryMsg = isFormattingRequired ? formattedSummary : summary;
|
141
|
+
const alertMessage = {
|
142
|
+
"@type": "MessageCard",
|
143
|
+
"@context": "http://schema.org/extensions",
|
144
|
+
"summary": "System Alert",
|
145
|
+
"themeColor": "FF0000",
|
146
|
+
"title": `🚨 ${title} 🚨`,
|
147
|
+
"sections": [
|
148
|
+
{
|
149
|
+
"facts": [
|
150
|
+
{
|
151
|
+
"name": "summary:",
|
152
|
+
"value": summaryMsg
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"name": "component:",
|
156
|
+
"value": handler
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"name": "timestamp:",
|
160
|
+
"value": timestamp
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"name": "",
|
164
|
+
"value": `[Click here for more details](https://eu-west-1.console.aws.amazon.com/cloudwatch/home?region=eu-west-1#logsV2:log-groups/log-group/${this.logGroupName}/log-events/${logStreamName})`
|
165
|
+
},
|
166
|
+
],
|
167
|
+
"markdown": true
|
168
|
+
}
|
169
|
+
]
|
170
|
+
};
|
171
|
+
try {
|
172
|
+
await axios_1.default.post(webhookUrl, alertMessage, {
|
173
|
+
headers: {
|
174
|
+
"Content-Type": "application/json",
|
175
|
+
},
|
176
|
+
});
|
177
|
+
console.log("Message sent successfully");
|
178
|
+
}
|
179
|
+
catch (error) {
|
180
|
+
console.error("Error sending message:", error);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
;
|
131
184
|
async log(correlationId, timestamp, component, source, destination, event, usecase, sourcePayload, destinationPayload, logMessage, brand, secondaryKey, logStreamName, destinationObjectType, destinationObjectId, sourceObjectType, sourceObjectId, destinationResponse) {
|
132
185
|
const logObject = {
|
133
186
|
correlationId,
|
@@ -177,6 +230,32 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
|
|
177
230
|
await this.sendAlerttoTeams(errorMessage.message ? errorMessage.message : errorMessage, errorMessage.stack ? errorMessage.stack : errorMessage, component, logObject, encodeURIComponent(logStreamName));
|
178
231
|
}
|
179
232
|
}
|
233
|
+
async logAlert(correlationId, timestamp, component, source, destination, event, usecase, sourcePayload, destinationPayload, logMessage, brand, secondaryKey, logStreamName, isAlertFormattingRequired, destinationObjectType, destinationObjectId, sourceObjectType, sourceObjectId, destinationResponse) {
|
234
|
+
const logObject = {
|
235
|
+
correlationId,
|
236
|
+
timestamp,
|
237
|
+
type: 'INFO',
|
238
|
+
component,
|
239
|
+
source,
|
240
|
+
destination,
|
241
|
+
event,
|
242
|
+
usecase,
|
243
|
+
sourcePayload,
|
244
|
+
destinationPayload,
|
245
|
+
logMessage,
|
246
|
+
brand,
|
247
|
+
secondaryKey,
|
248
|
+
destinationObjectType,
|
249
|
+
destinationObjectId,
|
250
|
+
sourceObjectType,
|
251
|
+
sourceObjectId,
|
252
|
+
destinationResponse
|
253
|
+
};
|
254
|
+
await this.logToCloudWatch('info', logObject, logStreamName);
|
255
|
+
if (this.isAlertNeeded) {
|
256
|
+
await this.sendNotificationtoTeams(logMessage, destinationPayload, component, encodeURIComponent(logStreamName), isAlertFormattingRequired);
|
257
|
+
}
|
258
|
+
}
|
180
259
|
};
|
181
260
|
exports.CloudWatchLoggerService = CloudWatchLoggerService;
|
182
261
|
exports.CloudWatchLoggerService = CloudWatchLoggerService = __decorate([
|
package/dist/enum.d.ts
CHANGED
@@ -37,6 +37,9 @@ export declare class LoggerEnum {
|
|
37
37
|
UPDATE_KYB_ENROLLMENT_DATA: string;
|
38
38
|
GET_NON_KYB_ACCOUNTS: string;
|
39
39
|
CREATE_CASE_KYB_ENROLLMENT_FAIL: string;
|
40
|
+
GET_KYB_ENROLLMENT_HISTORY: string;
|
41
|
+
CREATE_LOG_KYB_ENROLLMENT_JOB_SUMMARY: string;
|
42
|
+
CREATE_TEAMS_ALERT: string;
|
40
43
|
};
|
41
44
|
UseCase: {
|
42
45
|
PROGRAM_INFO: string;
|
@@ -63,6 +66,7 @@ export declare class LoggerEnum {
|
|
63
66
|
KYB_SCREENING: string;
|
64
67
|
KYB_UNENROLLMENT: string;
|
65
68
|
KYB_ENROLLMENT: string;
|
69
|
+
SEND_ALERTS: string;
|
66
70
|
};
|
67
71
|
Component: {
|
68
72
|
OAP_FRONTEND: string;
|
@@ -85,5 +89,8 @@ export declare class LoggerEnum {
|
|
85
89
|
GUS_KYB_KYC_FEEDBACK_INTEGRATION_HANDLER: string;
|
86
90
|
GUS_KYB_ENROLLMENT_JOB: string;
|
87
91
|
GUS_KYB_EVENT_SCHEDULER: string;
|
92
|
+
GUS_DLQ_ALERT_JOB: string;
|
93
|
+
GUS_TEAMS_CHANNEL: string;
|
94
|
+
GUS_DLQ_ALERT_EVENT_SCHEDULER: string;
|
88
95
|
};
|
89
96
|
}
|
package/dist/enum.js
CHANGED
@@ -47,7 +47,10 @@ let LoggerEnum = class LoggerEnum {
|
|
47
47
|
REGISTER_KYB_ENROLLMENT: 'REGISTER_KYB_ENROLLMENT',
|
48
48
|
UPDATE_KYB_ENROLLMENT_DATA: 'UPDATE_KYB_ENROLLMENT_DATA',
|
49
49
|
GET_NON_KYB_ACCOUNTS: 'GET_NON_KYB_ACCOUNTS',
|
50
|
-
CREATE_CASE_KYB_ENROLLMENT_FAIL: 'CREATE_CASE_KYB_ENROLLMENT_FAIL'
|
50
|
+
CREATE_CASE_KYB_ENROLLMENT_FAIL: 'CREATE_CASE_KYB_ENROLLMENT_FAIL',
|
51
|
+
GET_KYB_ENROLLMENT_HISTORY: 'GET_KYB_ENROLLMENT_HISTORY',
|
52
|
+
CREATE_LOG_KYB_ENROLLMENT_JOB_SUMMARY: 'CREATE_LOG_KYB_ENROLLMENT_JOB_SUMMARY',
|
53
|
+
CREATE_TEAMS_ALERT: 'CREATE_TEAMS_ALERT'
|
51
54
|
};
|
52
55
|
this.UseCase = {
|
53
56
|
PROGRAM_INFO: 'SAVE_PROGRAMME_DETAILS',
|
@@ -73,7 +76,8 @@ let LoggerEnum = class LoggerEnum {
|
|
73
76
|
DELETE_DOCUMENT: 'DELETE_DOCUMENT',
|
74
77
|
KYB_SCREENING: 'KYB_SCREENING',
|
75
78
|
KYB_UNENROLLMENT: 'KYB_UNENROLLMENT',
|
76
|
-
KYB_ENROLLMENT: 'KYB_ENROLLMENT'
|
79
|
+
KYB_ENROLLMENT: 'KYB_ENROLLMENT',
|
80
|
+
SEND_ALERTS: 'SEND_ALERTS'
|
77
81
|
};
|
78
82
|
this.Component = {
|
79
83
|
OAP_FRONTEND: 'OAP-FRONTEND',
|
@@ -95,7 +99,10 @@ let LoggerEnum = class LoggerEnum {
|
|
95
99
|
GUS_KYB_KYC_FEEDBACK_INTEGRATION_QUEUE: "GUS_KYB_KYC_FEEDBACK_INTEGRATION_QUEUE",
|
96
100
|
GUS_KYB_KYC_FEEDBACK_INTEGRATION_HANDLER: "GUS_KYB_KYC_FEEDBACK_INTEGRATION_HANDLER",
|
97
101
|
GUS_KYB_ENROLLMENT_JOB: 'GUS_KYB_ENROLLMENT_JOB',
|
98
|
-
GUS_KYB_EVENT_SCHEDULER: 'GUS_KYB_EVENT_SCHEDULER'
|
102
|
+
GUS_KYB_EVENT_SCHEDULER: 'GUS_KYB_EVENT_SCHEDULER',
|
103
|
+
GUS_DLQ_ALERT_JOB: 'GUS_DLQ_ALERT_JOB',
|
104
|
+
GUS_TEAMS_CHANNEL: 'GUS_TEAMS_CHANNEL',
|
105
|
+
GUS_DLQ_ALERT_EVENT_SCHEDULER: 'GUS_DLQ_ALERT_EVENT_SCHEDULER'
|
99
106
|
};
|
100
107
|
}
|
101
108
|
};
|
package/package.json
CHANGED