@mhubcloud/tms_core 3.1.6-beta.0 → 3.1.6-beta.2
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 +11 -16
- package/package.json +1 -1
- package/src/defaultPublisher.ts +4 -2
- package/src/utils/utils.ts +9 -14
- package/tests/AffiliatePort.js +7 -11
- package/tests/Facebook.js +7 -18
- package/tests/Piano.js +7 -15
package/dist/index.js
CHANGED
|
@@ -81,29 +81,24 @@ var EventPublisherBase = class {
|
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
function logMessage(level, message, properties) {
|
|
85
|
-
|
|
86
|
-
aiClient?.trackTrace({
|
|
87
|
-
message,
|
|
88
|
-
severity: level,
|
|
89
|
-
properties
|
|
90
|
-
});
|
|
84
|
+
function logMessage(log3, level, message, properties) {
|
|
85
|
+
log3.warn(message, properties);
|
|
91
86
|
}
|
|
92
87
|
function logEvent(publisher2, event, region) {
|
|
93
|
-
const message = "Event dispatched to platform";
|
|
94
88
|
const properties = {
|
|
95
89
|
publisher: publisher2,
|
|
96
90
|
event,
|
|
97
91
|
region
|
|
98
92
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
aiClient?.trackException({
|
|
104
|
-
exception
|
|
93
|
+
aiClient?.trackTrace({
|
|
94
|
+
message: "Event dispatched to platform",
|
|
95
|
+
severity: 1,
|
|
96
|
+
properties
|
|
105
97
|
});
|
|
106
98
|
}
|
|
99
|
+
function logException(log3, exception) {
|
|
100
|
+
log3.warn(exception);
|
|
101
|
+
}
|
|
107
102
|
function removeUndefined(originalValue) {
|
|
108
103
|
if (originalValue instanceof Array) {
|
|
109
104
|
return removeUndefinedFromArray(originalValue);
|
|
@@ -286,13 +281,11 @@ async function defaultPublisher(azureFunctionContext, serviceBusMessage, source,
|
|
|
286
281
|
if (result.status === "rejected") {
|
|
287
282
|
if (result.reason instanceof Error) {
|
|
288
283
|
const errorMessage = parseErrorMessage(result.reason);
|
|
289
|
-
logException(new Error(errorMessage));
|
|
290
284
|
throw new Error(errorMessage);
|
|
291
285
|
} else {
|
|
292
286
|
const errorMessage = parseErrorMessage(
|
|
293
287
|
typeof result.reason === "object" ? JSON.stringify(result.reason) : result.reason
|
|
294
288
|
);
|
|
295
|
-
logException(new Error(errorMessage));
|
|
296
289
|
throw new Error(errorMessage);
|
|
297
290
|
}
|
|
298
291
|
}
|
|
@@ -330,6 +323,7 @@ async function processMessage(message, log3, platformPublisher, source, trigger)
|
|
|
330
323
|
publishedAny = true;
|
|
331
324
|
} else {
|
|
332
325
|
logException(
|
|
326
|
+
log3,
|
|
333
327
|
new Error(
|
|
334
328
|
`The message has not been published. Source: ${platformPublisher.source}`
|
|
335
329
|
)
|
|
@@ -338,6 +332,7 @@ async function processMessage(message, log3, platformPublisher, source, trigger)
|
|
|
338
332
|
}
|
|
339
333
|
if (!publishedAny) {
|
|
340
334
|
logException(
|
|
335
|
+
log3,
|
|
341
336
|
new Error(
|
|
342
337
|
"The message has not been published to any publisher configuration"
|
|
343
338
|
)
|
package/package.json
CHANGED
package/src/defaultPublisher.ts
CHANGED
|
@@ -39,7 +39,7 @@ export async function defaultPublisher(
|
|
|
39
39
|
if (result.status === 'rejected') {
|
|
40
40
|
if (result.reason instanceof Error) {
|
|
41
41
|
const errorMessage = utils.parseErrorMessage(result.reason);
|
|
42
|
-
utils.logException(new Error(errorMessage));
|
|
42
|
+
// utils.logException(azureFunctionContext.log, new Error(errorMessage));
|
|
43
43
|
throw new Error(errorMessage);
|
|
44
44
|
} else {
|
|
45
45
|
const errorMessage = utils.parseErrorMessage(
|
|
@@ -47,7 +47,7 @@ export async function defaultPublisher(
|
|
|
47
47
|
? JSON.stringify(result.reason)
|
|
48
48
|
: (result.reason as Error['message']),
|
|
49
49
|
);
|
|
50
|
-
utils.logException(new Error(errorMessage));
|
|
50
|
+
// utils.logException(azureFunctionContext.log, new Error(errorMessage));
|
|
51
51
|
throw new Error(errorMessage);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -105,6 +105,7 @@ async function processMessage(
|
|
|
105
105
|
publishedAny = true;
|
|
106
106
|
} else {
|
|
107
107
|
utils.logException(
|
|
108
|
+
log,
|
|
108
109
|
new Error(
|
|
109
110
|
`The message has not been published. Source: ${platformPublisher.source}`,
|
|
110
111
|
),
|
|
@@ -113,6 +114,7 @@ async function processMessage(
|
|
|
113
114
|
}
|
|
114
115
|
if (!publishedAny) {
|
|
115
116
|
utils.logException(
|
|
117
|
+
log,
|
|
116
118
|
new Error(
|
|
117
119
|
'The message has not been published to any publisher configuration',
|
|
118
120
|
),
|
package/src/utils/utils.ts
CHANGED
|
@@ -60,16 +60,12 @@ export class EventPublisherBase implements EventPublisherBaseClass {
|
|
|
60
60
|
* Logs message to Azure Function context and to Application Insights (if configured)
|
|
61
61
|
*/
|
|
62
62
|
export function logMessage(
|
|
63
|
+
log: Logger,
|
|
63
64
|
level: SeverityLevel,
|
|
64
65
|
message: string,
|
|
65
66
|
properties?: Telemetry['properties'],
|
|
66
67
|
): void {
|
|
67
|
-
|
|
68
|
-
aiClient?.trackTrace({
|
|
69
|
-
message,
|
|
70
|
-
severity: level,
|
|
71
|
-
properties,
|
|
72
|
-
});
|
|
68
|
+
log.warn(message, properties);
|
|
73
69
|
}
|
|
74
70
|
|
|
75
71
|
export function logEvent(
|
|
@@ -77,24 +73,23 @@ export function logEvent(
|
|
|
77
73
|
event: string,
|
|
78
74
|
region: string,
|
|
79
75
|
): void {
|
|
80
|
-
const message = 'Event dispatched to platform';
|
|
81
76
|
const properties: Telemetry['properties'] = {
|
|
82
77
|
publisher: publisher,
|
|
83
78
|
event: event,
|
|
84
79
|
region: region,
|
|
85
80
|
};
|
|
86
|
-
|
|
81
|
+
aiClient?.trackTrace({
|
|
82
|
+
message: 'Event dispatched to platform',
|
|
83
|
+
severity: 1,
|
|
84
|
+
properties,
|
|
85
|
+
});
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
/**
|
|
90
89
|
* Logs exception to Azure Function context and to Application Insights (if configured)
|
|
91
90
|
*/
|
|
92
|
-
export function logException(exception: Error) {
|
|
93
|
-
|
|
94
|
-
console.log(exception);
|
|
95
|
-
aiClient?.trackException({
|
|
96
|
-
exception,
|
|
97
|
-
});
|
|
91
|
+
export function logException(log: Logger, exception: Error) {
|
|
92
|
+
log.warn(exception);
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
/**
|
package/tests/AffiliatePort.js
CHANGED
|
@@ -74,17 +74,13 @@ describe('test AffiliatePort publisher', function () {
|
|
|
74
74
|
* @param [object] object obsahující nastavení testovací parametry
|
|
75
75
|
*/
|
|
76
76
|
async function test(serviceBusMessage) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
85
|
-
} catch (err) {
|
|
86
|
-
console.log(err);
|
|
87
|
-
}
|
|
77
|
+
await defaultPublisher(
|
|
78
|
+
testUtils.context,
|
|
79
|
+
serviceBusMessage,
|
|
80
|
+
'AffiliatePort',
|
|
81
|
+
publisher,
|
|
82
|
+
trigger,
|
|
83
|
+
);
|
|
88
84
|
}
|
|
89
85
|
|
|
90
86
|
function trigger(data) {
|
package/tests/Facebook.js
CHANGED
|
@@ -53,24 +53,13 @@ describe('test Facebook publisher', function () {
|
|
|
53
53
|
* @param [object] object obsahující nastavení testovací parametry
|
|
54
54
|
*/
|
|
55
55
|
async function test(serviceBusMessage) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
);
|
|
64
|
-
} catch (err) {
|
|
65
|
-
assert.equal(
|
|
66
|
-
err
|
|
67
|
-
.toString()
|
|
68
|
-
.indexOf(
|
|
69
|
-
'Error: HTTP Error code: 400, event: purchase, body: {"error":{"message":"Invalid OAuth access token - Cannot parse access token","type":"OAuthException","code":190',
|
|
70
|
-
),
|
|
71
|
-
0,
|
|
72
|
-
);
|
|
73
|
-
}
|
|
56
|
+
await defaultPublisher(
|
|
57
|
+
testUtils.context,
|
|
58
|
+
serviceBusMessage,
|
|
59
|
+
'Facebook',
|
|
60
|
+
publisher,
|
|
61
|
+
trigger,
|
|
62
|
+
);
|
|
74
63
|
}
|
|
75
64
|
|
|
76
65
|
function trigger(data) {
|
package/tests/Piano.js
CHANGED
|
@@ -53,21 +53,13 @@ describe('test Piano publisher', function () {
|
|
|
53
53
|
* @param [object] object obsahující nastavení testovací parametry
|
|
54
54
|
*/
|
|
55
55
|
async function test(serviceBusMessage) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
);
|
|
64
|
-
} catch (err) {
|
|
65
|
-
console.log(err.message);
|
|
66
|
-
assert.equal(
|
|
67
|
-
err.message,
|
|
68
|
-
'fetch failed Cause: Error: getaddrinfo ENOTFOUND xxxxx.xiti.com',
|
|
69
|
-
);
|
|
70
|
-
}
|
|
56
|
+
await defaultPublisher(
|
|
57
|
+
testUtils.context,
|
|
58
|
+
serviceBusMessage,
|
|
59
|
+
'Piano',
|
|
60
|
+
publisher,
|
|
61
|
+
trigger,
|
|
62
|
+
);
|
|
71
63
|
}
|
|
72
64
|
|
|
73
65
|
function trigger(data) {
|