@mhubcloud/tms_core 3.7.1-beta.0 → 3.7.1-beta.1
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/index.js +28 -12
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -108,14 +108,24 @@ function logEvent(publisher2, event, region, status, payload, id) {
|
|
|
108
108
|
if (status || status === 0) {
|
|
109
109
|
if (status >= 200 && status < 300) {
|
|
110
110
|
aiClient?.trackMetric({
|
|
111
|
-
name: `
|
|
112
|
-
value: 1
|
|
111
|
+
name: `DispatchSuccess`,
|
|
112
|
+
value: 1,
|
|
113
|
+
properties: {
|
|
114
|
+
publisher: publisher2,
|
|
115
|
+
event,
|
|
116
|
+
region
|
|
117
|
+
}
|
|
113
118
|
});
|
|
114
119
|
message = "Event dispatched to platform";
|
|
115
120
|
} else {
|
|
116
121
|
aiClient?.trackMetric({
|
|
117
|
-
name: `
|
|
118
|
-
value: 1
|
|
122
|
+
name: `DispatchFail`,
|
|
123
|
+
value: 1,
|
|
124
|
+
properties: {
|
|
125
|
+
publisher: publisher2,
|
|
126
|
+
event,
|
|
127
|
+
region
|
|
128
|
+
}
|
|
119
129
|
});
|
|
120
130
|
message = "Event dispatch failed";
|
|
121
131
|
}
|
|
@@ -133,10 +143,14 @@ function logEvent(publisher2, event, region, status, payload, id) {
|
|
|
133
143
|
properties = removeUndefined(properties);
|
|
134
144
|
logMessage(1, message, properties);
|
|
135
145
|
}
|
|
136
|
-
function logException(exception) {
|
|
146
|
+
function logException(exception, publisher2) {
|
|
137
147
|
aiClient?.trackMetric({
|
|
138
|
-
name: `Error
|
|
139
|
-
value: 1
|
|
148
|
+
name: `Error`,
|
|
149
|
+
value: 1,
|
|
150
|
+
properties: {
|
|
151
|
+
type: exception.name,
|
|
152
|
+
publisher: publisher2 ?? "Other"
|
|
153
|
+
}
|
|
140
154
|
});
|
|
141
155
|
aiClient?.trackException({ exception });
|
|
142
156
|
}
|
|
@@ -497,7 +511,7 @@ async function logToCosmosDb(message) {
|
|
|
497
511
|
try {
|
|
498
512
|
await cosmosClient.database(cosmosDatabaseName).container(cosmosContainerName).items.create(message);
|
|
499
513
|
} catch (e) {
|
|
500
|
-
logException(e);
|
|
514
|
+
logException(e, "Broker");
|
|
501
515
|
}
|
|
502
516
|
}
|
|
503
517
|
function parseScheduleOptions(options) {
|
|
@@ -586,13 +600,13 @@ async function defaultPublisher(azureFunctionContext, serviceBusMessage, source,
|
|
|
586
600
|
if (result.status === "rejected") {
|
|
587
601
|
if (result.reason instanceof Error) {
|
|
588
602
|
const formattedError = formatError(result.reason);
|
|
589
|
-
logException(new Error(formattedError.message));
|
|
603
|
+
logException(new Error(formattedError.message), source);
|
|
590
604
|
throw formattedError;
|
|
591
605
|
} else {
|
|
592
606
|
const formattedError = formatError(
|
|
593
607
|
typeof result.reason === "object" ? JSON.stringify(result.reason) : result.reason
|
|
594
608
|
);
|
|
595
|
-
logException(new Error(formattedError.message));
|
|
609
|
+
logException(new Error(formattedError.message), source);
|
|
596
610
|
throw formattedError;
|
|
597
611
|
}
|
|
598
612
|
}
|
|
@@ -635,7 +649,8 @@ async function processMessage(message, log2, platformPublisher, trigger) {
|
|
|
635
649
|
logException(
|
|
636
650
|
new Error(
|
|
637
651
|
`The message has not been published. Source: ${platformPublisher.source}`
|
|
638
|
-
)
|
|
652
|
+
),
|
|
653
|
+
platformPublisher.source
|
|
639
654
|
);
|
|
640
655
|
}
|
|
641
656
|
}
|
|
@@ -643,7 +658,8 @@ async function processMessage(message, log2, platformPublisher, trigger) {
|
|
|
643
658
|
logException(
|
|
644
659
|
new Error(
|
|
645
660
|
"The message has not been published to any publisher configuration"
|
|
646
|
-
)
|
|
661
|
+
),
|
|
662
|
+
platformPublisher.source
|
|
647
663
|
);
|
|
648
664
|
return false;
|
|
649
665
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mhubcloud/tms_core",
|
|
3
|
-
"version": "3.7.1-beta.
|
|
3
|
+
"version": "3.7.1-beta.1",
|
|
4
4
|
"description": "Core function for mHub Cloud TMS publishers",
|
|
5
5
|
"homepage": "https://mhubcloud.com/",
|
|
6
6
|
"license": "Apache 2.0",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"conversion API"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
-
"test": "mocha ./tests
|
|
19
|
+
"test": "mocha ./tests/*.js --local-settings=./local.settings.json --timeout 100000",
|
|
20
20
|
"dev": "ts-node index.ts",
|
|
21
21
|
"build": "tsup ./src/index.ts --format cjs --target node22"
|
|
22
22
|
},
|