notification-processor 4.23.0 → 4.24.0
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.
|
@@ -36,17 +36,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
36
36
|
accessKeyId = _ref$connection.accessKeyId,
|
|
37
37
|
secretAccessKey = _ref$connection.secretAccessKey,
|
|
38
38
|
deliveryStream = _ref$connection.deliveryStream,
|
|
39
|
+
jobsDeliveryStream = _ref$connection.jobsDeliveryStream,
|
|
39
40
|
region = _ref$connection.region;
|
|
40
41
|
|
|
41
42
|
_classCallCheck(this, MonitoringCenterObserver);
|
|
42
43
|
|
|
43
44
|
this.registerRecord = this.registerRecord.bind(this);
|
|
45
|
+
this._registerJob = this._registerJob.bind(this);
|
|
46
|
+
this._registerExecution = this._registerExecution.bind(this);
|
|
44
47
|
this.sender = sender;
|
|
45
48
|
this.clientId = clientId;
|
|
46
49
|
this.app = app1;
|
|
47
50
|
this.job = job1;
|
|
48
51
|
this.propertiesToOmit = propertiesToOmit;
|
|
49
52
|
this.deliveryStream = deliveryStream;
|
|
53
|
+
this.jobsDeliveryStream = jobsDeliveryStream;
|
|
50
54
|
this.firehose = new AWS.Firehose({ accessKeyId: accessKeyId, secretAccessKey: secretAccessKey, region: region });
|
|
51
55
|
this.uploadToFirehose = Promise.promisify(this.firehose.putRecord).bind(this.firehose);
|
|
52
56
|
}
|
|
@@ -74,15 +78,18 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
74
78
|
value: function registerRecord(payload, executionStatus) {
|
|
75
79
|
var _this2 = this;
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
var deliveryStreamName, jobId;
|
|
82
|
+
jobId = _.get(payload, 'notification.message.JobId');
|
|
83
|
+
deliveryStreamName = jobId ? this.jobsDeliveryStream : this.deliveryStream;
|
|
84
|
+
return this._mapper(_.merge({ executionStatus: executionStatus, jobId: jobId }, payload)).tap(function (record) {
|
|
85
|
+
return debug("Record to save in firehose %s %j", deliveryStreamName, record);
|
|
79
86
|
}).then(function (record) {
|
|
80
87
|
var __uploadToFirehose, uploadParams;
|
|
81
88
|
if (_.isEmpty(record)) {
|
|
82
89
|
return;
|
|
83
90
|
}
|
|
84
91
|
uploadParams = {
|
|
85
|
-
DeliveryStreamName:
|
|
92
|
+
DeliveryStreamName: deliveryStreamName,
|
|
86
93
|
Record: {
|
|
87
94
|
Data: JSON.stringify(record)
|
|
88
95
|
}
|
|
@@ -110,7 +117,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
110
117
|
notification = _ref2.notification,
|
|
111
118
|
error = _ref2.error,
|
|
112
119
|
warnings = _ref2.warnings,
|
|
113
|
-
executionStatus = _ref2.executionStatus
|
|
120
|
+
executionStatus = _ref2.executionStatus,
|
|
121
|
+
jobId = _ref2.jobId;
|
|
114
122
|
|
|
115
123
|
return Promise.method(this.sender.monitoringCenterFields.bind(this.sender))(notification).then(function (_ref3) {
|
|
116
124
|
var eventType = _ref3.eventType,
|
|
@@ -126,62 +134,92 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
126
134
|
job = _ref3.job,
|
|
127
135
|
partialMessage = _ref3.partialMessage;
|
|
128
136
|
|
|
129
|
-
var
|
|
137
|
+
var basicRegister, errorType, executionRegister, now, theRequest;
|
|
130
138
|
if (!eventId) {
|
|
131
139
|
return Promise.resolve({});
|
|
132
140
|
}
|
|
133
141
|
theRequest = _.get(error, "detail.request") || _.get(error, "cause.detail.request");
|
|
134
142
|
errorType = _this3._retrieveMessageFromError(error, TYPE_PROPERTIES, "unknown");
|
|
135
|
-
errorMessage = _this3._retrieveMessageFromError(error, MESSAGE_PROPERTIES, "");
|
|
136
143
|
if (/the operation did not complete within the allocated time/gi.test(errorType)) {
|
|
137
144
|
errorType = "timed_out";
|
|
138
145
|
}
|
|
139
146
|
now = new Date();
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
event: eventId,
|
|
148
|
-
parent: parentEventId,
|
|
149
|
-
externalreference: externalReference,
|
|
150
|
-
userexternalreference: userExternalReference,
|
|
151
|
-
timestamp: now.getTime(),
|
|
152
|
-
date: now.toISOString(),
|
|
153
|
-
year: moment(now).format('YYYY'),
|
|
154
|
-
month: moment(now).format('MM'),
|
|
155
|
-
day: moment(now).format('DD'),
|
|
156
|
-
hour: moment(now).format('HH'),
|
|
157
|
-
payload: JSON.stringify({
|
|
158
|
-
clientId: _this3.clientId,
|
|
159
|
-
job: _this3.job,
|
|
160
|
-
app: _this3.app,
|
|
161
|
-
error: _.omit(error, ["detail.request", "cause.detail.request"]),
|
|
162
|
-
request: _.omit(theRequest, _.castArray(_this3.propertiesToOmit).concat("auth")),
|
|
163
|
-
tags: _.get(error, "tags", []),
|
|
164
|
-
message: partialMessage || notification.message
|
|
165
|
-
}),
|
|
166
|
-
status: executionStatus,
|
|
167
|
-
resource: resource,
|
|
168
|
-
integration: _this3.app + "|" + (job || _this3.job),
|
|
169
|
-
// Generic app fields
|
|
170
|
-
event_timestamp: eventTimestamp || now.getTime(),
|
|
171
|
-
error_type: errorType,
|
|
172
|
-
output_message: errorMessage,
|
|
173
|
-
user_settings_version: null, //TODO
|
|
174
|
-
env_version: null, //TODO
|
|
175
|
-
code_version: null, //TODO
|
|
176
|
-
warnings: warnings != null ? warnings.map(function (warning) {
|
|
177
|
-
return {
|
|
178
|
-
type: _this3._retrieveMessageFromError(warning, TYPE_PROPERTIES, "unknown"),
|
|
179
|
-
message: _this3._retrieveMessageFromError(warning, MESSAGE_PROPERTIES, "")
|
|
180
|
-
};
|
|
181
|
-
}) : void 0
|
|
182
|
-
};
|
|
147
|
+
basicRegister = { id: id, app: app, companyId: companyId, now: now, executionStatus: executionStatus, errorType: errorType, job: job };
|
|
148
|
+
executionRegister = { eventType: eventType, userId: userId, eventId: eventId, parentEventId: parentEventId, externalReference: externalReference, userExternalReference: userExternalReference, error: error, theRequest: theRequest, partialMessage: partialMessage, notification: notification, resource: resource, eventTimestamp: eventTimestamp, warnings: warnings };
|
|
149
|
+
if (jobId) {
|
|
150
|
+
return _this3._registerJob(basicRegister, jobId);
|
|
151
|
+
} else {
|
|
152
|
+
return _this3._registerExecution(basicRegister, executionRegister);
|
|
153
|
+
}
|
|
183
154
|
});
|
|
184
155
|
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "_registerJob",
|
|
158
|
+
value: function _registerJob(basicRegister, jobId) {
|
|
159
|
+
return {
|
|
160
|
+
id: basicRegister.id,
|
|
161
|
+
app: basicRegister.app || parseInt(this.clientId) || null,
|
|
162
|
+
trigger_id: jobId,
|
|
163
|
+
trigger_mode: "scheduled",
|
|
164
|
+
company: basicRegister.companyId,
|
|
165
|
+
start_time: basicRegister.now.getTime(),
|
|
166
|
+
integration: this.app + "|" + (basicRegister.job || this.job),
|
|
167
|
+
error_type: basicRegister.errorType,
|
|
168
|
+
status: basicRegister.executionStatus
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "_registerExecution",
|
|
173
|
+
value: function _registerExecution(basicRegister, executionRegister) {
|
|
174
|
+
var _this4 = this;
|
|
175
|
+
|
|
176
|
+
var errorMessage, now, ref;
|
|
177
|
+
now = basicRegister.now;
|
|
178
|
+
errorMessage = this._retrieveMessageFromError(executionRegister.error, MESSAGE_PROPERTIES, "");
|
|
179
|
+
return {
|
|
180
|
+
id: basicRegister.id,
|
|
181
|
+
executionId: basicRegister.id,
|
|
182
|
+
app: basicRegister.app || parseInt(this.clientId) || null,
|
|
183
|
+
type: executionRegister.eventType || "service-bus",
|
|
184
|
+
company: basicRegister.companyId,
|
|
185
|
+
user: executionRegister.userId,
|
|
186
|
+
event: executionRegister.eventId,
|
|
187
|
+
parent: executionRegister.parentEventId,
|
|
188
|
+
externalreference: executionRegister.externalReference,
|
|
189
|
+
userexternalreference: executionRegister.userExternalReference,
|
|
190
|
+
timestamp: now.getTime(),
|
|
191
|
+
date: now.toISOString(),
|
|
192
|
+
year: moment(now).format('YYYY'),
|
|
193
|
+
month: moment(now).format('MM'),
|
|
194
|
+
day: moment(now).format('DD'),
|
|
195
|
+
hour: moment(now).format('HH'),
|
|
196
|
+
payload: JSON.stringify({
|
|
197
|
+
clientId: this.clientId,
|
|
198
|
+
job: this.job,
|
|
199
|
+
app: this.app,
|
|
200
|
+
error: _.omit(executionRegister.error, ["detail.request", "cause.detail.request"]),
|
|
201
|
+
request: _.omit(executionRegister.theRequest, _.castArray(this.propertiesToOmit).concat("auth")),
|
|
202
|
+
tags: _.get(executionRegister.error, "tags", []),
|
|
203
|
+
message: executionRegister.partialMessage || executionRegister.notification.message
|
|
204
|
+
}),
|
|
205
|
+
status: basicRegister.executionStatus,
|
|
206
|
+
resource: executionRegister.resource,
|
|
207
|
+
integration: this.app + "|" + (basicRegister.job || this.job),
|
|
208
|
+
// Generic app fields
|
|
209
|
+
event_timestamp: executionRegister.eventTimestamp || now.getTime(),
|
|
210
|
+
error_type: basicRegister.errorType,
|
|
211
|
+
output_message: errorMessage,
|
|
212
|
+
user_settings_version: null, //TODO
|
|
213
|
+
env_version: null, //TODO
|
|
214
|
+
code_version: null, //TODO
|
|
215
|
+
warnings: (ref = executionRegister.warnings) != null ? ref.map(function (warning) {
|
|
216
|
+
return {
|
|
217
|
+
type: _this4._retrieveMessageFromError(warning, TYPE_PROPERTIES, "unknown"),
|
|
218
|
+
message: _this4._retrieveMessageFromError(warning, MESSAGE_PROPERTIES, "")
|
|
219
|
+
};
|
|
220
|
+
}) : void 0
|
|
221
|
+
};
|
|
222
|
+
}
|
|
185
223
|
}, {
|
|
186
224
|
key: "_retrieveMessageFromError",
|
|
187
225
|
value: function _retrieveMessageFromError(error, properties, defaultValue) {
|