@mhubcloud/tms_core 3.4.3 → 3.4.5
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 +13 -3
- package/package.json +1 -1
- package/src/broker.ts +2 -0
- package/src/defaultPublisher.ts +10 -2
- package/src/index.ts +3 -3
- package/src/publishers/googleAds.ts +1 -1
- package/publishers/TableStorage.js +0 -46
package/dist/index.js
CHANGED
|
@@ -359,6 +359,8 @@ function matchEvent(event, publisherEvent) {
|
|
|
359
359
|
if (!paramMatch) {
|
|
360
360
|
return false;
|
|
361
361
|
}
|
|
362
|
+
} else if (publisherEventParam && !eventParam) {
|
|
363
|
+
return false;
|
|
362
364
|
} else {
|
|
363
365
|
throw new Error("Unexpected formatting in publisher configuration");
|
|
364
366
|
}
|
|
@@ -431,13 +433,19 @@ async function defaultPublisher(azureFunctionContext, serviceBusMessage, source,
|
|
|
431
433
|
if (result.status === "rejected") {
|
|
432
434
|
if (result.reason instanceof Error) {
|
|
433
435
|
const formattedError = formatError(result.reason);
|
|
434
|
-
logException(
|
|
436
|
+
logException(
|
|
437
|
+
azureFunctionContext.log,
|
|
438
|
+
new Error(formattedError.message)
|
|
439
|
+
);
|
|
435
440
|
throw formattedError;
|
|
436
441
|
} else {
|
|
437
442
|
const formattedError = formatError(
|
|
438
443
|
typeof result.reason === "object" ? JSON.stringify(result.reason) : result.reason
|
|
439
444
|
);
|
|
440
|
-
logException(
|
|
445
|
+
logException(
|
|
446
|
+
azureFunctionContext.log,
|
|
447
|
+
new Error(formattedError.message)
|
|
448
|
+
);
|
|
441
449
|
throw formattedError;
|
|
442
450
|
}
|
|
443
451
|
}
|
|
@@ -475,6 +483,7 @@ async function processMessage(message, log2, platformPublisher, trigger) {
|
|
|
475
483
|
publishedAny = true;
|
|
476
484
|
} else {
|
|
477
485
|
logException(
|
|
486
|
+
log2,
|
|
478
487
|
new Error(
|
|
479
488
|
`The message has not been published. Source: ${platformPublisher.source}`
|
|
480
489
|
)
|
|
@@ -483,6 +492,7 @@ async function processMessage(message, log2, platformPublisher, trigger) {
|
|
|
483
492
|
}
|
|
484
493
|
if (!publishedAny) {
|
|
485
494
|
logException(
|
|
495
|
+
log2,
|
|
486
496
|
new Error(
|
|
487
497
|
"The message has not been published to any publisher configuration"
|
|
488
498
|
)
|
|
@@ -891,7 +901,7 @@ var publisher = {
|
|
|
891
901
|
Facebook: facebook,
|
|
892
902
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
893
903
|
CJ: cj,
|
|
894
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
904
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
895
905
|
GoogleAds: googleAds,
|
|
896
906
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
897
907
|
GoogleAnalytics4: googleAnalytics4,
|
package/package.json
CHANGED
package/src/broker.ts
CHANGED
|
@@ -104,6 +104,8 @@ function matchEvent(event: EventInfo, publisherEvent: string | PublisherEvent) {
|
|
|
104
104
|
if (!paramMatch) {
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
|
+
} else if (publisherEventParam && !eventParam) {
|
|
108
|
+
return false;
|
|
107
109
|
} else {
|
|
108
110
|
throw new Error('Unexpected formatting in publisher configuration');
|
|
109
111
|
}
|
package/src/defaultPublisher.ts
CHANGED
|
@@ -41,7 +41,10 @@ export async function defaultPublisher(
|
|
|
41
41
|
if (result.status === 'rejected') {
|
|
42
42
|
if (result.reason instanceof Error) {
|
|
43
43
|
const formattedError = utils.formatError(result.reason);
|
|
44
|
-
utils.logException(
|
|
44
|
+
utils.logException(
|
|
45
|
+
azureFunctionContext.log,
|
|
46
|
+
new Error(formattedError.message),
|
|
47
|
+
);
|
|
45
48
|
throw formattedError;
|
|
46
49
|
} else {
|
|
47
50
|
const formattedError = utils.formatError(
|
|
@@ -49,7 +52,10 @@ export async function defaultPublisher(
|
|
|
49
52
|
? JSON.stringify(result.reason)
|
|
50
53
|
: (result.reason as Error['message']),
|
|
51
54
|
);
|
|
52
|
-
utils.logException(
|
|
55
|
+
utils.logException(
|
|
56
|
+
azureFunctionContext.log,
|
|
57
|
+
new Error(formattedError.message),
|
|
58
|
+
);
|
|
53
59
|
throw formattedError;
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -106,6 +112,7 @@ async function processMessage(
|
|
|
106
112
|
publishedAny = true;
|
|
107
113
|
} else {
|
|
108
114
|
utils.logException(
|
|
115
|
+
log,
|
|
109
116
|
new Error(
|
|
110
117
|
`The message has not been published. Source: ${platformPublisher.source}`,
|
|
111
118
|
),
|
|
@@ -114,6 +121,7 @@ async function processMessage(
|
|
|
114
121
|
}
|
|
115
122
|
if (!publishedAny) {
|
|
116
123
|
utils.logException(
|
|
124
|
+
log,
|
|
117
125
|
new Error(
|
|
118
126
|
'The message has not been published to any publisher configuration',
|
|
119
127
|
),
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { defaultPublisher } from './defaultPublisher';
|
|
|
3
3
|
import { affiliatePort } from './publishers/affiliatePort';
|
|
4
4
|
import { cj } from './publishers/cj';
|
|
5
5
|
import { facebook } from './publishers/facebook';
|
|
6
|
-
import { googleAds
|
|
6
|
+
import { googleAds } from './publishers/googleAds';
|
|
7
7
|
import { googleAnalytics4 } from './publishers/googleAnalytics4';
|
|
8
8
|
import { piano } from './publishers/piano';
|
|
9
9
|
import { universalAnalytics } from './publishers/universalAnalytics';
|
|
@@ -15,8 +15,8 @@ export const publisher = {
|
|
|
15
15
|
Facebook: facebook,
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
17
17
|
CJ: cj,
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
|
-
GoogleAds: googleAds
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
|
+
GoogleAds: googleAds,
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
21
21
|
GoogleAnalytics4: googleAnalytics4,
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -3,7 +3,7 @@ import * as utils from './../utils/utils';
|
|
|
3
3
|
import { EventToLog } from '../types/EventToLog';
|
|
4
4
|
import { TypeSafeObject } from '../types/UtilTypes';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface GoogleAdsPlatformPublisher {
|
|
7
7
|
source: string;
|
|
8
8
|
publish: (
|
|
9
9
|
log: Logger,
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const { TableClient } = require("@azure/data-tables");
|
|
2
|
-
const utils = require("../lib/utils");
|
|
3
|
-
const SOURCE = "f_TableStorage";
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
/**
|
|
7
|
-
* Processed data coming from EventHub to data for further processing
|
|
8
|
-
* @param {Object} data The data coming from EventHub
|
|
9
|
-
* @returns {Object} Data for further processing
|
|
10
|
-
*/
|
|
11
|
-
parse: function parse(data, context) {
|
|
12
|
-
//ConsumerBase.cs:ConsumeOneEventAsync
|
|
13
|
-
data.enqueuedAt = context.test ? 1600000000000 : Date.now();
|
|
14
|
-
return data;
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Publishes data to TableStorage
|
|
19
|
-
* https://www.npmjs.com/package/@azure/data-tables
|
|
20
|
-
* @param {{id: string, access_token: string}} config Publisher configuration
|
|
21
|
-
* @param {Object} data Data in publisher-friendly format to be published
|
|
22
|
-
* @param {string} event for which is it triggered
|
|
23
|
-
*/
|
|
24
|
-
publish: async function publish(config, data, event) {
|
|
25
|
-
data = utils.removeUndefined(data);
|
|
26
|
-
|
|
27
|
-
const client = new TableClient(config.connectionString, config.tableName);
|
|
28
|
-
|
|
29
|
-
await client.createEntity(data);
|
|
30
|
-
|
|
31
|
-
console.log(`TableStorage - ${event} - sent`);
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Validates an object against given schema
|
|
36
|
-
* @param {Object} data An object to validate.
|
|
37
|
-
* @param {string} schema Name of the schema. That's name of a file with `.schema.json` extension in `customizable/schemas` subfolder of current publisher folder
|
|
38
|
-
* @returns {boolean} Validation result, true if successful, false if unsuccessfull (in which case more info is written to console)
|
|
39
|
-
*/
|
|
40
|
-
validate: function validate(data, schema) {
|
|
41
|
-
if (!schema) throw new Error("Schema parameters not provided");
|
|
42
|
-
if (schema.indexOf("/") >= 0) throw new Error("Schema must be provided as schema name, not schema path");
|
|
43
|
-
//More validation done by utils.validate
|
|
44
|
-
return utils.validate(data, SOURCE, schema);
|
|
45
|
-
}
|
|
46
|
-
};
|